1 package ExtUtils::CBuilder::Platform::Windows::MSVC;
2 $ExtUtils::CBuilder::Platform::Windows::MSVC::VERSION = '0.280225';
7 my ($self, $file) = @_;
11 sub format_compiler_cmd {
12 my ($self, %spec) = @_;
14 foreach my $path ( @{ $spec{includes} || [] },
15 @{ $spec{perlinc} || [] } ) {
19 %spec = $self->write_compiler_script(%spec)
20 if $spec{use_scripts};
22 return [ grep {defined && length} (
23 $spec{cc},'-nologo','-c',
34 sub write_compiler_script {
35 my ($self, %spec) = @_;
37 my $script = File::Spec->catfile( $spec{srcdir},
38 $spec{basename} . '.ccs' );
40 $self->add_to_cleanup($script);
41 print "Generating script '$script'\n" if !$self->{quiet};
43 my $SCRIPT = IO::File->new( ">$script" )
44 or die( "Could not create script '$script': $!" );
46 print $SCRIPT join( "\n",
47 map { ref $_ ? @{$_} : $_ }
50 @spec{ qw(includes cflags optimize defines perlinc) } )
53 push @{$spec{includes}}, '@"' . $script . '"';
58 sub format_linker_cmd {
59 my ($self, %spec) = @_;
60 my $cf = $self->{config};
62 foreach my $path ( @{$spec{libpath}} ) {
63 $path = "-libpath:$path";
66 my $output = $spec{output};
67 my $manifest = $spec{manifest};
69 $spec{def_file} &&= '-def:' . $spec{def_file};
70 $spec{output} &&= '-out:' . $spec{output};
71 $spec{manifest} &&= '-manifest ' . $spec{manifest};
72 $spec{implib} &&= '-implib:' . $spec{implib};
73 $spec{map_file} &&= '-map:' . $spec{map_file};
75 %spec = $self->write_linker_script(%spec)
76 if $spec{use_scripts};
78 my @cmds; # Stores the series of commands needed to build the module.
80 push @cmds, [ grep {defined && length} (
84 @{$spec{other_ldflags}} ,
95 # Embed the manifest file if it exists
97 'if', 'exist', $manifest, 'mt', '-nologo', $spec{manifest}, '-outputresource:' . "$output;2"
103 sub write_linker_script {
104 my ($self, %spec) = @_;
106 my $script = File::Spec->catfile( $spec{srcdir},
107 $spec{basename} . '.lds' );
109 $self->add_to_cleanup($script);
111 print "Generating script '$script'\n" if !$self->{quiet};
113 my $SCRIPT = IO::File->new( ">$script" )
114 or die( "Could not create script '$script': $!" );
116 print $SCRIPT join( "\n",
117 map { ref $_ ? @{$_} : $_ }
120 @spec{ qw(lddlflags libpath other_ldflags
121 startup objects libperl perllibs
122 def_file implib map_file) } )
125 push @{$spec{lddlflags}}, '@"' . $script . '"';