svn commit: samba r14481 - in branches/SAMBA_4_0/source: . script

jelmer at samba.org jelmer at samba.org
Thu Mar 16 16:02:23 GMT 2006


Author: jelmer
Date: 2006-03-16 16:02:21 +0000 (Thu, 16 Mar 2006)
New Revision: 14481

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=14481

Log:
Change paths in headers on the fly when installing. Adds a simple text 
file that contains the paths where headers need to be installed.

Added:
   branches/SAMBA_4_0/source/headermap.txt
Modified:
   branches/SAMBA_4_0/source/script/installheader.pl


Changeset:
Added: branches/SAMBA_4_0/source/headermap.txt
===================================================================
--- branches/SAMBA_4_0/source/headermap.txt	2006-03-16 15:21:41 UTC (rev 14480)
+++ branches/SAMBA_4_0/source/headermap.txt	2006-03-16 16:02:21 UTC (rev 14481)
@@ -0,0 +1,47 @@
+# FIXME: This file should be autogenerated by the build system at some 
+# point
+lib/talloc/talloc.h: talloc.h
+lib/util/util.h: util.h
+lib/util/debug.h: util/debug.h
+lib/util/mutex.h: util/mutex.h
+lib/util/util_proto.h: util/proto.h
+nt_status.h: core/nt_status.h
+lib/util/byteorder.h: util/byteorder.h
+lib/util/safe_string.h: util/safe_string.h
+lib/util/xfile.h: util/xfile.h
+lib/tdr/tdr.h: tdr.h
+librpc/rpc/dcerpc.h: dcerpc.h
+lib/socket_wrapper/socket_wrapper.h: socket_wrapper.h
+libnet/libnet.h: libnet.h
+libnet/libnet_join.h: libnet/join.h
+libnet/libnet_lookup.h: libnet/lookup.h
+libnet/libnet_passwd.h: libnet/passwd.h
+libnet/libnet_rpc.h: libnet/rpc.h
+libnet/libnet_share.h: libnet/share.h
+libnet/libnet_time.h: libnet/time.h
+libnet/libnet_user.h: libnet/user.h
+libnet/libnet_site.h: libnet/site.h
+libnet/libnet_vampire.h: libnet/vampire.h
+libnet/userinfo.h: libnet/userinfo.h
+libnet/userman.h: libnet/userman.h
+lib/ldb/include/ldb.h: ldb.h
+ntvfs/ntvfs.h: ntvfs.h
+lib/tdb/include/tdb.h: tdb.h
+auth/gensec/gensec.h: gensec.h
+gtk/common/gtk-smb.h: gtk-smb.h
+gtk/common/select.h: gtk/select.h
+librpc/ndr/libndr.h: ndr.h
+lib/registry/registry.h: registry.h
+libcli/util/nterr.h: core/nterr.h
+libcli/util/doserr.h: core/doserr.h
+libcli/util/nt_status.h: core/ntstatus.h
+libcli/cldap/cldap.h: cldap.h
+lib/samba3/samba3.h: samba3.h
+include/core.h: core.h
+librpc/gen_ndr/dcerpc.h: gen_ndr/dcerpc.h
+librpc/gen_ndr/misc.h: gen_ndr/misc.h
+librpc/ndr/libndr_proto.h: ndr/proto.h
+librpc/rpc/dcerpc_proto.h: dcerpc/proto.h
+lib/tdr/tdr_proto.h: tdr/proto.h
+auth/credentials/credentials.h: credentials.h
+auth/credentials/credentials_proto.h: credentials/proto.h


Property changes on: branches/SAMBA_4_0/source/headermap.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: branches/SAMBA_4_0/source/script/installheader.pl
===================================================================
--- branches/SAMBA_4_0/source/script/installheader.pl	2006-03-16 15:21:41 UTC (rev 14480)
+++ branches/SAMBA_4_0/source/script/installheader.pl	2006-03-16 16:02:21 UTC (rev 14481)
@@ -1,18 +1,70 @@
 #!/usr/bin/perl
+# Copyright (C) 2006 Jelmer Vernooij
 use strict;
 use File::Basename;
 
 my $includedir = shift;
 
+
+sub read_headermap($)
+{
+	my ($fn) = @_;
+	my %map = ();
+	my $ln = 0;
+	open(MAP, "<headermap.txt");
+	while(<MAP>) {
+		$ln++;
+		s/#.*$//g;
+		next if (/^\s*$/);
+		if (! /^(.*): (.*)$/) {
+			print STDERR "headermap.txt:$ln: Malformed line\n";
+			next;
+		}
+		$map{$1} = $2;
+	}
+
+	close(MAP);
+
+	return %map;
+}
+
+my %map = read_headermap("headermap.txt");
+
+sub findmap($)
+{
+	$_ = shift;
+	s/^\.\///g;
+
+	if (! -f $_ && -f "lib/$_") { $_ = "lib/$_"; }
+	
+	return $map{$_};
+}
+
+sub rewrite_include($$)
+{
+	my ($pos,$d) = @_;
+
+	my $n = findmap($d);
+	return $n if $n; 
+	return $d;
+}
+
 sub install_header($$)
 {
 	my ($src,$dst) = @_;
 
+	my $lineno = 0;
+
 	open(IN, "<$src");
 	open(OUT, ">$dst");
 
 	while (<IN>) {
-		print OUT $_;
+		$lineno++;
+		if (/^#include \"(.*)\"/) {
+			print OUT "#include <" . rewrite_include("$src:$lineno", $1) . ">\n";
+		} else {
+			print OUT $_;
+		}
 	}
 
 	close(OUT);
@@ -21,15 +73,25 @@
 
 foreach my $p (@ARGV)
 {
- my $p2 = basename($p);
- print "Installing $p as $includedir/$p2\n";
+	my $p2 = findmap($p);
+	unless ($p2) {
+		warn("Unable to map $p");
+		next;
+	}
+ 	print "Installing $p as $includedir/$p2\n";
 
- if ( -f "$includedir/$p2" ) {
-   unlink("$includedir/$p2.old");
-   rename("$includedir/$p2", "$includedir/$p2.old");
- }
+	my $dirname = dirname($p2);
 
- install_header($p,"$includedir/$p2");
+	if (! -d "$includedir/$dirname") {
+		mkdir("$includedir/$dirname");
+	}
+
+	if ( -f "$includedir/$p2" ) {
+		unlink("$includedir/$p2.old");
+		rename("$includedir/$p2", "$includedir/$p2.old");
+	}
+
+	install_header($p,"$includedir/$p2");
 }
 
 print <<EOF;



More information about the samba-cvs mailing list