NAME
Alien::Xrepo::Base - Base class for Alien distributions using Xrepo
SYNOPSIS
In your subclass lib/Alien/Zstd.pm:
use v5.40;
use experimental 'class';
use Alien::Xrepo::Base;
class Alien::Zstd : isa(Alien::Xrepo::Base) {
method package_name { 'zstd' }
# Optional: customize installation
method install_opts {
return (
kind => 'shared',
configs => { legacy => 1 }
);
}
}
In your Build.PL:
use strict;
use warnings;
use lib 'lib';
use Alien::Xrepo::Base;
# Pass your subclass name to the builder
Build_PL('Alien::Zstd');
In your cpanfile:
requires 'perl', '5.40.0';
requires 'File::ShareDir', '1.00';
on 'configure' => sub {
requires 'Alien::Xmake', '0.08';
requires 'Alien::Xrepo', '0.08';
};
on 'build' => sub {
requires 'ExtUtils::InstallPaths', '0.002';
requires 'ExtUtils::Install', '2.00';
};
DESCRIPTION
Alien::Xrepo::Base is a base class designed to simplify the creation of Alien::* distributions that use xrepo to manage native dependencies.
It leverages Perl 5.40's native class features and provides a Module::Build::Tiny-compatible build system that:
- 2. Captures all relevant metadata (include dirs, lib dirs, flags, etc.).
- 3. Generates a
ConfigData.pmmodule for runtime access. - 4. Handles portable path resolution both from
blib(during development/testing) and from the final installation directory.
CONSTRUCTOR
new( ... )
my $alien = Alien::Zstd->new(
package_name => 'zstd',
version_constraint => 'latest',
root => '/path/to/project-root',
verbose => 1
);
Creates a new instance. If package_name is omitted it is inherited from the subclass package_name method.
- package_name
-
The name of the package as it appears in the
xreporepository (e.g.,zstd). If omitted, the value returned by the subclasspackage_namemethod is used. One of the two must be provided. - version_constraint
-
Optional semantic version constraint (e.g.,
1.6.x,latest,1.6.32). Passed toAlien::Xrepo::installand appended to thexrepoinstall spec. - root
-
Optional path to an isolated, local installation root for packages and configuration. When set,
XMAKE_CONFIGDIRandXMAKE_PKG_INSTALLDIRpoint inside this directory so the package does not touch the global~/.xmakeenvironment. - verbose
-
Boolean. If true, prints xrepo status output to
STDOUT. Defaults to0.
SUBCLASSING
To create a new Alien module, inherit from this class and implement the following methods:
package_name( )
Required. Returns the name of the package as it appears in the xrepo repository.
install_opts( )
Optional. Returns a hash (or list) of options honored by the builder (Build_PL / Build) when it installs the package during the build action. Pass these same options directly to install( %opts ) when installing at runtime. Common options include:
kind: 'shared' (default) or 'static'.configs: A hash reference of package-specific configuration flags.plat,arch,mode: Platform/Architecture/Mode overrides.
METHODS
install( %opts )
Explicitly triggers the installation of the package. This is usually handled automatically by the build system, but can be called manually at runtime if dynamic fetching is desired.
upgrade( %opts )
Updates the xrepo repositories and then calls install().
cflags( )
Returns the compiler flags (typically -I flags) required to use the library.
libs( )
Returns the linker flags (typically -L and -l flags) required to use the library.
version( )
Returns the version of the installed package.
libpath( )
Returns the absolute path to the primary shared library.
ffi_lib( )
An alias for libpath(), provided for compatibility with FFI::Platypus.
bin_dir( )
Returns an array reference of directories containing executables.
kind( )
Returns the type of installation: 'library' or 'binary'.
find_header( $filename )
Searches the package's include directories for the specified header and returns its absolute path.
package_info( )
Returns the raw Alien::Xrepo::PackageInfo object containing all metadata.
BUILDER METHODS
These methods are intended for use in Build.PL and the generated Build script.
Build_PL( $alien_class )
Creates the Build script and stores build parameters. $alien_class should be the name of your subclass.
Build( [$alien_class] )
The entry point for the Build script. Orchestrates the build, test, install, and clean actions.
SEE ALSO
Alien::Xrepo, Alien::Xmake, xmake, xrepo
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