| 1 | package Test::Smoke::App::ConfigSmoke::MSWin32; | ||
| 2 | use warnings; | ||
| 3 | use strict; | ||
| 4 | |||
| 5 | our $VERSION = '0.001'; | ||
| 6 | |||
| 7 | use Exporter 'import'; | ||
| 8 | our @EXPORT = qw/ config_mswin32 /; | ||
| 9 | |||
| 10 | use Test::Smoke::App::Options; | ||
| 11 | use Test::Smoke::Util::FindHelpers qw/ get_avail_w32compilers /; | ||
| 12 | use System::Info::Windows; | ||
| 13 | |||
| 14 | =head1 NAME | ||
| 15 | |||
| 16 | Test::Smoke::App::ConfigSmoke::MSWin32 - Mixin for L<Test::Smoke::App::ConfigSmoke> | ||
| 17 | |||
| 18 | =head1 DESCRIPTION | ||
| 19 | |||
| 20 | These methods will be added to the L<Test::Smoke::App::ConfigSmoke> class. | ||
| 21 | |||
| 22 | =head2 config_mswin32 | ||
| 23 | |||
| 24 | =cut | ||
| 25 | |||
| 26 | sub config_mswin32 { | ||
| 27 | my $self = shift; | ||
| 28 | |||
| 29 | print "\n-- MSWin32 section --\n"; | ||
| 30 | |||
| 31 | my $osvers = get_Win_version(); | ||
| 32 | my %compilers = get_avail_w32compilers(); | ||
| 33 | |||
| 34 | my $w32cc = uc( $self->handle_option(w32cc_option(\%compilers, $osvers)) ); | ||
| 35 | my $w32make = $self->handle_option(w32make_option($w32cc, $compilers{$w32cc})); | ||
| 36 | |||
| 37 | $self->current_values->{w32args} = [ | ||
| 38 | "--win32-cctype" => $w32cc, | ||
| 39 | "--win32-maker" => $w32make, | ||
| 40 | "osvers=$osvers", | ||
| 41 | $compilers{$w32cc}->{ccversarg}, | ||
| 42 | ]; | ||
| 43 | } | ||
| 44 | |||
| 45 | =head2 get_Win_version() | ||
| 46 | |||
| 47 | Use L<System::Info::Windows> to get the version from a windows system. | ||
| 48 | |||
| 49 | =cut | ||
| 50 | |||
| 51 | sub get_Win_version { | ||
| 52 | my $si = System::Info::Windows->new(); | ||
| 53 | (my $win_version = $si->os) =~ s/^[^-]*- //; | ||
| 54 | return $win_version; | ||
| 55 | } | ||
| 56 | |||
| 57 | =head2 w32cc_option | ||
| 58 | |||
| 59 | Dynamic option for configuring the Compiler on Windows. | ||
| 60 | |||
| 61 | =cut | ||
| 62 | |||
| 63 | sub w32cc_option { | ||
| 64 | my ($compilers, $osvers) = @_; | ||
| 65 | my $compiler_info = join( | ||
| 66 | "\n", | ||
| 67 | map { | ||
| 68 | sprintf(" %-4s - %s", $_, $compilers->{$_}{ccbin}) | ||
| 69 | } keys %$compilers | ||
| 70 | ); | ||
| 71 | return Test::Smoke::App::AppOption->new( | ||
| 72 | name => 'w32cc', | ||
| 73 | helptext => "Which compiler should be used for $osvers?", | ||
| 74 | configtext => $compiler_info, | ||
| 75 | configdft => sub { ( sort keys %$compilers )[-1] }, | ||
| 76 | configalt => sub { [ sort keys %$compilers ] }, | ||
| 77 | ); | ||
| 78 | } | ||
| 79 | |||
| 80 | =head2 w32make_option | ||
| 81 | |||
| 82 | Dynamic option for configuring the make program on Windows. | ||
| 83 | |||
| 84 | =cut | ||
| 85 | |||
| 86 | sub w32make_option { | ||
| 87 | my ($w32cc, $this_compiler) = @_; | ||
| 88 | return Test::Smoke::App::AppOption->new( | ||
| 89 | name => 'w32make', | ||
| 90 | helptext => "Which 'make' should be used for $w32cc?", | ||
| 91 | configtext => join(", ", @{$this_compiler->{maker}}), | ||
| 92 | configdft => sub { ( sort @{$this_compiler->{maker}} )[-1] }, | ||
| 93 | configalt => sub { [ sort @{$this_compiler->{maker}} ] }, | ||
| 94 | ); | ||
| 95 | } | ||
| 96 | |||
| 97 | 1; | ||
| 98 | |||
| 99 | =head1 COPYRIGHT | ||
| 100 | |||
| 101 | E<copy> 2022, All rights reserved. | ||
| 102 | |||
| 103 | * Abe Timmerman <abeltje@cpan.org> | ||
| 104 | |||
| 105 | This library is free software; you can redistribute it and/or modify | ||
| 106 | it under the same terms as Perl itself. | ||
| 107 | |||
| 108 | See: | ||
| 109 | |||
| 110 | =over 4 | ||
| 111 | |||
| 112 | =item * L<http://www.perl.com/perl/misc/Artistic.html> | ||
| 113 | |||
| 114 | =item * L<http://www.gnu.org/copyleft/gpl.html> | ||
| 115 | |||
| 116 | =back | ||
| 117 | |||
| 118 | This program is distributed in the hope that it will be useful, | ||
| 119 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 120 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 121 | |||
| 122 | =cut |