[svn:parrot] r44035 - in branches/rm_cflags: lib/Parrot/Configure t/configure
coke at svn.parrot.org
coke at svn.parrot.org
Tue Feb 16 18:55:23 UTC 2010
Author: coke
Date: Tue Feb 16 18:55:20 2010
New Revision: 44035
URL: https://trac.parrot.org/parrot/changeset/44035
Log:
Allow @foo?bar@ replacement when generating makefiles.
(defaults to @foo@ if @foo?bar@ isn't defined)
Modified:
branches/rm_cflags/lib/Parrot/Configure/Compiler.pm
branches/rm_cflags/t/configure/034-step.t
Modified: branches/rm_cflags/lib/Parrot/Configure/Compiler.pm
==============================================================================
--- branches/rm_cflags/lib/Parrot/Configure/Compiler.pm Tue Feb 16 18:00:18 2010 (r44034)
+++ branches/rm_cflags/lib/Parrot/Configure/Compiler.pm Tue Feb 16 18:55:20 2010 (r44035)
@@ -197,10 +197,15 @@
$conf->genfile($source, $target, %options);
-Takes the specified source file, replacing entries like C<@FOO@> with
-C<FOO>'s value from the configuration system's data, and writes the results
+Takes the specified source file, replacing entries like C<@key@> with
+C<key>'s value from the configuration system's data, and writes the results
to specified target file.
+If a C<?> is present in the C<@key@>, the replaced value will first try to
+use the full key, but if that is not present, the key up to the C<?> is used.
+For example, if C<@cc_warnings?src/embed.c@> is used, and that key doesn't
+exist, the fallback key would be C<@cc_warnings@>.
+
Respects the following options when manipulating files (Note: most of the
replacement syntax assumes the source text is on a single line.)
@@ -532,11 +537,26 @@
# interpolate @foo@ values
$line =~ s{ \@ (\w+) \@ }{
if(defined(my $val=$conf->data->get($1))) {
- #use Data::Dumper;warn Dumper("val for $1 is ",$val);
$val;
}
else {
- warn "value for '$1' in $source is undef";
+ warn "value for '\@$1\@' in $source is undef";
+ '';
+ }
+ }egx;
+
+ # interpolate @foo?bar@ values
+ $line =~ s{ \@ (\w+) \? (\w+) \@ }{
+ my $full = $1 . '?' . $2;
+ my $base = $1;
+ if(defined(my $val=$conf->data->get($full))) {
+ $val;
+ }
+ elsif(defined($val=$conf->data->get($base))) {
+ $val;
+ }
+ else {
+ warn "value for '\@$full\@' in $source is undef, no fallback";
'';
}
}egx;
Modified: branches/rm_cflags/t/configure/034-step.t
==============================================================================
--- branches/rm_cflags/t/configure/034-step.t Tue Feb 16 18:00:18 2010 (r44034)
+++ branches/rm_cflags/t/configure/034-step.t Tue Feb 16 18:55:20 2010 (r44035)
@@ -114,7 +114,7 @@
\$stderr
);
ok($rv, "genfile() returned true when warning expected" );
- like( $stderr, qr/value for 'foobar'/, "got expected warning" );
+ like( $stderr, qr/value for '\@foobar\@'/, "got expected warning" );
unlink $dummy or croak "Unable to delete file after testing";
chdir $cwd or croak "Unable to change back to starting directory";
More information about the parrot-commits
mailing list