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