1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
package My::Build::Win32_MSVC_Bakefile;
use strict;
use base qw(My::Build::Win32_MSVC My::Build::Win32_Bakefile);
use My::Build::Utility qw(awx_install_arch_file awx_install_arch_auto_file);
use Alien::wxWidgets::Utility qw(awx_capture);
use Config;
use Fatal qw(chdir);
use Cwd ();
sub _check_nmake {
my $out = awx_capture( 'nmake /?' );
unless( $out =~ m{/U\s}i ) {
die "Please use an NMAKE version supporting '-u', not the" .
" freely-available one\n";
}
}
sub awx_wx_config_data {
my $self = shift;
My::Build::Win32::_init();
$self->_check_nmake();
return $self->{awx_data} if $self->{awx_data};
my %data = ( %{$self->SUPER::awx_wx_config_data},
'cxx' => 'cl',
'ld' => 'link',
);
my $make = File::Basename::basename( lc $Config{make}, '.exe' );
die "PANIC: you are not using nmake!" unless $make eq 'nmake';
my $orig_libdir;
my $final = $self->awx_debug ? 'BUILD=debug DEBUG_RUNTIME_LIBS=0'
: 'BUILD=release DEBUG_RUNTIME_LIBS=0';
my $unicode = $self->awx_unicode ? 'UNICODE=1' : 'UNICODE=0';
$unicode .= ' MSLU=1' if $self->awx_mslu;
my $dir = Cwd::cwd;
chdir File::Spec->catdir( $ENV{WXDIR}, 'samples', 'minimal' );
my @t = qx(nmake /nologo /n /u /f makefile.vc $final $unicode SHARED=1);
my( $accu, $libdir, $digits );
foreach ( @t ) {
chomp;
m/^\s*echo\s+(.*)>\s*\S+\s*$/ and $accu .= ' ' . $1 and next;
s/\@\S+\s*$/$accu/ and undef $accu;
if( s/^\s*link\s+// ) {
m/\swxmsw(\d+)\S+\.lib/ and $digits = $1;
s/\s+\S+\.(exe|res|obj)/ /g;
s{[-/]LIBPATH:(\S+)}
{$orig_libdir = File::Spec->canonpath
( File::Spec->rel2abs( $1 ) );
'-L' . ( $libdir = awx_install_arch_file( $self, 'rEpLaCe/lib' ) )}egi;
$data{libs} = $_;
} elsif( s/^\s*cl\s+// ) {
s/\s+\S+\.(cpp|pdb|obj)/ /g;
s{[-/]I(\S+)}{'-I' . File::Spec->canonpath
( File::Spec->rel2abs( $1 ) )}egi;
s{[-/]I(\S+)[\\/]samples[\\/]minimal(\s|$)}{-I$1\\contrib\\include }i;
s{[-/]I(\S+)[\\/]samples(\s|$)}{ }i;
s{[-/]D(\S+)}{-D$1}g;
$data{cxxflags} = $_;
}
}
chdir $dir;
die 'Could not find wxWidgets lib directory' unless $libdir;
$data{dlls} = $self->awx_grep_dlls( $orig_libdir, $digits, $self->awx_is_monolithic );
$data{version} = $digits;
$self->{awx_data} = \%data;
}
sub _make_command { "nmake -f makefile.vc all " }
sub build_wxwidgets {
my( $self ) = shift;
my $old_dir = Cwd::cwd();
$self->My::Build::Win32_Bakefile::build_wxwidgets( @_ );
# Compiling with MSVC 9 (VS 2008) and probably with VS 2005, the
# linker creates a manifest that must be embedded in the DLL to
# make it load correctly
chdir File::Spec->catdir( $ENV{WXDIR} );
foreach my $dll ( glob( 'lib/vc_dll*/*.dll' ) ) {
next unless -f "${dll}.manifest";
$self->_system( 'mt', '-nologo', '-manifest', "${dll}.manifest",
"-outputresource:${dll};2" );
unlink "${dll}.manifest";
}
chdir $old_dir;
}
1;
|