App-mkpkgconfig
view release on metacpan or search on metacpan
script/mkpkgconfig view on Meta::CPAN
$conf->add_variable( version => $opt->modversion );
# add auto generated variables
$conf->add_variables( \%VarsAuto )
if defined $opt->auto;
# override from user
$conf->add_variables( $opt->var );
# add standard keywords
$conf->add_keyword( Name => $opt->name );
$conf->add_keyword( Description => $opt->description );
$conf->add_keyword( Version => '${version}' );
for my $kwd ( qw( Requires Libs Conflicts Cflags ) ) {
my $mth = lc $kwd;
$conf->add_keyword( $kwd => $opt->$mth )
if defined $opt->$mth;
}
# override from user
$conf->add_keywords( $opt->kwd );
#<<< no tidy
my @vars_needed =
# output all variables, used or not
$opt->usevars == ALL_VARS ? $conf->variables
# output only requested + keyword dependencies
: $opt->usevars == REQUESTED_VARS ? ( keys %{ $opt->var } , @{ $opt->auto // [] } )
# only variables actually used by keywords
: $opt->usevars == NEEDED_VARS ? ()
: die( "unknown filter for variables: ", $opt->usevars, "\n" );
#>>>
$conf->write(
$opt->output,
write => ( $opt->usevars == ALL_VARS ? 'all' : 'req' ),
vars => \@vars_needed,
comments => [
"This file was created by $0 ($VERSION) via",
join( ' ', $0, @sARGV ) ] );
}
sub parse_opts {
my %Map_usevars = (
'all' => ALL_VARS,
'requested' => REQUESTED_VARS,
'req' => REQUESTED_VARS,
'needed' => NEEDED_VARS
);
my ( $opt, $usage ) = Getopt::Long::Descriptive::describe_options(
"%o <options>",
[ 'output|o=s', "output [stdout]" ],
[
'usevars|u:s',
"which variables to output",
{
default => { reverse %Map_usevars }->{ +NEEDED_VARS },
callbacks => {
'valid output variables' => sub {
return 1 if defined $Map_usevars{ $_[0] };
die(
"$_[0] isn't one of 'all', 'req', 'requested', or 'used'\n"
);
}
} }
],
[ 'auto:s@', "generate a default set of variables" ],
[
'list-auto',
"output a list of variables generated by the --auto option",
{ shortcircuit => 1 }
],
[],
['Variables:'],
[ 'var|variable=s%', 'define variables', { default => {} } ],
[ 'prefix=s', "'prefix' variable", ],
[ 'package=s', "'package' variable", ],
[
'modversion|modversion=s',
'"version" variable and Version keyword)',
{ required => 1 }
],
[],
['Keywords:'],
[ 'kwd|keyword=s%', 'define keywords', { default => {} } ],
(
map { [
qq(\u$_|\l$_=s),
qq("\u$_" keyword),
{ (
$KeywordOptions{$_}{required}
// 0 ? ( required => 1 ) : ()
),
},
]
}
keys %KeywordOptions
),
[],
['Miscellaneous::'],
[ 'version|v', 'output version and exit', { shortcircuit => 1 } ],
[
'help|h',
'output short help message and exit',
{ shortcircuit => 1 }
],
[
'manual|m',
'output full manual page and exit',
{ shortcircuit => 1 }
( run in 2.676 seconds using v1.01-cache-2.11-cpan-cdf2f3d4e48 )