Skip to content

Commit

Permalink
Split init_others() into init_tools() and init_others().
Browse files Browse the repository at this point in the history
This separates the complicated linker and compiler tools from the simple ones.
It makes it easier to initialize the tools for testing purposes.
  • Loading branch information
schwern committed Oct 23, 2011
1 parent 7b575bf commit f4904b4
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 56 deletions.
57 changes: 35 additions & 22 deletions lib/ExtUtils/MM_Any.pm
Expand Up @@ -1913,15 +1913,14 @@ sub init_VERSION {
}


=head3 init_others
$MM->init_others();
=head3 init_tools
Initializes the macro definitions used by tools_other() and places them
in the $MM object.
$MM->init_tools();
If there is no description, its the same as the parameter to
WriteMakefile() documented in ExtUtils::MakeMaker.
Initializes the simple macro definitions used by tools_other() and
places them in the $MM object. These use conservative cross platform
versions and should be overridden with platform specific versions for
performance.
Defines at least these macros.
Expand All @@ -1930,11 +1929,6 @@ Defines at least these macros.
NOOP Do nothing
NOECHO Tell make not to display the command itself
MAKEFILE
FIRST_MAKEFILE
MAKEFILE_OLD
MAKE_APERL_FILE File used by MAKE_APERL
SHELL Program used to run shell commands
ECHO Print text adding a newline on the end
Expand All @@ -1953,7 +1947,7 @@ Defines at least these macros.
=cut

sub init_others {
sub init_tools {
my $self = shift;

$self->{ECHO} ||= $self->oneliner('print qq{@ARGV}', ['-l']);
Expand Down Expand Up @@ -1986,6 +1980,18 @@ CODE
$self->{UNINST} ||= 0;
$self->{VERBINST} ||= 0;

$self->{SHELL} ||= $Config{sh};

# UMASK_NULL is not used by MakeMaker but some CPAN modules
# make use of it.
$self->{UMASK_NULL} ||= "umask 0";

# Not the greatest default, but its something.
$self->{DEV_NULL} ||= "> /dev/null 2>&1";

$self->{NOOP} ||= '$(TRUE)';
$self->{NOECHO} = '@' unless defined $self->{NOECHO};

$self->{FIRST_MAKEFILE} ||= $self->{MAKEFILE} || 'Makefile';
$self->{MAKEFILE} ||= $self->{FIRST_MAKEFILE};
$self->{MAKEFILE_OLD} ||= $self->{MAKEFILE}.'.old';
Expand All @@ -1999,17 +2005,24 @@ CODE
$self->{MACROSTART} ||= '';
$self->{MACROEND} ||= '';

$self->{SHELL} ||= $Config{sh};
return;
}

# UMASK_NULL is not used by MakeMaker but some CPAN modules
# make use of it.
$self->{UMASK_NULL} ||= "umask 0";

# Not the greatest default, but its something.
$self->{DEV_NULL} ||= "> /dev/null 2>&1";
=head3 init_others
$self->{NOOP} ||= '$(TRUE)';
$self->{NOECHO} = '@' unless defined $self->{NOECHO};
$MM->init_others();
Initializes the macro definitions having to do with compiling and
linking used by tools_other() and places them in the $MM object.
If there is no description, its the same as the parameter to
WriteMakefile() documented in ExtUtils::MakeMaker.
=cut

sub init_others {
my $self = shift;

$self->{LD_RUN_PATH} = "";

Expand Down Expand Up @@ -2050,7 +2063,7 @@ CODE
: ($Config{usedl} ? 'dynamic' : 'static');
}

return 1;
return;
}


Expand Down
17 changes: 7 additions & 10 deletions lib/ExtUtils/MM_Unix.pm
Expand Up @@ -1739,17 +1739,14 @@ EOP
$self->{NAME} eq "ExtUtils::MakeMaker";
}

=item init_others
=item init_tools
Initializes EXTRALIBS, BSLOADLIBS, LDLOADLIBS, LIBS, LD_RUN_PATH, LD,
OBJECT, BOOTDEP, PERLMAINCC, LDFROM, LINKTYPE, SHELL, NOOP,
FIRST_MAKEFILE, MAKEFILE_OLD, NOECHO, RM_F, RM_RF, TEST_F,
TOUCH, CP, MV, CHMOD, UMASK_NULL, ECHO, ECHO_N
Initializes tools to use their common (and faster) Unix commands.
=cut

