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