diff options
author | Stefan Hajnoczi <stefanha@gmail.com> | 2008-06-04 20:56:20 +0100 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2008-06-05 00:45:33 +0100 |
commit | f866b179988f686ae90c197f0270a922ddebf718 (patch) | |
tree | 96bfecf701fd7d5f4011bf462635622269087b88 /src/util | |
parent | 842165ef7624f20b85e58f3d9c56d9110be0ae15 (diff) | |
download | ipxe-f866b179988f686ae90c197f0270a922ddebf718.zip ipxe-f866b179988f686ae90c197f0270a922ddebf718.tar.gz ipxe-f866b179988f686ae90c197f0270a922ddebf718.tar.bz2 |
[util] config-local.h to avoid accidental commits
During development it is often handy to change the config.h options from
their defaults, for example to enable debugging features.
To prevent accidental commits of debugging config.h changes, mdc
suggested having a config-local.h that is excluded from source control.
This file acts as a temporary config.h and can override any of the
defaults.
This commit is an attempt to implement the config-local.h feature.
The config.h file now has the following as its last line:
/* @TRYSOURCE config-local.h */
The @TRYSOURCE directive causes config-local.h to be included at that
point in the file. If config-local.h does not exist, no error will be
printed and parsing will continue as normal. Therefore, mkconfig.pl is
"trying" to "source" config-local.h.
Diffstat (limited to 'src/util')
-rwxr-xr-x | src/util/mkconfig.pl | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/util/mkconfig.pl b/src/util/mkconfig.pl index 6a9c2f1..e55c2ca 100755 --- a/src/util/mkconfig.pl +++ b/src/util/mkconfig.pl @@ -7,6 +7,7 @@ use warnings; my $cfgdir = "config"; my $config_h = shift || "config.h"; +my @input_files; # Read in a whole file # @@ -110,15 +111,15 @@ sub postamble { return "\n#endif /* $guard */\n"; } -# Get the new configuration by splitting config.h file using the -# @BEGIN/@END tags +# Parse one config.h file into an existing configuration # -sub new_config { +sub parse_config { my $file = shift; - - my $cfg = {}; + my $cfg = shift; my $cursor = ""; + push ( @input_files, $file ); + open my $fh, "<$file" or die "Could not open $file: $!\n"; while ( <$fh> ) { if ( ( my $newcursor, my $suffix ) = /\@BEGIN\s+(\w+\.h)(.*)$/ ) { @@ -133,14 +134,28 @@ sub new_config { ." at $file line $.\n" unless $cursor eq $oldcursor; $cfg->{$cursor} .= $prefix."*/\n"; $cursor = ""; + } elsif ( ( my $newfile ) = /\@TRYSOURCE\s+([\w\-]+\.h)/ ) { + die "Missing \"\@END $cursor\" before \"\@TRYSOURCE $newfile\"" + ." at $file line $.\n" if $cursor; + parse_config ( $newfile, $cfg ) if -e $newfile; } else { $cfg->{$cursor} .= $_ if $cursor; } } close $fh; die "Missing \"\@END $cursor\" in $file\n" if $cursor; +} - foreach $cursor ( keys %$cfg ) { +# Get the new configuration by splitting config.h file using the +# @BEGIN/@END tags +# +sub new_config { + my $file = shift; + my $cfg = {}; + + parse_config ( $file, $cfg ); + + foreach my $cursor ( keys %$cfg ) { $cfg->{$cursor} .= postamble ( $cursor ); } @@ -180,9 +195,11 @@ foreach my $file ( keys %$new ) { } # If we now have fragments that are older than config.h, set the -# timestamp on config.h to match the oldest fragment, to prevent make -# from always attempting to rebuild the fragments. +# timestamp on each input file to match the oldest fragment, to +# prevent make from always attempting to rebuild the fragments. # -if ( $oldest < file_mtime ( $config_h ) ) { - utime time(), $oldest, $config_h or die "Could not touch $config_h: $!\n"; +foreach my $file ( @input_files ) { + if ( $oldest < file_mtime ( $file ) ) { + utime time(), $oldest, $file or die "Could not touch $file: $!\n"; + } } |