sub init_others { # --- Initialize Other Attributes
my($self) = shift;
sub init_tools {
my $self = shift;

$self->{ECHO} ||= 'echo';
$self->{ECHO_N} ||= 'echo -n';
Expand All @@ -1765,13 +1762,13 @@ sub init_others { # --- Initialize Other Attributes

$self->{LD} ||= 'ld';

$self->SUPER::init_others(@_);
return $self->SUPER::init_tools(@_);

# After SUPER::init_others so $Config{shell} has a
# After SUPER::init_tools so $Config{shell} has a
# chance to get set.
$self->{SHELL} ||= '/bin/sh';

return 1;
return;
}


Expand Down
36 changes: 27 additions & 9 deletions lib/ExtUtils/MM_VMS.pm
Expand Up @@ -447,21 +447,20 @@ sub init_main {
}
}

=item init_others (override)
=item init_tools (override)
Provide VMS-specific forms of various utility commands, then hand
off to the default MM_Unix method.
Provide VMS-specific forms of various utility commands.
DEV_NULL should probably be overriden with something.
Sets DEV_NULL to nothing because I don't know how to do it on VMS.
Also changes EQUALIZE_TIMESTAMP to set revision date of target file to
Changes EQUALIZE_TIMESTAMP to set revision date of target file to
one second later than source file, since MMK interprets precisely
equal revision dates for a source and target file as a sign that the
target needs to be updated.
=cut

sub init_others {
sub init_tools {
my($self) = @_;

$self->{NOOP} = 'Continue';
Expand Down Expand Up @@ -493,17 +492,34 @@ sub init_others {
install([ from_to => {split(' ', <STDIN>)}, verbose => '$(VERBINST)', uninstall_shadows => '$(UNINST)', dir_mode => '$(PERM_DIR)' ]);
CODE

$self->SUPER::init_others;
$self->{UMASK_NULL} = '! ';

$self->{SHELL} ||= 'Posix';
$self->SUPER::init_tools;

$self->{UMASK_NULL} = '! ';
# Use the default shell
$self->{SHELL} ||= 'Posix';

# Redirection on VMS goes before the command, not after as on Unix.
# $(DEV_NULL) is used once and its not worth going nuts over making
# it work. However, Unix's DEV_NULL is quite wrong for VMS.
$self->{DEV_NULL} = '';

return;
}


=item init_others (override)
Provide VMS-specific forms of various compile and link commands
=cut

sub init_others {
my $self = shift;

# Must come first as we're modifying and deriving from the defaults.
$self->SUPER::init_others;

if ($self->{OBJECT} =~ /\s/) {
$self->{OBJECT} =~ s/(\\)?\n+\s+/ /g;
$self->{OBJECT} = $self->wraplist(
Expand All @@ -514,6 +530,8 @@ CODE
$self->{LDFROM} = $self->wraplist(
map $self->fixpath($_,0), split /,?\s+/, $self->{LDFROM}
);

return;
}


Expand Down
41 changes: 26 additions & 15 deletions lib/ExtUtils/MM_Win32.pm
Expand Up @@ -141,21 +141,13 @@ sub init_DIRFILESEP {
: '\\';
}

=item B<init_others>
=item init_tools
Override some of the Unix specific commands with portable
ExtUtils::Command ones.
Also provide defaults for LD and AR in case the %Config values aren't
set.
LDLOADLIBS's default is changed to $Config{libs}.
Adjustments are made for Borland's quirks needing -L to come first.
Override some of the slower, portable commands with Windows specific ones.
=cut

sub init_others {
sub init_tools {
my ($self) = @_;

$self->{NOOP} ||= 'rem';
Expand All @@ -165,14 +157,33 @@ sub init_others {
"\$(PERLRUN) $self->{PERL_SRC}/win32/bin/pl2bat.pl" :
'pl2bat.bat';

$self->SUPER::init_tools;

# Setting SHELL from $Config{sh} can break dmake. Its ok without it.
delete $self->{SHELL};

return;
}


=item init_others
Override the default link and compile tools.
LDLOADLIBS's default is changed to $Config{libs}.
Adjustments are made for Borland's quirks needing -L to come first.
=cut

sub init_others {
my $self = shift;

$self->{LD} ||= 'link';
$self->{AR} ||= 'lib';

$self->SUPER::init_others;

# Setting SHELL from $Config{sh} can break dmake. Its ok without it.
delete $self->{SHELL};

$self->{LDLOADLIBS} ||= $Config{libs};
# -Lfoo must come first for Borland, so we put it in LDDLFLAGS
if ($BORLAND) {
Expand All @@ -187,7 +198,7 @@ sub init_others {
$self->{LDDLFLAGS} .= " $libpath";
}

return 1;
return;
}


Expand Down
1 change: 1 addition & 0 deletions lib/ExtUtils/MakeMaker.pm
Expand Up @@ -613,6 +613,7 @@ END
$self->catfile($Config{'archlibexp'}, "Config.pm")
);

$self->init_tools();
$self->init_others();
$self->init_platform();
$self->init_PERM();
Expand Down

0 comments on commit f4904b4

Please sign in to comment.