Acme-Win32-PEPM
view release on metacpan or search on metacpan
lib/Win32/PEPM/Build.pm view on Meta::CPAN
#note, this will break if __END__ is in a string
my $pos = index($text, '__END__');
#stop following error caused by no __END__
#Unrecognized character \x12; marked by <-- HERE after <-- HERE near column 1 at
#C:/perl/***.pm line 154.
$text .= $nl.'__END__'.$nl if $pos == -1;
$text = 'MZ' #DOS MAGIC
.';' #make the magic not be a syntax error
.$nl.'#!!!!WARNING do not edit this file!!!!'.$nl
.' ' #space pad to the heredoc
x (0x40 #DOS headers full length
-length('MZ')
-length(';')
-length($nl.'#!!!!WARNING do not edit this file!!!!'.$nl)
-length('<<e_lfanew;'.$nl) #heredoc to escape
-4 #size of DWORD e_lfanew
)
.'<<e_lfanew;'.$nl #heredoc
."\x01\x01\x01\x01" #e_lfanew member, a U32/DWORD offset, will be overwritten by linker
#end of 0x40 area, things below are now supposed executable space of the dos prog
.$nl.'e_lfanew'.$nl.$nl #end quoting of the binary offset
.$text
#note the "Rich Signature" appears here before PE header
#after going through VC linker, the Rich Signature IS NOT uninitialized
#memory leaking from VC linker due to our garbage MZ header with invalid
#DOS executable lengths
;
write_file($file, {binmode => ':raw'}, $text);
}
sub WMHash {
no warnings 'uninitialized';
my $h = shift;
#assymne VERSION_FROM is the master .pm for the module if a module has
#multiple .pm files, the DLL will be placed in the master .pm and the 2
#should be having the same base names that isn't being checked due to
lib/Win32/PEPM/Build.pm view on Meta::CPAN
if($oldpm_to_blib){
$dlib = &$oldpm_to_blib(@_);
} else {
package MY;
my($self) = shift;
$dlib = $self->SUPER::pm_to_blib(@_);
package main;
}
my $pos = index($dlib,'pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM)',0);
die 'bad pm_to_blib match' if $pos == -1;
$pos += length 'pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM)';
substr($dlib, $pos, 0, ' $(INST_DYNAMIC)'); #depend on the DLL built
$pos = index($dlib,' $(NOECHO) $(TOUCH) pm_to_blib',0);
die "bad pm_to_blib match" if $pos == -1;
#file is copied twice, but for simplicity don't remove the 1st copying cmd
#copy the DLL to the .pm, DLL already is a .pm after C linking
#remove auto since there is no need to install the dll since it will be
#inside the .pm #TODO it breaks nmake, nothing is installed then due to dep suddenly disappearing and being build once already
substr($dlib, $pos, 0,
' $(RM_F) $(INST_LIBDIR)$(DFSEP)$(BASEEXT).pm
lib/Win32/PEPM/Build.pm view on Meta::CPAN
if($oldconstants){
$dlib = &$oldconstants(@_);
} else {
package MY;
my($self) = shift;
$dlib = $self->SUPER::constants(@_);
package main;
}
my $pos = index($dlib,'INST_DYNAMIC = $(INST_ARCHAUTODIR)\$(DLBASE).$(DLEXT)',0);
die 'bad constants match' if $pos == -1;
substr($dlib, $pos, length('INST_DYNAMIC = $(INST_ARCHAUTODIR)\$(DLBASE).$(DLEXT)'),
'INST_DYNAMIC = $(DLBASE).$(DLEXT)');
return $dlib;
};
}
}
1;
__END__
( run in 0.805 second using v1.01-cache-2.11-cpan-65fba6d93b7 )