Alien-Xmake

 view release on metacpan or  search on metacpan

Changes.md  view on Meta::CPAN

  - `import_pkg` / `export` handle offline package distribution
  - `list_repo` lists configured remote repositories
  - `env` sets up a package environment and runs a program (or `--show` it)
  - `search` supports `--addon`
  - `uninstall` supports `--all` and `--force`
  - `_build_args` now understands jobs, force/shallow/build, VS/NDK/SDK/MingW toolchain switches, and `--toolchain_host`
- Full coverage of xmake actions and plugins in Alien::Xmake
  - New constructor option `verbose` to echo commands as they run
  - Actions: `build`, `clean`, `create`, `configure`, `global`, `install`, `uninstall`, `package`, `pack`, `require`, `run`, `test`, `update`, `service`, `addon`
  - Plugins: `check`, `doxygen`, `format`, `lua`, `macro`, `project`, `repo`, `show`, `watch`
  - Generic escape hatch `task( $name, %options )` for tasks without a dedicated method
  - `show` strips ANSI codes, splits listings, and decodes `--format=json` into a data structure
  - The xmake `f`-style config switches are mapped to options like `plat`, `arch`, `mode`, `kind`, `vs`, `ndk`, `mingw`, `sdk`, `toolchain`, ... (plus a `set` hash for any `--key=value`)
  - `global` gets only the config keys xmake actually accepts there (`vs`, `ndk`, `qt`, ...)
  - Version-build accessor renamed `build()` to `buildid()` so `build` is the build action; the xmake `config` action is exposed as `configure()` to keep config( $key )` as the install-time data accessor
- New `installdir`/`cachedir` options to force a project-local package store (via `XMAKE_PKG_INSTALLDIR` / `XMAKE_PKG_CACHEDIR`) for reproducible, isolated builds
- `::PackageInfo` gains...
  - an `installdir` accessor (from fetch `artifacts.installdir`, else derived from the first libfile/include dir) and `bin_dir` falls back to `<installdir>/bin`, so tool packages (ninja, python, ...) can be installed and run as binaries
  - a `kind` accessor (`library` vs `binary`), surfaced by `print`/`dump`/`_data_printer`
- `Alien::Xrepo->new( root => $dir )` becomes the default `installdir` for every store-touching method, so one install call can run against a project-local store; used by `Alien::Xrepo::Base`
- Alien::Xrepo POD now describes binary/tool installs and not just shared libs for FFI

README.md  view on Meta::CPAN

my $host = $xmake->lua_json('os.host()', return => 1);              # "windows"
my $info = $xmake->lua_json(q{import("core.base.json"); print(json.encode({arch=os.arch()}))});
```

Runs inline Lua and returns the decoded JSON it produced. In the simplest form the code prints one JSON value itself
via `import`ing `core.base.json` and passing `print(json.encode(...))`. With `return => 1` just give the value,
e.g. a string, a number, a table (`{1,2,3}`), or a nested structure (`{name='z', libs={'z','m'}}`), and the wrapper
prints the encoded JSON for you.

xmake's `lua` runner appends a stray `{ }` chunk even on success, so the wrapper locates and decodes the emitted JSON
value and returns an empty list if none is found. `lua_json` is the general escape hatch when a specific method (like
`target_info`) does not yet exist for a structured query.

## `macro( [$name], %options )`

```perl
$xmake->macro('mybuild', begin => 1);     # begin recording
$xmake->macro('mybuild', end => 1);       # and stop
my $list = $xmake->macro( list => 1 );
```

README.md  view on Meta::CPAN

Rebuilds (or runs) the project whenever source files change. `commands` holds the command to rerun (`-c`), `script`
the path of the script to watch, `watchdirs`/`plaindirs` add extra watched/ignored directories, `run` reruns the
given target and `target` the target to build. Arbitrary program arguments are passed via `argv`.

## `task( $name, %options )`

```perl
$xmake->task('show', args => ['-l', 'toolchains']);
```

Generic escape hatch that runs any xmake task/plugin by name with `%options`, streaming output and returning success.
Reach for this when a dedicated method doesn't exist yet.

## `version( )`

```perl
my $ver = $xmake->version;
```

Returns the xmake version (e.g. `v3.0.6`).

README.md  view on Meta::CPAN

use Alien::Xmake;

