Alien-Xmake-Project
view release on metacpan or search on metacpan
lib/Alien/Xmake/Project.pod view on Meta::CPAN
Sets the debug-symbol mode. Levels may be combined: C<none>, C<debug>, C<hidden>, plus the msvc-only refinements
C<edit> and C<embed>.
=item C<set_fpmodels( @models )>
...->set_fpmodels( 'fast', 'except' )
Sets the floating-point compilation mode: C<fast>, C<strict>, C<except>, C<noexcept>, C<precise> (the default). Models
may be combined, but C<fast> conflicts with C<precise>/C<strict>.
=item C<set_exceptions( @modes )>
...->set_exceptions( 'cxx' )
Enables or disables C++ / Objective-C exceptions: C<cxx>, C<no-cxx>, C<objc>, C<no-objc>. xmake picks the
compiler-specific flag.
=item C<set_encodings( @encodings )>
...->set_encodings( 'utf-8' )
...->set_encodings( 'source:utf-8', 'target:gb2312' )
Sets the source and/or target executable encoding. A bare encoding applies to both; prefix with C<source:> or
C<target:> for one side.
=item C<set_policy( $name, $value )>
...->set_policy( 'build.warning', true )
Sets a build policy for this target. See the xmake builtin-policies reference for the full list.
=item C<set_pcheader( $header )>
...->set_pcheader( 'common.h' )
Sets the C precompiled header.
=item C<set_pcxxheader( $header )>
...->set_pcxxheader( 'common.hpp' )
Sets the C++ precompiled header.
=item C<set_pmheader( $header )>
...->set_pmheader( 'common.h' )
Sets the Objective-C precompiled header.
=item C<set_pmxxheader( $header )>
...->set_pmxxheader( 'common.hh' )
Sets the Objective-C++ precompiled header.
=item C<set_runtimes( @runtimes )>
...->set_runtimes( 'MD' )
Sets the runtime library flavour(s). On MSVC this selects the C runtime: C<MT>, C<MTd>, C<MD>, C<MDd>; on Android/iOS
it selects the C++ STL implementation: C<c++_static>, C<c++_shared>.
=item C<set_languages( @langs )>
...->set_languages( 'c99', 'cxx11' )
Sets the language standard(s). Standard C values: C<ansi>, C<c89>, C<gnu89>, C<c90>, C<gnu90>, C<c99>, C<gnu99>,
C<c11>, C<gnu11>, C<c17>, C<gnu17>, ..., C<clatest>. C++ values use the C<cxxN> form (C<cxx98>, C<cxx11>, C<cxx14>,
C<cxx17>, C<cxx20>, C<cxx23>, ..., C<cxxlatest>) or the C<C++N> spelling. A C and a C++ standard may be set together.
=item C<add_forceincludes( @files )>
...->add_forceincludes( 'config.h' )
Force-includes the given header files in every translation unit.
=item C<add_vectorexts( @exts )>
...->add_vectorexts( 'sse2', 'avx' )
Enables the given vector extensions.
=back
=item B<content and deps>
Otherwise-identical statements grouped by shared semantics; each is chainable.
=over
=item C<add_files( @patterns )>
...->add_files( 'src/*.cpp' )
Adds source files or glob patterns to compile.
=item C<remove_files( @patterns )>
...->remove_files( 'src/old.cpp' )
Removes source files/patterns previously added.
=item C<remove_headerfiles( @files )>
...->remove_headerfiles( 'src/old.h' )
Removes header files from the header set.
=item C<add_defines( @defines )>
...->add_defines( 'NDEBUG' )
Adds preprocessor macro definitions.
=item C<add_undefines( @defines )>
...->add_undefines( 'DEBUG' )
Undefines macros.
=item C<add_includedirs( @dirs )>
lib/Alien/Xmake/Project.pod view on Meta::CPAN
=item C<add_installfiles( @files )>
...->add_installfiles( 'README.md' )
Adds extra install files to package.
=item C<add_targets( @targets )>
...->add_targets( 'myapp' )
Includes the named build targets' outputs in the package.
=item C<add_components( @comps )>
...->add_components( 'core' )
Includes prebuilt components in the package.
=item C<add_buildrequires( @pkgs )>
...->add_buildrequires( 'nsis' )
Adds packages required to build the installer.
=item C<on_load( $body )> C<on_package( $body )>
...->on_package( 'function (xpack) end' )
Injects raw-Lua hooks (each takes raw Lua function bodies).
=item C<component( $name, @body )>
...->component( 'core', sub { ...->set_default( true ) } )
Begins an C<xpack_component(...)> block; returns a L</XpackComponent builder>.
=back
=head3 XpackComponent builder
An C<xpack_component(...)> block describes one sub-component of an xpack. Every method is chainable.
=over
=item C<set_title( $title )>
...->set_title( 'Core runtime' )
Sets the display title of the component.
=item C<set_description( $text )>
...->set_description( 'The core runtime library' )
Sets the description of the component.
=item C<set_default( $bool )>
...->set_default( true )
Sets whether the component is selected by default. Pass a real C<false> to deselect.
=item C<add_sourcefiles( @files )>
...->add_sourcefiles( 'src/*.c' )
Adds source files to this component.
=item C<add_installfiles( @files )>
...->add_installfiles( 'LICENSE' )
Adds extra install files to this component.
=item C<on_load( $body )>
...->on_load( 'function (component) end' )
Injects a raw-Lua hook (takes a raw Lua function body).
=item C<before_installcmd( $body )> C<on_installcmd( $body )> C<after_installcmd( $body )>
C<before_uninstallcmd( $body )> C<on_uninstallcmd( $body )> C<after_uninstallcmd( $body )>
...->on_installcmd( 'function (cmd) end' )
Injects raw-Lua hooks around the component's install/uninstall commands (each takes raw Lua function bodies). C<lua(
@lines )> pushes raw Lua lines straight into the component body.
=back
=head1 OPTION TABLES AND BOOLEANS
Any method that in xmake takes a trailing table accepts a Perl hashref as its last argument. It is rendered with
bracket keys so any string key is valid Lua:
$t->add_files('src/*.cpp', { unity_group => 'core' }); # add_files("src/*.cpp", {["unity_group"]="core"})
Use the v5.36+ C<true>/C<false> keywords for booleans so xmake receives a real boolean, not the string C<"1">:
$p->add_requires('zlib', { shared => true });
Key order in tables is deterministic (sorted).
=head1 EXAMPLES
A dependency-driven executable and a shared library with a test, built from Perl:
use v5.40;
use Alien::Xmake::Project;
my $p = Alien::Xmake::Project->new(file => 'xmake.lua');
$p->set_project('app')->set_version('0.1.0');
$p->add_rules('mode.debug', 'mode.release');
$p->add_requires('zlib', { configs => { shared => true } });
$p->target('core')
->set_kind('shared')
->add_files('src/core/*.cpp')
->add_packages('zlib');
$p->target('app')
( run in 3.094 seconds using v1.01-cache-2.11-cpan-e623d60df62 )