NAME

Alien::Xrepo::PackageInfo - The resolved metadata for one xrepo package

SYNOPSIS

my $info = $repo->install('libpng', '1.6.x');

$info->version;                 # 1.6.45
$info->libpath;                 # /store/libpng/1.6.45/lib/libpng16.so
$info->includedirs;             # [ '/store/libpng/1.6.45/include' ]
$info->linkdirs;                # [ '/store/libpng/1.6.45/lib' ]
$info->links;                   # [ 'png16' ]
$info->kind;                    # 'library'

my $header = $info->find_header('png.h');

# a tool package resolves the same way, but answers with binaries
my $ninja = $repo->install('ninja');
my ($bin) = $ninja->bin_dir;    # .../ninja/bin

DESCRIPTION

Alien::Xrepo::PackageInfo is the value object Alien::Xrepo builds from a successful xrepo install or fetch, and that Alien::Xrepo::Runtime re-exposes to consumers. One instance describes exactly one package: where its headers and libraries landed, what to link against, how it was built, and which other shared libraries a dynamic loader must be able to find before it is usable.

The engine constructs it; consumers only read it. Most fields come straight from xrepo's own output, but a few heuristics fill the gaps xrepo leaves:

  • installdir is derived from the first library or include path when xrepo reports no artifacts root.

  • bindirs falls back to <installdir>/bin for a package that ships executables.

  • libfiles is recovered by scanning the install tree when a package plainly holds libraries but reported none, so it is not mistaken for a header-only package.

  • kind is inferred (binary for a package with an install root but neither libraries nor headers, library otherwise) when xrepo reports no kind.

Instances are immutable in practice. with_runtime_deps returns a new object rather than mutating one, so a caller can attach a diagnostic without disturbing a cached or snapshotted value.

CONSTRUCTOR

my $info = Alien::Xrepo::PackageInfo->new(
    includedirs  => [ ... ],      # required
    libfiles     => [ ... ],      # required
    license      => 'zlib',       # required
    linkdirs     => [ ... ],      # required
    links        => [ ... ],      # required
    shared       => 1,            # required
    static       => 0,            # required
    version      => '1.6.45',     # required
    installdir   => '...',        # required
    libpath      => '...',        # defaults to undef
    bindirs      => [ ... ],      # defaults to []
    deps         => [ ... ],      # defaults to []
    runtime_deps => [ ... ],      # defaults to []
    kind         => 'library'     # defaults to undef
);

Instances are normally built by Alien::Xrepo and Alien::Xrepo::Runtime, not by hand.

ATTRIBUTES

includedirs

Arrayref of the package's include directories (the -I... paths).

libfiles

Arrayref of every library file the package installed: shared objects, import libraries, static archives, and so on. Unlike libpath, this is the complete list.

libpath

Absolute path to the package's primary runtime library (.dll, .dylib, or .so), chosen by matching the package's links against the installed files. undef for a header-only package. When no runtime binary can be identified the engine falls back to the first entry of libfiles so an XS build can still proceed (and warns when the package was requested as shared).

linkdirs

Arrayref of directories to search for the package's libraries (the -L... paths).

Arrayref of library base names to link against (the -l... names).

license

The license identifier xrepo reported for the package.

shared

Boolean: whether the package was built as a shared library.

static

Boolean: whether the package was built as a static library.

version

The installed version, as reported by xrepo.

bindirs

Arrayref of directories holding the package's executables. Falls back to <installdir>/bin when the package is a tool. See also bin_dir( ) for the same directories as a list.

installdir

The package's install root.

deps

Arrayref of the dependency records Xmake reported for the package, as hashrefs. Empty for a plain fetch; populated when the fetch asked for dependencies.

runtime_deps

Arrayref of the classified runtime dependencies of libpath (the libraries the dynamic linker resolves before the package's own symbols are usable). Each entry is a hashref with name, path, dir, and scope (store, host, system, or unresolved); empty when nothing was scanned. Alien::Xrepo::Build records these in the snapshot, so a hermetic consumer reads them without a second scan.

kind

'library' for a library (or header-only package), 'binary' for a tool. undef only if it could not be inferred.

METHODS

find_header( $filename )
my $path = $info->find_header('png.h');

Scans includedirs for the given filename and returns its absolute path, or undef after warning when it is not found.

bin_dir( )
my @dirs = $info->bin_dir;

The directories from bindirs as a list, handy for map/grep when hunting for a tool's executable.

with_runtime_deps( \@deps )
my $info = $info->with_runtime_deps($deps);

Returns a copy of the object with runtime_deps set to \@deps, or the object itself unchanged when it already carries a non-empty list. "package_info" in Alien::Xrepo::Runtime uses it to attach the runtime dependency diagnostic.

SEE ALSO

Alien::Xrepo, Alien::Xrepo::Runtime, Alien::Xrepo::Build

LICENSE

Copyright (C) Sanko Robinson.

This library is free software; you can redistribute it and/or modify it under the terms found in the Artistic License 2. Other copyrights, terms, and conditions may apply to data transmitted through this module.

AUTHOR

Sanko Robinson https://github.com/sanko