Commit | Line | Data |
---|---|---|
bb4e9162 YST |
1 | package Module::Build::Platform::MacOS; |
2 | ||
3 | use strict; | |
4 | use Module::Build::Base; | |
5 | use base qw(Module::Build::Base); | |
6 | ||
7 | use ExtUtils::Install; | |
8 | ||
a314697d RS |
9 | sub have_multiarg_pipeopen { 0 } |
10 | ||
bb4e9162 YST |
11 | sub new { |
12 | my $class = shift; | |
13 | my $self = $class->SUPER::new(@_); | |
14 | ||
15 | # $Config{sitelib} and $Config{sitearch} are, unfortunately, missing. | |
16 | $self->{config}{sitelib} ||= $self->{config}{installsitelib}; | |
17 | $self->{config}{sitearch} ||= $self->{config}{installsitearch}; | |
18 | ||
19 | # For some reason $Config{startperl} is filled with a bunch of crap. | |
20 | $self->{config}{startperl} =~ s/.*Exit \{Status\}\s//; | |
21 | ||
22 | return $self; | |
23 | } | |
24 | ||
25 | sub make_executable { | |
26 | my $self = shift; | |
27 | require MacPerl; | |
28 | foreach (@_) { | |
29 | MacPerl::SetFileInfo('McPL', 'TEXT', $_); | |
30 | } | |
31 | } | |
32 | ||
33 | sub dispatch { | |
34 | my $self = shift; | |
35 | ||
36 | if( !@_ and !@ARGV ) { | |
37 | require MacPerl; | |
38 | ||
39 | # What comes first in the action list. | |
40 | my @action_list = qw(build test install); | |
41 | my %actions = map {+($_, 1)} $self->known_actions; | |
42 | delete @actions{@action_list}; | |
43 | push @action_list, sort { $a cmp $b } keys %actions; | |
44 | ||
45 | my %toolserver = map {+$_ => 1} qw(test disttest diff testdb); | |
46 | foreach (@action_list) { | |
47 | $_ .= ' *' if $toolserver{$_}; | |
48 | } | |
49 | ||
50 | my $cmd = MacPerl::Pick("What build command? ('*' requires ToolServer)", @action_list); | |
51 | return unless defined $cmd; | |
52 | $cmd =~ s/ \*$//; | |
53 | $ARGV[0] = ($cmd); | |
54 | ||
55 | my $args = MacPerl::Ask('Any extra arguments? (ie. verbose=1)', ''); | |
56 | return unless defined $args; | |
57 | push @ARGV, $self->split_like_shell($args); | |
58 | } | |
59 | ||
60 | $self->SUPER::dispatch(@_); | |
61 | } | |
62 | ||
63 | sub ACTION_realclean { | |
64 | my $self = shift; | |
65 | chmod 0666, $self->{properties}{build_script}; | |
66 | $self->SUPER::ACTION_realclean; | |
67 | } | |
68 | ||
69 | # ExtUtils::Install has a hard-coded '.' directory in versions less | |
70 | # than 1.30. We use a sneaky trick to turn that into ':'. | |
71 | # | |
72 | # Note that we do it here in a cross-platform way, so this code could | |
73 | # actually go in Module::Build::Base. But we put it here to be less | |
74 | # intrusive for other platforms. | |
75 | ||
76 | sub ACTION_install { | |
77 | my $self = shift; | |
78 | ||
79 | return $self->SUPER::ACTION_install(@_) | |
80 | if eval {ExtUtils::Install->VERSION('1.30'); 1}; | |
81 | ||
82 | local $^W = 0; # Avoid a 'redefine' warning | |
83 | local *ExtUtils::Install::find = sub { | |
84 | my ($code, @dirs) = @_; | |
85 | ||
86 | @dirs = map { $_ eq '.' ? File::Spec->curdir : $_ } @dirs; | |
87 | ||
88 | return File::Find::find($code, @dirs); | |
89 | }; | |
90 | ||
91 | return $self->SUPER::ACTION_install(@_); | |
92 | } | |
93 | ||
94 | 1; | |
95 | __END__ | |
96 | ||
97 | =head1 NAME | |
98 | ||
99 | Module::Build::Platform::MacOS - Builder class for MacOS platforms | |
100 | ||
101 | =head1 DESCRIPTION | |
102 | ||
103 | The sole purpose of this module is to inherit from | |
104 | C<Module::Build::Base> and override a few methods. Please see | |
105 | L<Module::Build> for the docs. | |
106 | ||
107 | =head2 Overriden Methods | |
108 | ||
109 | =over 4 | |
110 | ||
111 | =item new() | |
112 | ||
113 | MacPerl doesn't define $Config{sitelib} or $Config{sitearch} for some | |
114 | reason, but $Config{installsitelib} and $Config{installsitearch} are | |
115 | there. So we copy the install variables to the other location | |
116 | ||
117 | =item make_executable() | |
118 | ||
119 | On MacOS we set the file type and creator to MacPerl so it will run | |
120 | with a double-click. | |
121 | ||
122 | =item dispatch() | |
123 | ||
124 | Because there's no easy way to say "./Build test" on MacOS, if | |
125 | dispatch is called with no arguments and no @ARGV a dialog box will | |
126 | pop up asking what action to take and any extra arguments. | |
127 | ||
128 | Default action is "test". | |
129 | ||
130 | =item ACTION_realclean() | |
131 | ||
132 | Need to unlock the Build program before deleting. | |
133 | ||
134 | =back | |
135 | ||
136 | =head1 AUTHOR | |
137 | ||
138 | Michael G Schwern <schwern@pobox.com> | |
139 | ||
140 | ||
141 | =head1 SEE ALSO | |
142 | ||
143 | perl(1), Module::Build(3), ExtUtils::MakeMaker(3) | |
144 | ||
145 | =cut |