1package ExtUtils::CBuilder::Platform::Windows::MSVC; 2 3our $VERSION = '0.280238'; # VERSION 4 5use warnings; 6use strict; 7 8sub arg_exec_file { 9 my ($self, $file) = @_; 10 return "/OUT:$file"; 11} 12 13sub format_compiler_cmd { 14 my ($self, %spec) = @_; 15 16 foreach my $path ( @{ $spec{includes} || [] }, 17 @{ $spec{perlinc} || [] } ) { 18 $path = '-I' . $path; 19 } 20 21 %spec = $self->write_compiler_script(%spec) 22 if $spec{use_scripts}; 23 24 return [ grep {defined && length} ( 25 $spec{cc},'-nologo','-c', 26 @{$spec{includes}} , 27 @{$spec{cflags}} , 28 @{$spec{optimize}} , 29 @{$spec{defines}} , 30 @{$spec{perlinc}} , 31 "-Fo$spec{output}" , 32 $spec{source} , 33 ) ]; 34} 35 36sub write_compiler_script { 37 my ($self, %spec) = @_; 38 39 my $script = File::Spec->catfile( $spec{srcdir}, 40 $spec{basename} . '.ccs' ); 41 42 $self->add_to_cleanup($script); 43 print "Generating script '$script'\n" if !$self->{quiet}; 44 45 my $SCRIPT = IO::File->new( ">$script" ) 46 or die( "Could not create script '$script': $!" ); 47 48 print $SCRIPT join( "\n", 49 map { ref $_ ? @{$_} : $_ } 50 grep defined, 51 delete( 52 @spec{ qw(includes cflags optimize defines perlinc) } ) 53 ); 54 55 push @{$spec{includes}}, '@"' . $script . '"'; 56 57 return %spec; 58} 59 60sub format_linker_cmd { 61 my ($self, %spec) = @_; 62 my $cf = $self->{config}; 63 64 foreach my $path ( @{$spec{libpath}} ) { 65 $path = "-libpath:$path"; 66 } 67 68 my $output = $spec{output}; 69 my $manifest = $spec{manifest}; 70 71 $spec{def_file} &&= '-def:' . $spec{def_file}; 72 $spec{output} &&= '-out:' . $spec{output}; 73 $spec{manifest} &&= '-manifest ' . $spec{manifest}; 74 $spec{implib} &&= '-implib:' . $spec{implib}; 75 $spec{map_file} &&= '-map:' . $spec{map_file}; 76 77 %spec = $self->write_linker_script(%spec) 78 if $spec{use_scripts}; 79 80 my @cmds; # Stores the series of commands needed to build the module. 81 82 push @cmds, [ grep {defined && length} ( 83 $spec{ld} , 84 @{$spec{lddlflags}} , 85 @{$spec{libpath}} , 86 @{$spec{other_ldflags}} , 87 @{$spec{startup}} , 88 @{$spec{objects}} , 89 $spec{map_file} , 90 $spec{libperl} , 91 @{$spec{perllibs}} , 92 $spec{def_file} , 93 $spec{implib} , 94 $spec{output} , 95 ) ]; 96 97 # Embed the manifest file if it exists 98 push @cmds, [ 99 'if', 'exist', $manifest, 'mt', '-nologo', $spec{manifest}, '-outputresource:' . "$output;2" 100 ]; 101 102 return @cmds; 103} 104 105sub write_linker_script { 106 my ($self, %spec) = @_; 107 108 my $script = File::Spec->catfile( $spec{srcdir}, 109 $spec{basename} . '.lds' ); 110 111 $self->add_to_cleanup($script); 112 113 print "Generating script '$script'\n" if !$self->{quiet}; 114 115 my $SCRIPT = IO::File->new( ">$script" ) 116 or die( "Could not create script '$script': $!" ); 117 118 print $SCRIPT join( "\n", 119 map { ref $_ ? @{$_} : $_ } 120 grep defined, 121 delete( 122 @spec{ qw(lddlflags libpath other_ldflags 123 startup objects libperl perllibs 124 def_file implib map_file) } ) 125 ); 126 127 push @{$spec{lddlflags}}, '@"' . $script . '"'; 128 129 return %spec; 130} 131 1321; 133 134 135