| 1 | # App::hopen::T::Gnu::C::LinkCmd - link object files using the GNU toolset | ||||||||||
| 2 | package App::hopen::T::Gnu::C::LinkCmd; | ||||||||||
| 3 | 1 | ▶ | use Data::Hopen; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Data::Hopen::Base; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | our $VERSION = '0.000013'; # TRIAL | |||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use parent 'App::hopen::G::Cmd'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Class::Tiny qw(dest linker); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 1 | ▶ | use App::hopen::BuildSystemGlobals; # For $DestDir. | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | # TODO make the dirs available to nodes through the context. | ||||||||||
| 14 | 1 | ▶ | use App::hopen::Util::BasedPath; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 1 | ▶ | use Data::Hopen qw(getparameters); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 1 | ▶ | use Data::Hopen::Util::Filename; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 1 | ▶ | use Path::Class; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | |||||||||||
| 19 | # Docs {{{1 | ||||||||||
| 20 | |||||||||||
| 21 | =head1 NAME | ||||||||||
| 22 | |||||||||||
| 23 | App::hopen::T::Gnu::C::LinkCmd - link object files using the GNU toolset | ||||||||||
| 24 | |||||||||||
| 25 | =head1 SYNOPSIS | ||||||||||
| 26 | |||||||||||
| 27 | In a hopen file: | ||||||||||
| 28 | |||||||||||
| 29 | my $cmd = App::hopen::T::Gnu::C::LinkCmd->new( | ||||||||||
| 30 | linker => 'gcc', | ||||||||||
| 31 | dest => 'foo.exe', | ||||||||||
| 32 | name => 'some linker node', # optional | ||||||||||
| 33 | ); | ||||||||||
| 34 | |||||||||||
| 35 | The inputs come from earlier in the build graph. | ||||||||||
| 36 | TODO support specifying linker arguments. | ||||||||||
| 37 | |||||||||||
| 38 | =head1 ATTRIBUTES | ||||||||||
| 39 | |||||||||||
| 40 | =head2 linker | ||||||||||
| 41 | |||||||||||
| 42 | The linker to use. TODO is this a full path or just a name? | ||||||||||
| 43 | |||||||||||
| 44 | =head2 dest | ||||||||||
| 45 | |||||||||||
| 46 | The destination file to produce, as an L<App::hopen::Util::BasedPath> instance. | ||||||||||
| 47 | TODO? accept string or L<Path::Class::File> instance? | ||||||||||
| 48 | |||||||||||
| 49 | =head1 MEMBER FUNCTIONS | ||||||||||
| 50 | |||||||||||
| 51 | =cut | ||||||||||
| 52 | |||||||||||
| 53 | # }}}1 | ||||||||||
| 54 | |||||||||||
| 55 | =head2 _run | ||||||||||
| 56 | |||||||||||
| 57 | Create the link command line. | ||||||||||
| 58 | |||||||||||
| 59 | =cut | ||||||||||
| 60 | |||||||||||
| 61 | sub _run { | ||||||||||
| 62 | 3 | ▶ | my ($self, %args) = getparameters('self', [qw(visitor ; *)], @_); | ||||||||
|
Subroutine
_run: called CC=4 SCAR=14.1
| |||||||||||
| 63 | |||||||||||
| 64 | # Currently we only do things at gen time. | ||||||||||
| 65 | 3 | ▶ | return $self->passthrough(-nocontext=>1) if $Phase ne 'Gen'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | |||||||||||
| 67 | # Pull the inputs | ||||||||||
| 68 | 3 | my $lrObjFiles = $self->input_assets; | |||||||||
| 69 | 3 | ▶ | hlog { 'found object files', Dumper($lrObjFiles) } 2; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 70 | |||||||||||
| 71 | 3 | my $exe = App::hopen::Asset->new( | |||||||||
| 72 | target => $self->dest, | ||||||||||
| 73 | made_by => $self, | ||||||||||
| 74 | ); | ||||||||||
| 75 | 3 | $args{visitor}->asset($exe, | |||||||||
| 76 | -how => $self->linker . ' -o #out #all', | ||||||||||
| 77 | ); | ||||||||||
| 78 | |||||||||||
| 79 | 3 | foreach my $obj (@$lrObjFiles) { | |||||||||
| 80 | 3 | ▶ | die "Cannot link non-file $obj" unless $obj->isdisk; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | 3 | $args{visitor}->connect($obj, $exe); | |||||||||
| 82 | } | ||||||||||
| 83 | |||||||||||
| 84 | 3 | $self->make($exe); | |||||||||
| 85 | 3 | return {}; | |||||||||
| 86 | } #_run() | ||||||||||
| 87 | |||||||||||
| 88 | 1 | 1; | |||||||||
| 89 | __END__ | ||||||||||
| 90 | # vi: set fdm=marker: # | ||||||||||