From 3bb28c83e277bda9233de4cca71f367ce00be5c3 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Mar 2006 13:04:28 +0000 Subject: r14471: Convert installheader script to perl (This used to be commit c6a478a1af38cad5622d3c3c53a7a99f9770b169) --- source4/script/installheader.pl | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 source4/script/installheader.pl (limited to 'source4/script/installheader.pl') diff --git a/source4/script/installheader.pl b/source4/script/installheader.pl new file mode 100755 index 0000000000..1af05f3fea --- /dev/null +++ b/source4/script/installheader.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl +use strict; +use File::Basename; + +my $includedir = shift; + +sub install_header($$) +{ + my ($src,$dst) = @_; + + open(IN, "<$src"); + open(OUT, ">$dst"); + + while () { + print OUT $_; + } + + close(OUT); + close(IN); +} + +foreach my $p (@ARGV) +{ + my $p2 = basename($p); + print "Installing $p as $includedir/$p2\n"; + + if ( -f "$includedir/$p2" ) { + unlink("$includedir/$p2.old"); + rename("$includedir/$p2", "$includedir/$p2.old"); + } + + install_header($p,"$includedir/$p2"); +} + +print < Date: Thu, 16 Mar 2006 16:02:21 +0000 Subject: r14481: Change paths in headers on the fly when installing. Adds a simple text file that contains the paths where headers need to be installed. (This used to be commit c3d975f4dce85245c7ba2b159c1128711d828291) --- source4/script/installheader.pl | 78 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 70 insertions(+), 8 deletions(-) (limited to 'source4/script/installheader.pl') diff --git a/source4/script/installheader.pl b/source4/script/installheader.pl index 1af05f3fea..808ab8d433 100755 --- a/source4/script/installheader.pl +++ b/source4/script/installheader.pl @@ -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, ") { + $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 () { - print OUT $_; + $lineno++; + if (/^#include \"(.*)\"/) { + print OUT "#include <" . rewrite_include("$src:$lineno", $1) . ">\n"; + } else { + print OUT $_; + } } close(OUT); @@ -21,15 +73,25 @@ sub install_header($$) 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"; + + my $dirname = dirname($p2); - if ( -f "$includedir/$p2" ) { - unlink("$includedir/$p2.old"); - rename("$includedir/$p2", "$includedir/$p2.old"); - } + 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"); + install_header($p,"$includedir/$p2"); } print < Date: Tue, 11 Apr 2006 11:37:52 +0000 Subject: r15036: Add out of tree build support and see how buildfarm will respond to make constructs (This used to be commit 9329854489e2c231ffb7986d39009e0936873c11) --- source4/script/installheader.pl | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'source4/script/installheader.pl') diff --git a/source4/script/installheader.pl b/source4/script/installheader.pl index 808ab8d433..e0597ab381 100755 --- a/source4/script/installheader.pl +++ b/source4/script/installheader.pl @@ -2,16 +2,18 @@ # Copyright (C) 2006 Jelmer Vernooij use strict; use File::Basename; +use Cwd 'abs_path'; my $includedir = shift; - +my $builddir = abs_path($ENV{samba_builddir}); +my $srcdir = abs_path($ENV{samba_srcdir}); sub read_headermap($) { my ($fn) = @_; my %map = (); my $ln = 0; - open(MAP, ") { $ln++; s/#.*$//g; @@ -28,14 +30,19 @@ sub read_headermap($) return %map; } -my %map = read_headermap("headermap.txt"); +my %map = read_headermap("$srcdir/headermap.txt"); sub findmap($) { $_ = shift; s/^\.\///g; + s/$builddir\///g; + s/$srcdir\///g; if (! -f $_ && -f "lib/$_") { $_ = "lib/$_"; } + if ($srcdir !~ $builddir) { + if (! -f "$srcdir/$_" && -f "$srcdir/lib/$_") { $_ = "lib/$_"; } + } return $map{$_}; } @@ -55,7 +62,7 @@ sub install_header($$) my $lineno = 0; - open(IN, "<$src"); + open(IN, "<$src") || open(IN, "<$srcdir/$src"); open(OUT, ">$dst"); while () { @@ -75,8 +82,8 @@ foreach my $p (@ARGV) { my $p2 = findmap($p); unless ($p2) { - warn("Unable to map $p"); - next; + warn("Unable to map $p"); + next; } print "Installing $p as $includedir/$p2\n"; -- cgit From 91631d9b90c7422debb59b45b13bee9b6caba832 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 26 Apr 2006 09:51:02 +0000 Subject: r15267: Fix call to mkdir() for old versions of perl. This should fix installation on sun1. (This used to be commit a56900a7a2e40f17df9a49e7aa3faf561173fe37) --- source4/script/installheader.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/script/installheader.pl') diff --git a/source4/script/installheader.pl b/source4/script/installheader.pl index e0597ab381..a47e2b1177 100755 --- a/source4/script/installheader.pl +++ b/source4/script/installheader.pl @@ -90,7 +90,7 @@ foreach my $p (@ARGV) my $dirname = dirname($p2); if (! -d "$includedir/$dirname") { - mkdir("$includedir/$dirname"); + mkdir("$includedir/$dirname", 0777); } if ( -f "$includedir/$p2" ) { -- cgit From cad39146196880ec73177654abc2c47c5d1cc82e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 1 May 2006 15:45:26 +0000 Subject: r15378: Fix installheader script. Alexander, this will break installation of headers for srcdir != builddir (This used to be commit 527a40d80b096a0716fe71eae5a65e2a136a7ac5) --- source4/script/installheader.pl | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'source4/script/installheader.pl') diff --git a/source4/script/installheader.pl b/source4/script/installheader.pl index a47e2b1177..7b8dd8e92a 100755 --- a/source4/script/installheader.pl +++ b/source4/script/installheader.pl @@ -2,18 +2,16 @@ # Copyright (C) 2006 Jelmer Vernooij use strict; use File::Basename; -use Cwd 'abs_path'; my $includedir = shift; -my $builddir = abs_path($ENV{samba_builddir}); -my $srcdir = abs_path($ENV{samba_srcdir}); + sub read_headermap($) { my ($fn) = @_; my %map = (); my $ln = 0; - open(MAP, "<$fn"); + open(MAP, ") { $ln++; s/#.*$//g; @@ -30,19 +28,14 @@ sub read_headermap($) return %map; } -my %map = read_headermap("$srcdir/headermap.txt"); +my %map = read_headermap("headermap.txt"); sub findmap($) { $_ = shift; s/^\.\///g; - s/$builddir\///g; - s/$srcdir\///g; if (! -f $_ && -f "lib/$_") { $_ = "lib/$_"; } - if ($srcdir !~ $builddir) { - if (! -f "$srcdir/$_" && -f "$srcdir/lib/$_") { $_ = "lib/$_"; } - } return $map{$_}; } @@ -62,7 +55,7 @@ sub install_header($$) my $lineno = 0; - open(IN, "<$src") || open(IN, "<$srcdir/$src"); + open(IN, "<$src"); open(OUT, ">$dst"); while () { -- cgit From 2eeb0e5f282a22e11de07d4038b01fc446e3fc14 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 6 Nov 2006 12:05:09 +0000 Subject: r19569: Require that all public header files have a destination path. Fix places where this was currently not the case. (This used to be commit 3894497a232df8cf0457c7439c9ae347f63f24a1) --- source4/script/installheader.pl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/script/installheader.pl') diff --git a/source4/script/installheader.pl b/source4/script/installheader.pl index 7b8dd8e92a..d1f96b2592 100755 --- a/source4/script/installheader.pl +++ b/source4/script/installheader.pl @@ -75,8 +75,7 @@ foreach my $p (@ARGV) { my $p2 = findmap($p); unless ($p2) { - warn("Unable to map $p"); - next; + die("Unable to map $p"); } print "Installing $p as $includedir/$p2\n"; -- cgit From 4a8212c9550257d2fe3796a3e9f98e4e0367c38b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 May 2008 20:46:16 +0200 Subject: Refuse to install autogenerated proto header files. (This used to be commit c0a84c2b4698f6ac9b555cc74bed52e5930804d9) --- source4/script/installheader.pl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/script/installheader.pl') diff --git a/source4/script/installheader.pl b/source4/script/installheader.pl index d1f96b2592..6b10bde65f 100755 --- a/source4/script/installheader.pl +++ b/source4/script/installheader.pl @@ -60,6 +60,8 @@ sub install_header($$) while () { $lineno++; + die("Will not install autogenerated header $src") if (/This file was automatically generated by mkproto.pl. DO NOT EDIT/); + if (/^#include \"(.*)\"/) { print OUT "#include <" . rewrite_include("$src:$lineno", $1) . ">\n"; } else { -- cgit