line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# App::hopen::T::Gnu::C::CompileCmd - compile C source using the GNU toolset |
2
|
|
|
|
|
|
|
package App::hopen::T::Gnu::C::CompileCmd; |
3
|
1
|
|
|
1
|
|
7
|
use Data::Hopen; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
57
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; use warnings; |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
5
|
1
|
|
|
1
|
|
5
|
use Data::Hopen::Base; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.000012'; # TRIAL |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1302
|
use parent 'App::hopen::G::Cmd'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
10
|
1
|
|
|
1
|
|
65
|
use Class::Tiny qw(compiler); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
208
|
use App::hopen::BuildSystemGlobals; # For $DestDir. |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
120
|
|
13
|
|
|
|
|
|
|
# TODO make the dirs available to nodes through the context. |
14
|
1
|
|
|
1
|
|
8
|
use App::hopen::Util::BasedPath; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
55
|
|
15
|
|
|
|
|
|
|
#use Config; |
16
|
1
|
|
|
1
|
|
7
|
use Data::Hopen qw(getparameters); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
17
|
|
|
|
|
|
|
#use Data::Hopen::G::GraphBuilder; |
18
|
|
|
|
|
|
|
#use Data::Hopen::Util::Data qw(forward_opts); |
19
|
1
|
|
|
1
|
|
456
|
use Data::Hopen::Util::Filename; |
|
1
|
|
|
|
|
2475
|
|
|
1
|
|
|
|
|
44
|
|
20
|
|
|
|
|
|
|
#use Deep::Hash::Utils qw(deepvalue); |
21
|
|
|
|
|
|
|
#use File::Which (); |
22
|
1
|
|
|
1
|
|
8
|
use Path::Class; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
347
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $_FN = Data::Hopen::Util::Filename->new; # for brevity |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Docs {{{1 |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 NAME |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
App::hopen::T::Gnu::C::CompileCmd - compile C source using the GNU toolset |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 SYNOPSIS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
In a hopen file: |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $cmd = App::hopen::T::Gnu::C::CompileCmd->new( |
37
|
|
|
|
|
|
|
compiler => '/usr/bin/gcc', |
38
|
|
|
|
|
|
|
name => 'compilation command' # optional |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
The inputs come from earlier in the build graph. |
42
|
|
|
|
|
|
|
TODO support specifying compiler arguments. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 compiler |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
The compiler to use. TODO is this a full path or just a name? |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 MEMBER FUNCTIONS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# }}}1 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 _run |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Create the compile command line. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _run { |
63
|
2
|
|
|
2
|
|
654
|
my ($self, %args) = getparameters('self', [qw(phase visitor ; *)], @_); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Currently we only do things at gen time. |
66
|
2
|
50
|
|
|
|
168
|
return $self->passthrough(-nocontext=>1) if $args{phase} ne 'Gen'; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Pull the inputs |
69
|
2
|
|
|
|
|
15
|
my $lrSourceFiles = $self->input_assets; |
70
|
2
|
|
|
0
|
|
15
|
hlog { 'found source files', Dumper($lrSourceFiles) } 2; |
|
0
|
|
|
|
|
0
|
|
71
|
|
|
|
|
|
|
|
72
|
2
|
|
|
|
|
15
|
my @objFiles; |
73
|
2
|
|
|
|
|
6
|
foreach my $src (@$lrSourceFiles) { |
74
|
2
|
50
|
|
|
|
9
|
die "Cannot compile non-file $src" unless $src->isdisk; |
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
8
|
my $to = based_path(path => file($_FN->obj($src->target->path)), |
77
|
|
|
|
|
|
|
base => $DestDir); |
78
|
2
|
|
|
|
|
451
|
my $how = $self->compiler . " -c #first -o #out"; |
79
|
2
|
|
|
|
|
21
|
my $obj = App::hopen::Asset->new( |
80
|
|
|
|
|
|
|
target => $to, |
81
|
|
|
|
|
|
|
made_by => $self, |
82
|
|
|
|
|
|
|
); |
83
|
2
|
|
|
|
|
26
|
push @objFiles, $obj; |
84
|
|
|
|
|
|
|
|
85
|
2
|
|
|
|
|
12
|
$args{visitor}->asset($obj, -how => $how); |
86
|
2
|
|
|
|
|
17
|
$args{visitor}->connect($src, $obj); |
87
|
|
|
|
|
|
|
} |
88
|
2
|
|
|
|
|
6651
|
$self->make(\@objFiles); |
89
|
2
|
|
|
|
|
8
|
return {}; |
90
|
|
|
|
|
|
|
} #_run() |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
__END__ |
94
|
|
|
|
|
|
|
# vi: set fdm=marker: # |