Author: kwilliams
Date: Fri Jun 27 20:15:04 2008
New Revision: 11462
Modified:
Module-Build/trunk/lib/Module/Build/Base.pm
Module-Build/trunk/lib/Module/Build/Compat.pm
Log:
Added a one-liner builder at Schwern's suggestion
Modified: Module-Build/trunk/lib/Module/Build/Base.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Base.pm (original)
+++ Module-Build/trunk/lib/Module/Build/Base.pm Fri Jun 27 20:15:04 2008
@@ -4044,6 +4044,26 @@
return Text::ParseWords::shellwords($string);
}
+sub oneliner {
+ # Returns a string that the shell can evaluate as a perl command.
+ # This should be avoided whenever possible, since "the shell" really
+ # means zillions of shells on zillions of platforms and it's really
+ # hard to get it right all the time.
+
+ # Some of this code is stolen with permission from ExtUtils::MakeMaker.
+
+ my($self, $cmd, $switches, $args) = @_;
+ $switches = [] unless defined $switches;
+ $args = [] unless defined $args;
+
+ # Strip leading and trailing newlines
+ $cmd =~ s{^\n+}{};
+ $cmd =~ s{\n+$}{};
+
+ my $perl = ref($self) ? $self->perl : $self->find_perl_interpreter;
+ return $self->_quote_args($perl, @$switches, '-e', $cmd, @$args);
+}
+
sub run_perl_script {
my ($self, $script, $preargs, $postargs) = @_;
foreach ($preargs, $postargs) {
Modified: Module-Build/trunk/lib/Module/Build/Compat.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Compat.pm (original)
+++ Module-Build/trunk/lib/Module/Build/Compat.pm Fri Jun 27 20:15:04 2008
@@ -247,13 +247,15 @@
my $filetype = $class->is_vmsish ? '.COM' : '';
my $Build = 'Build' . $filetype . ' --makefile_env_macros 1';
+ my $unlink = $class->oneliner('1 while unlink $ARGV[0]', [],
[$args{makefile}]);
+ $unlink =~ s/\$/\$\$/g;
my $maketext = <<"EOF";
all : force_do_it
$perl $Build
realclean : force_do_it
$perl $Build realclean
- $perl -e 1 -e while -e unlink -e q=$args{makefile}=
+ $unlink
force_do_it :
@ $noop