App-mkpkgconfig

 view release on metacpan or  search on metacpan

lib/App/mkpkgconfig/PkgConfig.pm  view on Meta::CPAN

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

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

=head1 DESCRIPTION

C<PkgConfig> manages keywords and variables for C<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 C<pkg-config> files.  Reading is
success oriented.

=head1 METHODS

=head2 new

  $obj = PkgConfig->new;

Construct an empty object

=head2 new_from

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

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

=head2 variable

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

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

=head2 variables

   @variables = $obj->variables;

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

=head2 keyword

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

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

=head2 keywords

   @keywords = $obj->keywords;

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

=head2 add_variable

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

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

=head2 add_variables

  $obj->add_variables( \%variables );

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

=head2 add_keyword

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

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

=head2 add_keywords

  $obj->add_keywords( \%keywords );

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

=head2 write

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

Output C<pkg-config> metadata.  If C<< $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:

=over

=item comments => I<arrayref>

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

=item write => C<all|req>

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

=item vars => I<arrayref>

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

=back

=head2 resolve_dependencies

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

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

=head2 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.

=head2 order_keywords

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

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

=head1 SUPPORT



( run in 1.108 second using v1.01-cache-2.11-cpan-39bf76dae61 )