| 1 | package Test::Smoke::App::W32Configure; | ||
| 2 | use warnings; | ||
| 3 | use strict; | ||
| 4 | |||
| 5 | our $VERSION = '0.002'; | ||
| 6 | |||
| 7 | use base 'Test::Smoke::App::Base'; | ||
| 8 | |||
| 9 | use Cwd; | ||
| 10 | use System::Info::Windows; | ||
| 11 | use Test::Smoke::Util qw/Configure_win32/; | ||
| 12 | |||
| 13 | =head1 NAME | ||
| 14 | |||
| 15 | Test::Smoke::App::W32Configure - Create F<< $ddir\win32\smoke.mk >> | ||
| 16 | |||
| 17 | =head1 SYNOPSIS | ||
| 18 | |||
| 19 | See also L<bin/tsw32configure.pl>: | ||
| 20 | |||
| 21 | bin/tsw32configure.pl -c smokecurrent -Duseithreads | ||
| 22 | |||
| 23 | =head1 DESCRIPTION | ||
| 24 | |||
| 25 | This calls L<Test::Smoke::Util/"Configure_win32"> | ||
| 26 | |||
| 27 | =head2 new | ||
| 28 | |||
| 29 | Instantiate the applet. | ||
| 30 | |||
| 31 | =cut | ||
| 32 | |||
| 33 | sub new { | ||
| 34 | my $class = shift; | ||
| 35 | my $self = $class->SUPER::new(@_); | ||
| 36 | |||
| 37 | $self->{_verbose} = $self->option('verbose'); | ||
| 38 | return $self; | ||
| 39 | } | ||
| 40 | |||
| 41 | =head2 $app->run(); | ||
| 42 | |||
| 43 | run the applet. | ||
| 44 | |||
| 45 | =cut | ||
| 46 | |||
| 47 | sub run { | ||
| 48 | my $self = shift; | ||
| 49 | |||
| 50 | my $w32override; | ||
| 51 | my @configure_args = map { | ||
| 52 | $w32override = !$w32override && /^--w32override$/; | ||
| 53 | $w32override ? () : $_; | ||
| 54 | } @{$self->ARGV_EXTRA}; | ||
| 55 | |||
| 56 | die "This ($^O) is not MSWin32, use Configure.\n" | ||
| 57 | unless $^O eq 'MSWin32' or $w32override; | ||
| 58 | |||
| 59 | push @configure_args, "-DCCTYPE=" . $self->option('w32cc') | ||
| 60 | unless grep { /^-DCCTYPE/ } @configure_args; | ||
| 61 | my $c_args = join(" ", @configure_args); | ||
| 62 | |||
| 63 | my @cfg_vars = @{ $self->option('w32args') }; | ||
| 64 | @cfg_vars = @cfg_vars > 4 | ||
| 65 | ? splice(@cfg_vars, 4) | ||
| 66 | : ( 'osvers=' . _Win_version() ); | ||
| 67 | |||
| 68 | |||
| 69 | my $cwd = getcwd(); | ||
| 70 | chdir($self->option('ddir')) or | ||
| 71 | die sprintf("Cannot chdir(%s): %s", $self->option('ddir'), $!); | ||
| 72 | |||
| 73 | $self->log_info("./Configure [$c_args] %s '@cfg_vars'", $self->option('w32make')); | ||
| 74 | Configure_win32( "./Configure $c_args", $self->option('w32make'), @cfg_vars ); | ||
| 75 | |||
| 76 | chdir($cwd); | ||
| 77 | }; | ||
| 78 | |||
| 79 | sub _Win_version { | ||
| 80 | my $si = System::Info::Windows->new(); | ||
| 81 | (my $win_version = $si->os) =~ s/^[^-]*- //; | ||
| 82 | return $win_version; | ||
| 83 | } | ||
| 84 | |||
| 85 | 1; | ||
| 86 | |||
| 87 | =head1 COPYRIGHT | ||
| 88 | |||
| 89 | (c) 2020, Abe Timmerman <abeltje@cpan.org> All rights reserved. | ||
| 90 | |||
| 91 | This library is free software; you can redistribute it and/or modify | ||
| 92 | it under the same terms as Perl itself. | ||
| 93 | |||
| 94 | See: | ||
| 95 | |||
| 96 | =over 4 | ||
| 97 | |||
| 98 | =item * L<http://www.perl.com/perl/misc/Artistic.html> | ||
| 99 | |||
| 100 | =item * L<http://www.gnu.org/copyleft/gpl.html> | ||
| 101 | |||
| 102 | =back | ||
| 103 | |||
| 104 | This program is distributed in the hope that it will be useful, | ||
| 105 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 106 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 107 | |||
| 108 | =cut |