my $x = Alien::Xmake->new;
system $x->xrepo, qw[search zlib];             # find a package
system $x->xrepo, qw[info libpng];             # package details
```

## Query structured target info and arbitrary Lua as JSON

Capture methods return decoded Perl data instead of streaming. `target_info` gives the rich per-target detail, and
`lua_json` is the escape hatch for any other structured query:

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

my $x = Alien::Xmake->new;
$x->create('demo', template => 'console');
chdir 'demo';
$x->configure(mode => 'release');

lib/Alien/Xmake.pm  view on Meta::CPAN

    method _join ( $value, $sep //= ',' ) {
        return () unless defined $value;
        ref $value eq 'ARRAY' ? join( $sep, map { _bool_str($_) } @$value ) : _bool_str($value);
    }

    sub _bool_str ($value) {
        return $value ? 'true' : 'false' if is_bool($value);
        return $value;
    }

    # Generic escape hatch: run any task/plugin by name.
    method task ( $name, %opts ) {
        my @args = $self->_extra_args( \%opts );
        $self->_run( $name, @args );
    }

    # Actions
    method build ( $target //= (), %opts ) {
        my @args;
        push @args, '-r'        if $opts{rebuild};
        push @args, '-a'        if $opts{all};

lib/Alien/Xmake.pm  view on Meta::CPAN

        File::Spec->rel2abs($bin);
    }

    # Quote path if on Windows and spaces exist
    method _quote_path ($path) {
        return qq{"$path"} if $windows && $path =~ /\s/;
        $path;
    }

    # Safely quote arguments for Windows cmd.exe
    method _escape_args (@args) { return @args }
};
#
1;
__END__
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.

lib/Alien/Xmake.pod  view on Meta::CPAN


    my $host = $xmake->lua_json('os.host()', return => 1);              # "windows"
    my $info = $xmake->lua_json(q{import("core.base.json"); print(json.encode({arch=os.arch()}))});

Runs inline Lua and returns the decoded JSON it produced. In the simplest form the code prints one JSON value itself
via C<import>ing C<core.base.json> and passing C<print(json.encode(...))>. With C<return =E<gt> 1> just give the value,
e.g. a string, a number, a table (C<{1,2,3}>), or a nested structure (C<{name='z', libs={'z','m'}}>), and the wrapper
prints the encoded JSON for you.

xmake's C<lua> runner appends a stray C<{ }> chunk even on success, so the wrapper locates and decodes the emitted JSON
value and returns an empty list if none is found. C<lua_json> is the general escape hatch when a specific method (like
C<< target_info >>) does not yet exist for a structured query.

=head2 C<macro( [$name], %options )>

    $xmake->macro('mybuild', begin => 1);     # begin recording
    $xmake->macro('mybuild', end => 1);       # and stop
    my $list = $xmake->macro( list => 1 );

Records and replays the shell commands that follow (clone of C<xmake macro>). C<begin>/C<end> control recording,
C<show> prints a recorded macro, C<list> lists them (captured), C<delete>/C<clear> remove them and C<export>/C<import>

lib/Alien/Xmake.pod  view on Meta::CPAN

    $xmake->watch( script => 'my_script.lua' );

Rebuilds (or runs) the project whenever source files change. C<commands> holds the command to rerun (C<-c>), C<script>
the path of the script to watch, C<watchdirs>/C<plaindirs> add extra watched/ignored directories, C<run> reruns the
given target and C<target> the target to build. Arbitrary program arguments are passed via C<argv>.

=head2 C<task( $name, %options )>

    $xmake->task('show', args => ['-l', 'toolchains']);

Generic escape hatch that runs any xmake task/plugin by name with C<%options>, streaming output and returning success.
Reach for this when a dedicated method doesn't exist yet.

=head2 C<version( )>

    my $ver = $xmake->version;

Returns the xmake version (e.g. C<v3.0.6>).

=head2 C<buildid( )>

lib/Alien/Xmake.pod  view on Meta::CPAN

    use v5.40;
    use Alien::Xmake;

    my $x = Alien::Xmake->new;
    system $x->xrepo, qw[search zlib];             # find a package
    system $x->xrepo, qw[info libpng];             # package details

=head2 Query structured target info and arbitrary Lua as JSON

Capture methods return decoded Perl data instead of streaming. C<target_info> gives the rich per-target detail, and
C<lua_json> is the escape hatch for any other structured query:

    use v5.40;
    use Alien::Xmake;

    my $x = Alien::Xmake->new;
    $x->create('demo', template => 'console');
    chdir 'demo';
    $x->configure(mode => 'release');

    # decoded target HASH (name, kind, files, compilers, linker, targetfile ...)



( run in 0.766 second using v1.01-cache-2.11-cpan-54e63673c56 )