| 1 | package Module::Build::Platform::MacOS; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | our $VERSION = '0.4234'; | ||
| 6 | $VERSION = eval $VERSION; | ||
| 7 | use Module::Build::Base; | ||
| 8 | our @ISA = qw(Module::Build::Base); | ||
| 9 | |||
| 10 | use ExtUtils::Install; | ||
| 11 | |||
| 12 | sub have_forkpipe { 0 } | ||
| 13 | |||
| 14 | sub new { | ||
| 15 | my $class = shift; | ||
| 16 | my $self = $class->SUPER::new(@_); | ||
| 17 | |||
| 18 | # $Config{sitelib} and $Config{sitearch} are, unfortunately, missing. | ||
| 19 | foreach ('sitelib', 'sitearch') { | ||
| 20 | $self->config($_ => $self->config("install$_")) | ||
| 21 | unless $self->config($_); | ||
| 22 | } | ||
| 23 | |||
| 24 | # For some reason $Config{startperl} is filled with a bunch of crap. | ||
| 25 | (my $sp = $self->config('startperl')) =~ s/.*Exit \{Status\}\s//; | ||
| 26 | $self->config(startperl => $sp); | ||
| 27 | |||
| 28 | return $self; | ||
| 29 | } | ||
| 30 | |||
| 31 | sub make_executable { | ||
| 32 | my $self = shift; | ||
| 33 | require MacPerl; | ||
| 34 | foreach (@_) { | ||
| 35 | MacPerl::SetFileInfo('McPL', 'TEXT', $_); | ||
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 | sub dispatch { | ||
| 40 | my $self = shift; | ||
| 41 | |||
| 42 | if( !@_ and !@ARGV ) { | ||
| 43 | require MacPerl; | ||
| 44 | |||
| 45 | # What comes first in the action list. | ||
| 46 | my @action_list = qw(build test install); | ||
| 47 | my %actions = map {+($_, 1)} $self->known_actions; | ||
| 48 | delete @actions{@action_list}; | ||
| 49 | push @action_list, sort { $a cmp $b } keys %actions; | ||
| 50 | |||
| 51 | my %toolserver = map {+$_ => 1} qw(test disttest diff testdb); | ||
| 52 | foreach (@action_list) { | ||
| 53 | $_ .= ' *' if $toolserver{$_}; | ||
| 54 | } | ||
| 55 | |||
| 56 | my $cmd = MacPerl::Pick("What build command? ('*' requires ToolServer)", @action_list); | ||
| 57 | return unless defined $cmd; | ||
| 58 | $cmd =~ s/ \*$//; | ||
| 59 | $ARGV[0] = ($cmd); | ||
| 60 | |||
| 61 | my $args = MacPerl::Ask('Any extra arguments? (ie. verbose=1)', ''); | ||
| 62 | return unless defined $args; | ||
| 63 | push @ARGV, $self->split_like_shell($args); | ||
| 64 | } | ||
| 65 | |||
| 66 | $self->SUPER::dispatch(@_); | ||
| 67 | } | ||
| 68 | |||
| 69 | sub ACTION_realclean { | ||
| 70 | my $self = shift; | ||
| 71 | chmod 0666, $self->{properties}{build_script}; | ||
| 72 | $self->SUPER::ACTION_realclean; | ||
| 73 | } | ||
| 74 | |||
| 75 | # ExtUtils::Install has a hard-coded '.' directory in versions less | ||
| 76 | # than 1.30. We use a sneaky trick to turn that into ':'. | ||
| 77 | # | ||
| 78 | # Note that we do it here in a cross-platform way, so this code could | ||
| 79 | # actually go in Module::Build::Base. But we put it here to be less | ||
| 80 | # intrusive for other platforms. | ||
| 81 | |||
| 82 | sub ACTION_install { | ||
| 83 | my $self = shift; | ||
| 84 | |||
| 85 | return $self->SUPER::ACTION_install(@_) | ||
| 86 | if eval {ExtUtils::Install->VERSION('1.30'); 1}; | ||
| 87 | |||
| 88 | local $^W = 0; # Avoid a 'redefine' warning | ||
| 89 | local *ExtUtils::Install::find = sub { | ||
| 90 | my ($code, @dirs) = @_; | ||
| 91 | |||
| 92 | @dirs = map { $_ eq '.' ? File::Spec->curdir : $_ } @dirs; | ||
| 93 | |||
| 94 | return File::Find::find($code, @dirs); | ||
| 95 | }; | ||
| 96 | |||
| 97 | return $self->SUPER::ACTION_install(@_); | ||
| 98 | } | ||
| 99 | |||
| 100 | 1; | ||
| 101 | __END__ |