Alien-wxWidgets
view release on metacpan or search on metacpan
inc/My/Build/Win32.pm view on Meta::CPAN
package My::Build::Win32;
use strict;
use base qw(My::Build::Base);
use My::Build::Utility qw(awx_arch_file awx_install_arch_file
awx_install_arch_dir);
use Config;
use Fatal qw(open close);
use Carp qw(cluck);
use File::Glob qw(bsd_glob);
my $initialized;
sub _init {
return if $initialized;
$initialized = 1;
return if Module::Build->current->notes( 'build_wx' );
# install_only is set when a wxWidgets build is already configured
# with Alien::wxWidgets
return if Module::Build->current->notes( 'install_only' );
# check for WXDIR and WXWIN environment variables
unless( exists $ENV{WXDIR} or exists $ENV{WXWIN} ) {
cluck <<EOT;
**********************************************************************
WARNING!
You need to set the WXDIR or WXWIN variables; refer to
docs/install.txt for a detailed explanation
**********************************************************************
EOT
exit 1;
}
$ENV{WXDIR} = $ENV{WXWIN} unless exists $ENV{WXDIR};
$ENV{WXWIN} = $ENV{WXDIR} unless exists $ENV{WXWIN};
}
sub _patch_command {
my( $self, $base_dir, $patch_file ) = @_;
my $patch_exe = File::Spec->catfile( File::Spec->updir,
qw(inc bin patch.exe) );
my $cmd = qq{perl -pe "" -- "$patch_file"} .
qq{ | "$patch_exe" -N -p0 -u -b -z .bak};
return $cmd;
}
sub awx_grep_dlls {
my( $self, $libdir, $digits, $mono ) = @_;
my $ret = {};
my $ver = $self->_version_2_dec( $self->awx_w32_bakefile_version );
my $suff = ( $self->awx_unicode ? 'u' : '' ) .
( $self->awx_debug && $ver <= 2.009 ? 'd' : '' );
my @dlls = grep { m/${digits}\d*${suff}_/ }
bsd_glob( File::Spec->catfile( $libdir, '*.dll' ) );
my @libs = grep { m/(?:lib)?wx(?:wince|msw|base)[\w\.]+$/ }
grep { m/${digits}\d*${suff}(_|\.)/ }
bsd_glob( File::Spec->catfile( $libdir, "*$Config{lib_ext}" ) );
# we want builtins on Win32 so that they are available for wxWidgets extensions
my @builtins = grep { m/wx(zlib|regex|expat|png|jpeg|tiff)/ }
bsd_glob( File::Spec->catfile( $libdir, "*$Config{lib_ext}" ) );
$self->{w32builtins} = \@builtins;
foreach my $full ( @dlls, @libs ) {
my( $name, $type );
local $_ = File::Basename::basename( $full );
m/^[^_]+_([^_\.]+)/ and $name = $1;
$name = 'base' if !defined $name || $name =~ m/^(gcc|vc|evc)$/;
$type = m/$Config{lib_ext}$/i ? 'lib' : 'dll';
$ret->{$name}{$type} = $full;
}
if( $mono ) {
$ret->{mono} = delete $ret->{base};
}
die "Configuration error: could not find libraries for configuration: "
. join ' ', map "'$_'", $suff, $digits
unless ( exists $ret->{core}{dll} and exists $ret->{core}{lib} )
or ( exists $ret->{mono}{dll} and exists $ret->{mono}{lib} );
return $ret;
}
sub awx_wx_config_data {
my $self = shift;
my $wxdir_b = $ENV{WXDIR};
my $wxdir = $self->notes( 'build_wx' ) ?
awx_install_arch_dir( $self, 'rEpLaCe' ) : $wxdir_b;
return { 'wxdir' => $wxdir,
'wxdir_build' => $wxdir_b,
'wxinc' => File::Spec->catdir( $wxdir_b, 'include' ),
'wxcontrinc' => File::Spec->catdir( $wxdir_b, 'contrib',
'include' ),
};
}
sub awx_configure {
my $self = shift;
my %config = $self->SUPER::awx_configure;
$config{prefix} = $self->wx_config( 'wxdir' );
$config{config}{toolkit} = $self->is_wince ? 'wce' : 'msw';
$config{shared_library_path} = awx_install_arch_file( $self, "rEpLaCe/lib" );
$self->awx_w32_find_setup_dir( $self->wx_config( 'cxxflags' ) );
return %config;
}
sub awx_w32_find_setup_dir {
my( $self, $cxxflags ) = @_;
die "Unable to find setup.h directory"
unless $cxxflags =~ m{[/-]I\s*(\S+lib[\\/][\w\\/]+)(?:\s|$)};
$self->{awx_setup_dir} = $1;
$self->{awx_data}{version} = $self->awx_w32_bakefile_version
if -f $self->awx_w32_build_cfg;
( run in 0.446 second using v1.01-cache-2.11-cpan-e93a5daba3e )