diff options
author | Andrew Tridgell <tridge@samba.org> | 2009-09-19 12:28:02 -0700 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2009-09-19 14:11:57 -0700 |
commit | c35bbad63e50b9975fb5753cdd60901020e2d81f (patch) | |
tree | e634600098a424e857f691d3c8f0a014b9729b98 /source4/script | |
parent | 7c807de6b87a57352fe408d27b32c217523a95cd (diff) | |
download | samba-c35bbad63e50b9975fb5753cdd60901020e2d81f.tar.gz samba-c35bbad63e50b9975fb5753cdd60901020e2d81f.tar.bz2 samba-c35bbad63e50b9975fb5753cdd60901020e2d81f.zip |
s4-scripts: make minimal_includes handle our -I overrides
Diffstat (limited to 'source4/script')
-rwxr-xr-x | source4/script/minimal_includes.pl | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/source4/script/minimal_includes.pl b/source4/script/minimal_includes.pl index 963dc10f8b..2bcbd1152a 100755 --- a/source4/script/minimal_includes.pl +++ b/source4/script/minimal_includes.pl @@ -10,6 +10,7 @@ use Getopt::Long; my $opt_help = 0; my $opt_remove = 0; +my $opt_skip_system = 0; ##################################################################### # write a string into a file @@ -62,24 +63,31 @@ sub test_include($$$$) my $i = shift; my $original = shift; my $line = $lines->[$i]; + my $testfname; $lines->[$i] = ""; - save_lines("_testcompile.c", $lines); + + `/bin/mv -f $fname $fname.misaved` && die "failed to rename $fname"; + save_lines($fname, $lines); - my $out = test_compile("_testcompile.c"); - $out =~ s/_testcompile.c/$fname/g; + my $out = test_compile($fname); if ($out eq $original) { if ($opt_remove) { - print "$fname: removing $line\n"; - save_lines($fname, $lines); - return; + if ($opt_skip_system && + $line =~ /system\//) { + print "$fname: not removing system include $line\n"; + } else { + print "$fname: removing $line\n"; + return; + } + } else { + print "$fname: might be able to remove $line\n"; } - print "$fname: might be able to remove $line\n"; } $lines->[$i] = $line; - unlink("_testcompile.c"); + `/bin/mv -f $fname.misaved $fname` && die "failed to restore $fname"; } sub process_file($) @@ -127,8 +135,9 @@ sub ShowHelp() Usage: minimal_includes.pl [options] <C files....> Options: - --help show help - --remove remove includes, don't just list them + --help show help + --remove remove includes, don't just list them + --skip-system don't remove system/ includes "; } @@ -137,6 +146,7 @@ sub ShowHelp() GetOptions ( 'h|help|?' => \$opt_help, 'remove' => \$opt_remove, + 'skip-system' => \$opt_skip_system, ); if ($opt_help) { |