CBuilder/Platform/os2.pm untested

filter: Statementstmt 0.0% 0 / 47 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 11 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 90 CC 10 SCAR 27.4
CC
10
Cov
0%
_do_link
30.0
extra_link_args_after_prelink
20.0
prelink
12.0
CRAP 15.4
1 package ExtUtils::CBuilder::Platform::os2;
2 $ExtUtils::CBuilder::Platform::os2::VERSION = '0.280224';
3 use warnings;
4 use strict;
5 use ExtUtils::CBuilder::Platform::Unix;
6  
7 use vars qw(@ISA);
8 @ISA = qw(ExtUtils::CBuilder::Platform::Unix);
9  
10 sub need_prelink { 1 }
11  
12 sub prelink {
13 # Generate import libraries (XXXX currently near .DEF; should be near DLL!)
14 my $self = shift;
15 my %args = @_;
16  
17 my @res = $self->SUPER::prelink(%args);
18 die "Unexpected number of DEF files" unless @res == 1;
19 die "Can't find DEF file in the output"
20 unless $res[0] =~ m,^(.*)\.def$,si;
21 my $libname = "$1$self->{config}{lib_ext}"; # Put .LIB file near .DEF file
22 $self->do_system('emximp', '-o', $libname, $res[0]) or die "emxexp: res=$?";
23 return (@res, $libname);
24 }
25  
26 sub _do_link {
27 my $self = shift;
28 my ($how, %args) = @_;
29 if ($how eq 'lib_file'
30 and (defined $args{module_name} and length $args{module_name})) {
31  
32 # Now know the basename, find directory parts via lib_file, or objects
33 my $objs = ( (ref $args{objects}) ? $args{objects} : [$args{objects}] );
34 my $near_obj = $self->lib_file(@$objs);
35 my $exp_dir = ($near_obj =~ m,(.*)[/\\],s ? "$1/" : '' );
36  
37 $args{dl_file} = $1 if $near_obj =~ m,(.*)\.,s; # put ExportList near OBJ
38  
39 # XXX _do_link does not have place to put libraries?
40 push @$objs, $self->perl_inc() . "/libperl$self->{config}{lib_ext}";
41 $args{objects} = $objs;
42 }
43 # Some 'env' do exec(), thus return too early when run from ksh;
44 # To avoid 'env', remove (useless) shrpenv
45 local $self->{config}{shrpenv} = '';
46 return $self->SUPER::_do_link($how, %args);
47 }
48  
49 sub extra_link_args_after_prelink {
50 # Add .DEF file to the link line
51 my ($self, %args) = @_;
52  
53 my @DEF = grep /\.def$/i, @{$args{prelink_res}};
54 die "More than one .def files created by 'prelink' stage" if @DEF > 1;
55 # XXXX No "$how" argument here, so how to test for dynamic link?
56 die "No .def file created by 'prelink' stage"
57 unless @DEF or not @{$args{prelink_res}};
58  
59 my @after_libs = ($OS2::is_aout ? ()
60 : $self->perl_inc() . "/libperl_override$self->{config}{lib_ext}");
61 # , "-L", "-lperl"
62 (@after_libs, @DEF);
63 }
64  
65 sub link_executable {
66 # ldflags is not expecting .exe extension given on command line; remove -Zexe
67 my $self = shift;
68 local $self->{config}{ldflags} = $self->{config}{ldflags};
69 $self->{config}{ldflags} =~ s/(?<!\S)-Zexe(?!\S)//;
70 return $self->SUPER::link_executable(@_);
71 }
72  
73  
74 1;