Re: Fwd: [Module::Build] Does ./Build work on Windows?
Status: Beta
Brought to you by:
kwilliams
|
From: Randy W. S. <ml...@th...> - 2006-02-02 01:22:30
|
demerphq wrote:
>
> The change required to MB to handle this is minimal and is implemented
> in a provisional form in the attached patch.
>
> When the Build script is created it needs to add the line
>
> close *DATA unless eof(*DATA);
>
> when being used on win32.
I think we can simplify, and apply this to all platforms.
> Then the exception line in pl2script needs
> to be removed.
> Additionally when scripts are pl2bat'ed their bat names need to be
> added to the cleanup list. This currently doesnt happen at all so MB
> cant/doesnt clean up pl2batted files properly. (It may do so
> indirectly as a directory cleanup but this doesnt help the build
> script itself.)
Yeah. They were cleaned up as part of blib, but you're right, it should
be mentioned explicitly here.
> Also, my preference (and i think the preference of many in the windows
> world) is to avoid ".bat" files on NT and latter Win32 OS'es. It
> should use the .cmd extension when on NT, W2K and XP or later. I
> hazzily recall there is a good reason for this, but i have to admit I
> dont remember what it is. Maybe its just cargo cultism and doesnt
> matter at all. Anyway, the point is the attached patch includes such
> logic. :-) I based it the behaviour change on the presence of .CMD in
> the PATHEXT enviornment var so on machines without either it will
> default to .bat
Ok.
> Im sorry i havent gotten further on this, i was distracted by other things.
No problem. You're work on this and on fixing the "Cwd won't install"
problem in EU::Install is very very much appreciated.
> BTW, there is one annoying thing about self deletion of the .cmd/.bat
> Build file. When control returns to the shell it raises a warning
> about the batch file unexpected ending. Its not an issue, but it is
> inelegant so figuring out how to make it go away would be nice.
This is the only issue holding me up. I'm going to do some experimenting
and research to see if that annoying message can be eliminated somehow.
Attached is a manually applied version of your patch against current
cvs. The only changes are applying the close(*DATA) on all OS, removing
the extraneous Build_FollowUp logic, and some line wraps.
Thanks,
Randy.
> Er, also, it might be worth just replacing the pl2bat behaviour with
> the creation of a generic Build.cmd that just contained the logic to
> launch perl Build. Then it wouldnt need to be cleaned up, and avoid
> the other little issues involved.
>
> Cheers,
> yves
>
> --
> perl -Mre=debug -e "/just|another|perl|hacker/"
>
>
> ------------------------------------------------------------------------
>
> diff -wur Module-Build-0.27_04/lib/Module/Build/Base.pm \dev\cpan\Module-Build-0.27_04_patched/lib/Module/Build/Base.pm
> --- Module-Build-0.27_04/lib/Module/Build/Base.pm 2005-12-23 17:54:53.000000000 +0100
> +++ \dev\cpan\Module-Build-0.27_04_patched/lib/Module/Build/Base.pm 2006-01-24 19:58:28.148126600 +0100
> @@ -847,7 +847,8 @@
> sub read_config {
> my ($self) = @_;
>
> - my $file = $self->config_file('build_params');
> + my $file = $self->config_file('build_params')
> + or die "No build_params?";
> my $fh = IO::File->new($file) or die "Can't read '$file': $!";
> my $ref = eval do {local $/; <$fh>};
> die if $@;
> @@ -1158,8 +1159,14 @@
>
> my $build_package = $self->build_class;
>
> + my $closedata="";
> +
> my %q = map {$_, $self->$_()} qw(config_dir base_dir);
> - $q{base_dir} = Win32::GetShortPathName($q{base_dir}) if $^O eq 'MSWin32';
> + if ( $^O eq 'MSWin32' ) {
> + $q{base_dir} = Win32::GetShortPathName($q{base_dir});
> + $closedata="\nclose(*DATA) unless eof(*DATA);"
> + ."# Necessary on Win32 to allow realclean!\n";
> + }
> my $case_tolerant = 0+(File::Spec->can('case_tolerant')
> && File::Spec->case_tolerant);
> $q{base_dir} = uc $q{base_dir} if $case_tolerant;
> @@ -1180,7 +1187,7 @@
> use Cwd;
> use File::Basename;
> use File::Spec;
> -
> +$closedata
> my \$progname;
> my \$orig_dir;
> BEGIN {
> diff -wur Module-Build-0.27_04/lib/Module/Build/Platform/Windows.pm \dev\cpan\Module-Build-0.27_04_patched/lib/Module/Build/Platform/Windows.pm
> --- Module-Build-0.27_04/lib/Module/Build/Platform/Windows.pm 2005-12-23 17:54:53.000000000 +0100
> +++ \dev\cpan\Module-Build-0.27_04_patched/lib/Module/Build/Platform/Windows.pm 2006-01-24 19:57:05.382501600 +0100
> @@ -40,17 +40,26 @@
> my $pl2bat = $self->{config}{pl2bat};
>
> if ( defined($pl2bat) && length($pl2bat) ) {
> + my $ext= $ENV{PATHEXT}=~/\.CMD(\W|$)/i ? '.cmd' : '.bat';
> +
> foreach my $script (@_) {
> - # Don't run 'pl2bat.bat' for the 'Build' script;
> - # there is no easy way to get the resulting 'Build.bat'
> - # to delete itself when doing a 'Build realclean'.
> - next if ( $script eq $self->{properties}{build_script} );
>
> (my $script_bat = $script) =~ s/\.plx?//i;
> - $script_bat .= '.bat' unless $script_bat =~ /\.bat$/i;
> -
> + if ($script_bat =~ /\.(bat|cmd)$/i) {
> + warn "Won't convert '$script' to a batch file named '$script_bat' nor to '$script_bat$ext'.\n";
> + next;
> + }
> + $script_bat .= $ext;
> + $self->add_to_cleanup($script_bat);
> my $status = $self->do_system($pl2bat, '<', $script, '>', $script_bat);
> +
> if ( $status && -f $script_bat ) {
> + if ( $script eq $self->{properties}{build_script} ) {
> + open my $fh, ">>", $script_bat or
> + die "Failed to open for append batch file '$script':$!";
> + print $fh "\nif exist Build_FollowUp$ext Build_FollowUp$ext\n";
> + close $fh;
> + }
> $self->SUPER::make_executable($script_bat);
> } else {
> warn "Unable to convert '$script' to an executable.\n";
>
>
>
>
>
>
|