[Module-build-checkins] [svn:Module-Build] r6288 - in Module-Build/trunk: . lib/Module/Build/Platfor
Status: Beta
Brought to you by:
kwilliams
From: <ra...@cv...> - 2006-05-12 00:06:36
|
Author: randys Date: Thu May 11 17:06:06 2006 New Revision: 6288 Modified: Module-Build/trunk/Changes Module-Build/trunk/lib/Module/Build/Platform/Windows.pm Module-Build/trunk/t/runthrough.t Log: Native batch scripts should not be converted by pl2bat. Modified: Module-Build/trunk/Changes ============================================================================== --- Module-Build/trunk/Changes (original) +++ Module-Build/trunk/Changes Thu May 11 17:06:06 2006 @@ -2,6 +2,9 @@ 0.2801 + - Native batch scripts under Windows should not be converted by + pl2bat. [Spotted by Ron Savage] + - Tweaked the way we determine whether a file is executable on Unix. We use this determination to decide whether to make it executable during installation. [Julian Mehnle] Modified: Module-Build/trunk/lib/Module/Build/Platform/Windows.pm ============================================================================== --- Module-Build/trunk/lib/Module/Build/Platform/Windows.pm (original) +++ Module-Build/trunk/lib/Module/Build/Platform/Windows.pm Thu May 11 17:06:06 2006 @@ -54,17 +54,26 @@ $self->SUPER::make_executable(@_); foreach my $script (@_) { - my %opts = (); - if ( $script eq $self->build_script ) { - $opts{ntargs} = q(-x -S %0 --build_bat %*); - $opts{otherargs} = q(-x -S "%0" --build_bat %1 %2 %3 %4 %5 %6 %7 %8 %9); - } - my $out = eval {$self->pl2bat(in => $script, update => 1, %opts)}; - if ( $@ ) { - $self->log_warn("WARNING: Unable to convert file '$script' to an executable script:\n$@"); + # Native batch script + if ( $script =~ /\.(bat|cmd)$/ ) { + $self->SUPER::make_executable($script); + next; + + # Perl script that needs to be wrapped in a batch script } else { - $self->SUPER::make_executable($out); + my %opts = (); + if ( $script eq $self->build_script ) { + $opts{ntargs} = q(-x -S %0 --build_bat %*); + $opts{otherargs} = q(-x -S "%0" --build_bat %1 %2 %3 %4 %5 %6 %7 %8 %9); + } + + my $out = eval {$self->pl2bat(in => $script, update => 1, %opts)}; + if ( $@ ) { + $self->log_warn("WARNING: Unable to convert file '$script' to an executable script:\n$@"); + } else { + $self->SUPER::make_executable($out); + } } } } Modified: Module-Build/trunk/t/runthrough.t ============================================================================== --- Module-Build/trunk/t/runthrough.t (original) +++ Module-Build/trunk/t/runthrough.t Thu May 11 17:06:06 2006 @@ -2,7 +2,7 @@ use strict; use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib'; -use MBTest tests => 28; +use MBTest tests => 32; use Module::Build; use Module::Build::ConfigData; @@ -197,6 +197,47 @@ ok ! -e $mb->config_dir; ok ! -e $mb->dist_dir; +chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; +$dist->remove; + +SKIP: { + skip( 'Windows only test', 4 ) unless $^O =~ /^MSWin/; + + my $script_data = <<'---'; +@echo off +echo Hello, World! +--- + + $dist = DistGen->new( dir => $tmp ); + $dist->change_file( 'Build.PL', <<'---' ); +use Module::Build; +my $build = new Module::Build( + module_name => 'Simple', + scripts => [ 'bin/script.bat' ], + license => 'perl', +); +$build->create_build_script; +--- + $dist->add_file( 'bin/script.bat', $script_data ); + + $dist->regen; + chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!"; + + $mb = Module::Build->new_from_context; + ok $mb; + + eval{ $mb->dispatch('build') }; + is $@, ''; + + my $script_file = File::Spec->catfile( qw(blib script), 'script.bat' ); + ok -f $script_file, "Native batch file copied to 'scripts'"; + + my $out = slurp( $script_file ); + is $out, $script_data, ' unmodified by pl2bat'; + + chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; + $dist->remove; +} # cleanup chdir( $cwd ) or die "Can''t chdir to '$cwd': $!"; |