| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# App::hopen::Gen::MSBuild - generator for msbuild |
|
2
|
|
|
|
|
|
|
package App::hopen::Gen::MSBuild; |
|
3
|
1
|
|
|
1
|
|
773
|
use strict; use warnings; |
|
|
1
|
|
|
1
|
|
2
|
|
|
|
1
|
|
|
|
|
48
|
|
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
33
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use Data::Hopen::Base; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
5
|
1
|
|
|
1
|
|
2233
|
use Syntax::Construct qw(/r); |
|
|
1
|
|
|
|
|
2072
|
|
|
|
1
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.000013'; # TRIAL |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
93
|
use parent 'App::hopen::Gen'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
10
|
1
|
|
|
1
|
|
74
|
use Class::Tiny; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
11
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
41
|
use App::hopen::BuildSystemGlobals; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
131
|
|
|
13
|
1
|
|
|
1
|
|
8
|
use App::hopen::Phases qw(is_last_phase); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
59
|
|
|
14
|
1
|
|
|
1
|
|
557
|
use App::hopen::Util::XML::FromPerl qw(xml_from_perl); |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
86
|
|
|
15
|
1
|
|
|
1
|
|
7
|
use Data::Hopen qw(:default getparameters *QUIET); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
148
|
|
|
16
|
1
|
|
|
1
|
|
10
|
use Data::Hopen::Scope::Hash; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
47
|
|
|
17
|
1
|
|
|
1
|
|
9
|
use Data::Hopen::Util::Data qw(forward_opts); |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
53
|
|
|
18
|
1
|
|
|
1
|
|
6
|
use File::Which; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
43
|
|
|
19
|
1
|
|
|
1
|
|
7
|
use Quote::Code; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
15
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
1
|
|
715
|
use App::hopen::Gen::MSBuild::AssetGraphNode; # for $OUTPUT |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
751
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Docs {{{1 |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
App::hopen::Gen::MSBuild - hopen generator for MSBuild |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
This generator makes a C<.proj> file that can be run with MSBuild. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# }}}1 |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 finalize |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Write out the project file (for now, always called C<build.proj>). Usage: |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$Generator->finalize($dag); # $data parameter unused |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
C<$dag> is the build graph. |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub finalize { |
|
50
|
2
|
|
|
2
|
1
|
12
|
my ($self, %args) = getparameters('self', [qw(dag; data)], @_); |
|
51
|
2
|
|
|
0
|
|
241
|
hlog { Finalizing => __PACKAGE__ , '- phase', $Phase }; |
|
|
0
|
|
|
|
|
0
|
|
|
52
|
2
|
100
|
|
|
|
20
|
return unless is_last_phase $Phase; # Only do work during Gen |
|
53
|
|
|
|
|
|
|
|
|
54
|
1
|
|
|
0
|
|
7
|
hlog { __PACKAGE__, 'Asset graph', '' . $self->_assets->_graph } 3; |
|
|
0
|
|
|
|
|
0
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
11
|
my $context = Data::Hopen::Scope::Hash->new; |
|
57
|
1
|
|
|
|
|
24
|
$context->put($App::hopen::Gen::MSBuild::AssetGraphNode::OUTPUT, undef); |
|
58
|
|
|
|
|
|
|
# undef => will be ignored when making the XML |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Generate the XML |
|
61
|
1
|
|
|
|
|
62
|
my $hrOut = $self->_assets->run(-context => $context); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $lrXML = $hrOut->{$self->asset_default_goal->name} |
|
64
|
1
|
|
|
|
|
3508
|
->{$App::hopen::Gen::MSBuild::AssetGraphNode::OUTPUT}; |
|
65
|
1
|
50
|
33
|
|
|
36
|
die "Empty XML!" unless defined $lrXML && @$lrXML; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# Make the header. NOTE: no '--' allowed within a comment, so s///gr. |
|
68
|
|
|
|
|
|
|
my $comment = qc_to <<"EOT"; |
|
69
|
|
|
|
|
|
|
MSBuild project file generated by hopen |
|
70
|
1
|
|
|
|
|
14
|
(https://github.com/hopenbuild/App-hopen) |
|
71
|
1
|
|
|
|
|
21
|
at #{gmtime =~ s/--/-/gr} GMT |
|
72
|
1
|
|
|
|
|
3
|
From ``#{$self->proj_dir->absolute =~ s/--/-/gr}'' |
|
|
1
|
|
|
|
|
184
|
|
|
73
|
|
|
|
|
|
|
into ``#{$self->dest_dir->absolute =~ s/--/-/gr}'' |
|
74
|
|
|
|
|
|
|
EOT |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Create the MSBuild file |
|
77
|
1
|
|
|
|
|
144
|
my $doc = xml_from_perl( |
|
78
|
|
|
|
|
|
|
['Project', |
|
79
|
|
|
|
|
|
|
{ xmlns => 'http://schemas.microsoft.com/developer/msbuild/2003', |
|
80
|
|
|
|
|
|
|
id => '__R_ROOT', |
|
81
|
|
|
|
|
|
|
}, |
|
82
|
|
|
|
|
|
|
[ '!--', $comment ], |
|
83
|
|
|
|
|
|
|
$lrXML # TODO @$lrXML? |
|
84
|
|
|
|
|
|
|
]); |
|
85
|
1
|
|
|
|
|
54
|
$doc->setEncoding('utf-8'); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# Write the file |
|
88
|
1
|
50
|
|
|
|
27
|
if($doc->toFile( $self->dest_dir->file('build.proj') ) == -1) { |
|
89
|
0
|
|
|
|
|
0
|
die "Couldn't create build.proj"; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} #finalize() |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 default_toolset |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns the package name of the default toolset for this generator, |
|
97
|
|
|
|
|
|
|
which is C<Gnu> (i.e., L<App::hopen::T::Gnu>). |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
|
100
|
|
|
|
|
|
|
|
|
101
|
2
|
|
|
2
|
1
|
9
|
sub default_toolset { 'Gnu' } # TODO |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 _assetop_class |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
The class of asset-graph operations, which in this case is |
|
106
|
|
|
|
|
|
|
L<App::hopen::Gen::MSBuild::AssetGraphNode>. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
|
109
|
|
|
|
|
|
|
|
|
110
|
4
|
|
|
4
|
|
10
|
sub _assetop_class { 'App::hopen::Gen::MSBuild::AssetGraphNode' } |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 _run_build |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Implementation of L<App::hopen::Gen/run_build>. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub _run_build { |
|
119
|
|
|
|
|
|
|
# Look for the make(1) executable. Listing make before gmake since a |
|
120
|
|
|
|
|
|
|
# system with both Cygwin and Strawberry Perl installed has cygwin's |
|
121
|
|
|
|
|
|
|
# make(1) and Strawberry's gmake(1). |
|
122
|
0
|
|
|
0
|
|
|
foreach my $candidate (qw[make gmake mingw32-make dmake]) { |
|
123
|
0
|
|
|
|
|
|
my $path = File::Which::which($candidate); |
|
124
|
0
|
0
|
|
|
|
|
next unless defined $path; |
|
125
|
0
|
|
|
0
|
|
|
hlog { Running => $path }; |
|
|
0
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
system $path, (); |
|
127
|
0
|
|
|
|
|
|
return; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
0
|
|
|
|
|
|
warn "Could not find a 'make' program to run"; |
|
130
|
|
|
|
|
|
|
} #_run_build() |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |
|
133
|
|
|
|
|
|
|
__END__ |
|
134
|
|
|
|
|
|
|
# vi: set fdm=marker: # |