Alien-Xmake-Project

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


            Enables or disables C++ / Objective-C exceptions: `cxx`, `no-cxx`, `objc`, `no-objc`. xmake picks the
            compiler-specific flag.

        - `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 `source:` or
            `target:` for one side.

        - `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.

        - `set_pcheader( $header )`

            ```
            ...->set_pcheader( 'common.h' )
            ```

            Sets the C precompiled header.

        - `set_pcxxheader( $header )`

            ```
            ...->set_pcxxheader( 'common.hpp' )
            ```

            Sets the C++ precompiled header.

        - `set_pmheader( $header )`

            ```
            ...->set_pmheader( 'common.h' )
            ```

            Sets the Objective-C precompiled header.

        - `set_pmxxheader( $header )`

            ```
            ...->set_pmxxheader( 'common.hh' )
            ```

            Sets the Objective-C++ precompiled header.

        - `set_runtimes( @runtimes )`

            ```
            ...->set_runtimes( 'MD' )
            ```

            Sets the runtime library flavour(s). On MSVC this selects the C runtime: `MT`, `MTd`, `MD`, `MDd`; on Android/iOS
            it selects the C++ STL implementation: `c++_static`, `c++_shared`.

        - `set_languages( @langs )`

            ```
            ...->set_languages( 'c99', 'cxx11' )
            ```

            Sets the language standard(s). Standard C values: `ansi`, `c89`, `gnu89`, `c90`, `gnu90`, `c99`, `gnu99`,
            `c11`, `gnu11`, `c17`, `gnu17`, ..., `clatest`. C++ values use the `cxxN` form (`cxx98`, `cxx11`, `cxx14`,
            `cxx17`, `cxx20`, `cxx23`, ..., `cxxlatest`) or the `C++N` spelling. A C and a C++ standard may be set together.

        - `add_forceincludes( @files )`

            ```
            ...->add_forceincludes( 'config.h' )
            ```

            Force-includes the given header files in every translation unit.

        - `add_vectorexts( @exts )`

            ```
            ...->add_vectorexts( 'sse2', 'avx' )
            ```

            Enables the given vector extensions.
    - **content and deps**

        Otherwise-identical statements grouped by shared semantics; each is chainable.

        - `add_files( @patterns )`

            ```
            ...->add_files( 'src/*.cpp' )
            ```

            Adds source files or glob patterns to compile.

        - `remove_files( @patterns )`

            ```
            ...->remove_files( 'src/old.cpp' )
            ```

            Removes source files/patterns previously added.

        - `remove_headerfiles( @files )`

            ```
            ...->remove_headerfiles( 'src/old.h' )
            ```

            Removes header files from the header set.

        - `add_defines( @defines )`

            ```
            ...->add_defines( 'NDEBUG' )
            ```

README.md  view on Meta::CPAN

    Includes the named build targets' outputs in the package.

- `add_components( @comps )`

    ```
    ...->add_components( 'core' )
    ```

    Includes prebuilt components in the package.

- `add_buildrequires( @pkgs )`

    ```
    ...->add_buildrequires( 'nsis' )
    ```

    Adds packages required to build the installer.

- `on_load( $body )` `on_package( $body )`

    ```js
    ...->on_package( 'function (xpack) end' )
    ```

    Injects raw-Lua hooks (each takes raw Lua function bodies).

- `component( $name, @body )`

    ```perl
    ...->component( 'core', sub { ...->set_default( true ) } )
    ```

    Begins an `xpack_component(...)` block; returns a ["XpackComponent builder"](#xpackcomponent-builder).

### XpackComponent builder

An `xpack_component(...)` block describes one sub-component of an xpack. Every method is chainable.

- `set_title( $title )`

    ```
    ...->set_title( 'Core runtime' )
    ```

    Sets the display title of the component.

- `set_description( $text )`

    ```
    ...->set_description( 'The core runtime library' )
    ```

    Sets the description of the component.

- `set_default( $bool )`

    ```
    ...->set_default( true )
    ```

    Sets whether the component is selected by default. Pass a real `false` to deselect.

- `add_sourcefiles( @files )`

    ```
    ...->add_sourcefiles( 'src/*.c' )
    ```

    Adds source files to this component.

- `add_installfiles( @files )`

    ```
    ...->add_installfiles( 'LICENSE' )
    ```

    Adds extra install files to this component.

- `on_load( $body )`

    ```js
    ...->on_load( 'function (component) end' )
    ```

    Injects a raw-Lua hook (takes a raw Lua function body).

- `before_installcmd( $body )` `on_installcmd( $body )` `after_installcmd( $body )`
`before_uninstallcmd( $body )` `on_uninstallcmd( $body )` `after_uninstallcmd( $body )`

    ```js
    ...->on_installcmd( 'function (cmd) end' )
    ```

    Injects raw-Lua hooks around the component's install/uninstall commands (each takes raw Lua function bodies). `lua(
    @lines )` pushes raw Lua lines straight into the component body.

# 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:

```perl
$t->add_files('src/*.cpp', { unity_group => 'core' });   # add_files("src/*.cpp", {["unity_group"]="core"})
```

Use the v5.36+ `true`/`false` keywords for booleans so xmake receives a real boolean, not the string `"1"`:

```perl
$p->add_requires('zlib', { shared => true });
```

Key order in tables is deterministic (sorted).

# EXAMPLES

A dependency-driven executable and a shared library with a test, built from Perl:

```perl
use v5.40;
use Alien::Xmake::Project;



( run in 0.879 second using v1.01-cache-2.11-cpan-e623d60df62 )