home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / perl / MacOS.pm < prev    next >
Encoding:
Perl POD Document  |  2003-12-23  |  3.4 KB  |  145 lines

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