| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 1 |  |  | 1 |  | 201098 | use strict; | 
|  | 1 |  |  |  |  | 7 |  | 
|  | 1 |  |  |  |  | 26 |  | 
| 2 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 54 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 |  |  |  |  |  |  | package Alien::Build::Plugin::Build::Premake5; | 
| 5 |  |  |  |  |  |  | # ABSTRACT: Premake5 build plugin for Alien::Build | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | our $VERSION = '0.002'; | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 1 |  |  | 1 |  | 275 | use Alien::Build::Plugin; | 
|  | 1 |  |  |  |  | 1846 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | has os           => sub { undef }; | 
| 12 |  |  |  |  |  |  | has cc           => sub { undef }; | 
| 13 |  |  |  |  |  |  | has dc           => sub { undef }; | 
| 14 |  |  |  |  |  |  | has dotnet       => sub { undef }; | 
| 15 |  |  |  |  |  |  | has fatal        => sub { undef }; | 
| 16 |  |  |  |  |  |  | has file         => sub { undef }; | 
| 17 |  |  |  |  |  |  | has insecure     => sub { undef }; | 
| 18 |  |  |  |  |  |  | has scripts      => sub { undef }; | 
| 19 |  |  |  |  |  |  | has systemscript => sub { undef }; | 
| 20 |  |  |  |  |  |  | has verbose      => sub { undef }; | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | has action => 'gmake'; | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | sub init { | 
| 25 | 2 |  |  | 2 | 1 | 41964 | my ($self, $meta) = @_; | 
| 26 |  |  |  |  |  |  |  | 
| 27 | 2 |  |  |  |  | 15 | $meta->add_requires( 'share', 'Alien::premake5' => '0.001' ); | 
| 28 | 2 |  |  |  |  | 48 | $meta->add_requires( 'configure', | 
| 29 |  |  |  |  |  |  | 'Alien::Build::Plugin::Build::Premake5' => '0.001' | 
| 30 |  |  |  |  |  |  | ); | 
| 31 |  |  |  |  |  |  |  | 
| 32 | 2 |  |  |  |  | 35 | $meta->apply_plugin( 'Build::Make', make_type => 'gmake' ); | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | $meta->interpolator->replace_helper( | 
| 35 |  |  |  |  |  |  | premake5 => sub { | 
| 36 | 2 |  |  | 2 |  | 4111 | require Alien::premake5; | 
| 37 | 2 |  |  |  |  | 3403 | my @cmd = Alien::premake5->exe; | 
| 38 |  |  |  |  |  |  |  | 
| 39 | 2 |  |  |  |  | 4746 | foreach my $key (qw( cc dc dotnet file os scripts systemscript )) { | 
| 40 | 14 |  |  |  |  | 72 | my $val = $self->$key; | 
| 41 | 14 | 100 |  |  |  | 222 | next unless defined $val; | 
| 42 | 6 | 50 | 33 |  |  | 31 | next if $key eq 'os' and $val eq $self->os_string; | 
| 43 | 6 | 50 |  |  |  | 39 | push @cmd, "--$key=$val" if $val; | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  |  | 
| 46 | 2 |  |  |  |  | 8 | foreach my $key (qw( fatal insecure verbose )) { | 
| 47 | 6 | 100 |  |  |  | 51 | push @cmd, "--$key" if defined $self->$key; | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  |  | 
| 50 | 2 |  |  |  |  | 29 | return join ' ', @cmd; | 
| 51 |  |  |  |  |  |  | }, | 
| 52 | 2 |  |  |  |  | 35609 | ); | 
| 53 |  |  |  |  |  |  |  | 
| 54 | 2 |  |  |  |  | 131 | $meta->interpolator->add_helper( | 
| 55 |  |  |  |  |  |  | premake => $meta->interpolator->has_helper('premake5'), | 
| 56 |  |  |  |  |  |  | ); | 
| 57 |  |  |  |  |  |  |  | 
| 58 | 2 |  |  |  |  | 129 | $meta->default_hook( | 
| 59 |  |  |  |  |  |  | build => [ | 
| 60 |  |  |  |  |  |  | '%{premake5} ' . $self->action, | 
| 61 |  |  |  |  |  |  | '%{make}', | 
| 62 |  |  |  |  |  |  | '%{make} install', | 
| 63 |  |  |  |  |  |  | ] | 
| 64 |  |  |  |  |  |  | ); | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | sub os_string { | 
| 69 | 9 |  |  | 9 | 1 | 2977 | my ($self) = shift; | 
| 70 |  |  |  |  |  |  |  | 
| 71 | 9 |  |  |  |  | 20 | my $os = ''; | 
| 72 | 9 |  |  |  |  | 15 | for ($^O) { | 
| 73 | 9 | 100 |  |  |  | 64 | if (/aix/i)     { $os = 'aix' } | 
|  | 1 | 100 |  |  |  | 3 |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 50 |  |  |  |  |  | 
| 74 | 2 |  |  |  |  | 5 | elsif (/bsd/i)     { $os = 'bsd' } | 
| 75 | 1 |  |  |  |  | 3 | elsif (/darwin/i)  { $os = 'macosx' } | 
| 76 | 1 |  |  |  |  | 5 | elsif (/haiku/i)   { $os = 'haiku' } | 
| 77 | 1 |  |  |  |  | 3 | elsif (/hurd/i)    { $os = 'hurd' } | 
| 78 | 1 |  |  |  |  | 2 | elsif (/linux/i)   { $os = 'linux' } | 
| 79 | 1 |  |  |  |  | 3 | elsif (/mswin32/i) { $os = 'windows' } | 
| 80 | 1 |  |  |  |  | 3 | elsif (/solaris/i) { $os = 'solaris' } | 
| 81 |  |  |  |  |  |  | } | 
| 82 |  |  |  |  |  |  |  | 
| 83 | 9 |  |  |  |  | 27 | return $os; | 
| 84 |  |  |  |  |  |  | } | 
| 85 |  |  |  |  |  |  |  | 
| 86 |  |  |  |  |  |  | 1; | 
| 87 |  |  |  |  |  |  |  | 
| 88 |  |  |  |  |  |  | __END__ |