NAME

App::mkpkgconfig::PkgConfig - output pkg-config .pc files

VERSION

version v2.0.1

SYNOPSIS

# create an empty object
$pkg = PkgConfig->new;

# Construct an object from an existing .pc file
$obj = PkgConfig->new_from( $file );

# or from a string containing similar content
$obj = PkgConfig->new_from( \$string );

# add a keyword
$obj->add_keyword( $name, $value );

# add a variable
$obj->add_variable( $name $value );

# resolve_dependencies for one or more keywords or variables:

@var_names = $obj->resolve_depdencies( $obj->keyword('Version') );

# write out a .pc file
$obj->write( $file );

DESCRIPTION

PkgConfig manages keywords and variables for pkg-config metadata about a project. It automatically scans values for variable dependencies and can determine if there are dependency loops or missing dependencies. It can generate a list of variables in the correct order to resolve dependencies.

On top of this, it can read and write pkg-config files. Reading is success oriented.

METHODS

new

$obj = PkgConfig->new;

Construct an empty object

new_from

$obj = PkgConfig->new_from( $file );
$obj = PkgConfig->new_from( \$string );

Construct an object from an existing pkg-config file or from a string containing similar content.

variable

$variable = $obj->variable( $name) ;

Return a App::mkpkgconfig::PkgConfig::Entry::Variable object for the requested variable.

variables

@variables = $obj->variables;

Return a list of App::mkpkgconfig::PkgConfig::Entry::Variable objects;

keyword

$keyword = $obj->keyword( $name );

Return a App::mkpkgconfig::PkgConfig::Entry::Keyword object for the requested keyword.

keywords

@keywords = $obj->keywords;

Return a list of App::mkpkgconfig::PkgConfig::Entry::Keywords objects;

add_variable

$obj->add_variable( $name, $value );

Add a variable with the specified value. If the variable exists, its value will be updated.

add_variables

$obj->add_variables( \%variables );

Add multiple variables, with names and values specified by the passed hash.

add_keyword

$obj->add_keyword( $name, $value );

Add a keyword with the specified value. If the keyword exists, its value will be updated.

add_keywords

$obj->add_keywords( \%keywords );

Add multiple keywords, with names and values specified by the passed hash.

write

$obj->write( $file, %options );

Output pkg-config metadata. If $file is undefined, the output will be written to the standard output stream, otherwise to the specified file. By default all of the keywords and variables will be output.

The available options are:

comments => arrayref

Write the comments at the top of the file, one per line.

write => all|req

Which variables to output. If all (the default), all are written. If req, write the variables required by the keywords as well as those specified by the vars option.

vars => arrayref

If the write option is req, write the specified variables in addition to those required by the keywords.

resolve_dependencies

@var_names = $obj->resolve_depdencies( @entries );

Returns the names of the variables needed to resolve all dependencies in the passed list of "App::mkpkgconfig::PkgConfig::Entry::Variable" and "App::mkpkgconfig::PkgConfig::Entry::Keyword" objects.

order_variables

@ordered_variable_names = $obj->order_variables( @variable_names );

Return a list of variables names in the order that they should be evaluated to ensure that dependencies are correctly resolved.

order_keywords

@ordered_keywords = $obj->order_keywords( @keyword_names );

Return a list of keywords ordered so that the Name, Description, and Version keywords are at the beginning of the list.

SUPPORT

Bugs

Please report any bugs or feature requests to bug-app-mkpkgconfig@rt.cpan.org or through the web interface at: https://rt.cpan.org/Public/Dist/Display.html?Name=App-mkpkgconfig

Source

Source is available at

https://gitlab.com/djerius/app-mkpkgconfig

and may be cloned from

https://gitlab.com/djerius/app-mkpkgconfig.git

SEE ALSO

Please see those modules/websites for more information related to this module.

AUTHOR

Diab Jerius <djerius@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2020 by Smithsonian Astrophysical Observatory.

This is free software, licensed under:

The GNU General Public License, Version 3, June 2007