view release on metacpan or search on metacpan
lib/App/hopen.pm view on Meta::CPAN
#GO => ['go'], # TODO implement this --- if specified, run all phases
# and invoke the build tool without requiring the user to
# re-run hopen.
# -h and --help reserved
#INCLUDE => ['i','|include=s@'],
#LIB => ['l','|load=s@'], # TODO implement this. A separate option
# for libs only used for hopen files?
#LANGUAGE => ['L','|language:s'],
# --man reserved
# OUTPUT_FILENAME => ['o','|output=s', ""],
# OPTIMIZE => ['O','|optimize'],
PHASE => ['phase','=s'], # NO DEFAULT so we can tell if --phase was used
QUIET => ['q'],
#SANDBOX => ['S','|sandbox',false],
#SOURCES reserved
TOOLSET => ['t','|T|toolset=s'], # -T is from CMake
DEST_DIR => ['to','=s'],
# --usage reserved
lib/App/hopen/Gen/MSBuild.pm view on Meta::CPAN
use App::hopen::BuildSystemGlobals;
use App::hopen::Phases qw(is_last_phase);
use App::hopen::Util::XML::FromPerl qw(xml_from_perl);
use Data::Hopen qw(:default getparameters *QUIET);
use Data::Hopen::Scope::Hash;
use Data::Hopen::Util::Data qw(forward_opts);
use File::Which;
use Quote::Code;
use App::hopen::Gen::MSBuild::AssetGraphNode; # for $OUTPUT
# Docs {{{1
=head1 NAME
App::hopen::Gen::MSBuild - hopen generator for MSBuild
=head1 SYNOPSIS
This generator makes a C<.proj> file that can be run with MSBuild.
lib/App/hopen/Gen/MSBuild.pm view on Meta::CPAN
=cut
sub finalize {
my ($self, %args) = getparameters('self', [qw(dag; data)], @_);
hlog { Finalizing => __PACKAGE__ , '- phase', $Phase };
return unless is_last_phase $Phase; # Only do work during Gen
hlog { __PACKAGE__, 'Asset graph', '' . $self->_assets->_graph } 3;
my $context = Data::Hopen::Scope::Hash->new;
$context->put($App::hopen::Gen::MSBuild::AssetGraphNode::OUTPUT, undef);
# undef => will be ignored when making the XML
# Generate the XML
my $hrOut = $self->_assets->run(-context => $context);
my $lrXML = $hrOut->{$self->asset_default_goal->name}
->{$App::hopen::Gen::MSBuild::AssetGraphNode::OUTPUT};
die "Empty XML!" unless defined $lrXML && @$lrXML;
# Make the header. NOTE: no '--' allowed within a comment, so s///gr.
my $comment = qc_to <<"EOT";
MSBuild project file generated by hopen
(https://github.com/hopenbuild/App-hopen)
at #{gmtime =~ s/--/-/gr} GMT
From ``#{$self->proj_dir->absolute =~ s/--/-/gr}''
into ``#{$self->dest_dir->absolute =~ s/--/-/gr}''
EOT
lib/App/hopen/Gen/MSBuild/AssetGraphNode.pm view on Meta::CPAN
=head1 SYNOPSIS
TODO
=head1 FUNCTIONS
=cut
# }}}1
use vars::i '*OUTPUT' => eval "\\'__R_MSBuildXML'";
=head2 _run
Add to the XML hashref being built up in C<__R_MSBuildXML>.
If the `how` of a node is defined but falsy, it's a goal.
If `how` is defined and truthy, it's a file.
=cut
sub _run {
my ($self, %args) = getparameters('self', [qw(; phase visitor)], @_);
my $lrXML = $self->scope->find($OUTPUT);
# TODO deal with multiple inputs being merged in DAG::_run()
my @inputs = $self->input_assets;
my $output = $self->asset->target;
$output = $output->path_wrt($DestDir) if eval { $output->DOES('App::hopen::Util::BasedPath') };
# TODO refactor this processing into a utility module/function
# Debugging output
hlog {;
qc'Project piece from node {$self->name}',
lib/App/hopen/Gen/MSBuild/AssetGraphNode.pm view on Meta::CPAN
# TODO refactor this processing into a utility module/function
$recipe =~ s<#first\b><$paths[0] // ''>ge; # first input
$recipe =~ s<#all\b><join(' ', @paths)>ge; # all inputs
$recipe =~ s<#out\b><$output // ''>ge;
$lrXML = [ TODO => { Name => $output },
$lrXML ];
}
$self->make($self->asset);
return {$OUTPUT=>$lrXML};
} #_run()
1;
__END__
# vi: set fdm=marker: #
lib/App/hopen/Gen/Make.pm view on Meta::CPAN
use Class::Tiny;
use App::hopen::BuildSystemGlobals;
use App::hopen::Phases qw(is_last_phase);
use Data::Hopen qw(:default getparameters *QUIET);
use Data::Hopen::Scope::Hash;
use Data::Hopen::Util::Data qw(forward_opts);
use File::Which;
use Quote::Code;
use App::hopen::Gen::Make::AssetGraphNode; # for $OUTPUT
# Docs {{{1
=head1 NAME
App::hopen::Gen::Make - hopen generator for simple Makefiles
=head1 SYNOPSIS
This generator makes a Makefile that does its best to run on cmd.exe or sh(1).
lib/App/hopen/Gen/Make.pm view on Meta::CPAN
# at @{[scalar gmtime]} GMT
# From ``@{[$self->proj_dir->absolute]}'' into ``@{[$self->dest_dir->absolute]}''
.PHONY: first__goal__
EOT
# Make sure the first goal is 'all' regardless of order.
say $fh qc'first__goal__: {$args{dag}->default_goal->name}\n';
my $context = Data::Hopen::Scope::Hash->new;
$context->put(App::hopen::Gen::Make::AssetGraphNode::OUTPUT, $fh);
# Write the Makefile. TODO flip the order.
$self->_assets->run(-context => $context);
close $fh;
} #finalize()
=head2 default_toolset
lib/App/hopen/Gen/Make/AssetGraphNode.pm view on Meta::CPAN
=head1 SYNOPSIS
TODO
=head1 FUNCTIONS
=cut
# }}}1
use vars::i '&OUTPUT' => sub { '__R_Makefile' };
=head2 _run
Generate a piece of a Makefile and write it to the filehandle in
C<__R_Makefile>.
If the `how` of a node is defined but falsy, it's a goal.
If `how` is defined and truthy, it's a file.
=cut
sub _run {
my ($self, %args) = getparameters('self', [qw(; phase visitor)], @_);
my $fh = $self->scope->find(OUTPUT);
# TODO deal with multiple inputs being merged in DAG::_run()
my @inputs = $self->input_assets;
my $output = $self->asset->target;
$output = $output->path_wrt($DestDir) if eval { $output->DOES('App::hopen::Util::BasedPath') };
# TODO refactor this processing into a utility module/function
# Debugging output
if($VERBOSE) {
say $fh qc'\n# Makefile piece from node {$self->name}';
lib/App/hopen/Gen/Ninja.pm view on Meta::CPAN
use App::hopen::BuildSystemGlobals;
use App::hopen::Phases qw(is_last_phase);
use Data::Hopen qw(:default getparameters *QUIET);
use Data::Hopen::Scope::Hash;
use Data::Hopen::Util::Data qw(forward_opts);
use File::Which;
use Path::Class;
use Quote::Code;
use App::hopen::Gen::Ninja::AssetGraphNode; # for $OUTPUT
# Docs {{{1
=head1 NAME
App::hopen::Gen::Ninja - hopen generator for simple Ninja files
=head1 SYNOPSIS
This generator makes a build.ninja file.
lib/App/hopen/Gen/Ninja.pm view on Meta::CPAN
# Ninja file generated by hopen (https://github.com/hopenbuild/App-hopen)
# at #{gmtime} GMT
# From ``#{$self->proj_dir->absolute}'' into ``#{$self->dest_dir->absolute}''
EOT
# # Make sure the first goal is 'all' regardless of order.
# say $fh qc'first__goal__: {$args{dag}->default_goal->name}\n';
my $context = Data::Hopen::Scope::Hash->new;
$context->put(App::hopen::Gen::Ninja::AssetGraphNode::OUTPUT, $fh);
# Write the Ninja file. TODO? flip the order?
$self->_assets->run(-context => $context);
close $fh;
} #finalize()
=head2 default_toolset
lib/App/hopen/Gen/Ninja/AssetGraphNode.pm view on Meta::CPAN
TODO? Store mapping from command lines to rules? Don't want to generate
a separate rule for every command if we can help it.
=head1 FUNCTIONS
=cut
# }}}1
use vars::i '&OUTPUT' => sub { '__R_Ninjafile' };
=head2 _run
Generate a piece of a C<build.ninja> file and write it to the filehandle in
C<__R_Ninjafile>.
If the `how` of a node is defined but falsy, it's a goal.
If `how` is defined and truthy, it's a file.
=cut
sub _run {
state $ruleidx=0;
my ($self, %args) = getparameters('self', [qw(; phase visitor)], @_);
my $fh = $self->scope->find(OUTPUT);
# TODO deal with multiple inputs being merged in DAG::_run()
my @inputs = $self->input_assets;
my $output = $self->asset->target;
$output = $output->path_wrt($DestDir) if eval { $output->DOES('App::hopen::Util::BasedPath') };
# TODO refactor this processing into a utility module/function
# Debugging output
if($VERBOSE) {
print $fh qc'\n# From node {$self->name}:\n';