line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# App::hopen::Gen::Make - generator for a generic make(1). |
2
|
|
|
|
|
|
|
package App::hopen::Gen::Make; |
3
|
1
|
|
|
1
|
|
648
|
use strict; use warnings; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
7
|
use Data::Hopen::Base; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
11
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.000013'; # TRIAL |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
1455
|
use parent 'App::hopen::Gen'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
9
|
1
|
|
|
1
|
|
54
|
use Class::Tiny; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
37
|
use App::hopen::BuildSystemGlobals; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
106
|
|
12
|
1
|
|
|
1
|
|
11
|
use App::hopen::Phases qw(is_last_phase); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
78
|
|
13
|
1
|
|
|
1
|
|
7
|
use Data::Hopen qw(:default getparameters *QUIET); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
126
|
|
14
|
1
|
|
|
1
|
|
16
|
use Data::Hopen::Scope::Hash; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
63
|
|
15
|
1
|
|
|
1
|
|
6
|
use Data::Hopen::Util::Data qw(forward_opts); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
52
|
|
16
|
1
|
|
|
1
|
|
441
|
use File::Which; |
|
1
|
|
|
|
|
1042
|
|
|
1
|
|
|
|
|
60
|
|
17
|
1
|
|
|
1
|
|
479
|
use Quote::Code; |
|
1
|
|
|
|
|
800
|
|
|
1
|
|
|
|
|
5
|
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
650
|
use App::hopen::Gen::Make::AssetGraphNode; # for $OUTPUT |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
596
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Docs {{{1 |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
App::hopen::Gen::Make - hopen generator for simple Makefiles |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This generator makes a Makefile that does its best to run on cmd.exe or sh(1). |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 FUNCTIONS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# }}}1 |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 finalize |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Write out the Makefile. Usage: |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$Generator->finalize($dag); # $data parameter unused |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
C<$dag> is the build graph. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub finalize { |
48
|
2
|
|
|
2
|
1
|
13
|
my ($self, %args) = getparameters('self', [qw(dag; data)], @_); |
49
|
2
|
|
|
0
|
|
259
|
hlog { Finalizing => __PACKAGE__ , '- phase', $Phase }; |
|
0
|
|
|
|
|
0
|
|
50
|
2
|
100
|
|
|
|
30
|
return unless is_last_phase $Phase; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
0
|
|
8
|
hlog { __PACKAGE__, 'Asset graph', '' . $self->_assets->_graph } 3; |
|
0
|
|
|
|
|
0
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# During the Gen phase, create the Makefile |
55
|
1
|
50
|
|
|
|
34
|
open my $fh, '>', $self->dest_dir->file('Makefile') or die "Couldn't create Makefile"; |
56
|
1
|
|
|
|
|
285
|
print $fh <<EOT; |
57
|
|
|
|
|
|
|
# Makefile generated by hopen (https://github.com/hopenbuild/App-hopen) |
58
|
1
|
|
|
|
|
18
|
# at @{[scalar gmtime]} GMT |
59
|
1
|
|
|
|
|
28
|
# From ``@{[$self->proj_dir->absolute]}'' into ``@{[$self->dest_dir->absolute]}'' |
|
1
|
|
|
|
|
159
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
.PHONY: first__goal__ |
62
|
|
|
|
|
|
|
EOT |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Make sure the first goal is 'all' regardless of order. |
65
|
1
|
|
|
|
|
160
|
say $fh qc'first__goal__: {$args{dag}->default_goal->name}\n'; |
|
1
|
|
|
|
|
30
|
|
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
|
|
31
|
my $context = Data::Hopen::Scope::Hash->new; |
68
|
1
|
|
|
|
|
32
|
$context->put(App::hopen::Gen::Make::AssetGraphNode::OUTPUT, $fh); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Write the Makefile. TODO flip the order. |
71
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
63
|
$self->_assets->run(-context => $context); |
73
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
3322
|
close $fh; |
75
|
|
|
|
|
|
|
} #finalize() |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 default_toolset |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Returns the package name of the default toolset for this generator, |
80
|
|
|
|
|
|
|
which is C<Gnu> (i.e., L<App::hopen::T::Gnu>). |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
2
|
|
|
2
|
1
|
12
|
sub default_toolset { 'Gnu' } |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 _assetop_class |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
The class of asset-graph operations, which in this case is |
89
|
|
|
|
|
|
|
L<App::hopen::Gen::Make::AssetGraphNode>. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
4
|
|
|
4
|
|
10
|
sub _assetop_class { 'App::hopen::Gen::Make::AssetGraphNode' } |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 _run_build |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Implementation of L<App::hopen::Gen/run_build>. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub _run_build { |
102
|
|
|
|
|
|
|
# Look for the make(1) executable. Listing make before gmake since a |
103
|
|
|
|
|
|
|
# system with both Cygwin and Strawberry Perl installed has cygwin's |
104
|
|
|
|
|
|
|
# make(1) and Strawberry's gmake(1). |
105
|
0
|
|
|
0
|
|
|
foreach my $candidate (qw[make gmake mingw32-make dmake]) { |
106
|
0
|
|
|
|
|
|
my $path = File::Which::which($candidate); |
107
|
0
|
0
|
|
|
|
|
next unless defined $path; |
108
|
0
|
|
|
0
|
|
|
hlog { Running => $path }; |
|
0
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
system $path, (); |
110
|
0
|
|
|
|
|
|
return; |
111
|
|
|
|
|
|
|
} |
112
|
0
|
|
|
|
|
|
warn "Could not find a 'make' program to run"; |
113
|
|
|
|
|
|
|
} #_run_build() |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
__END__ |
117
|
|
|
|
|
|
|
# vi: set fdm=marker: # |