# Alien::RmlUi

Find or build the RmlUi C++ user interface library for Perl distributions.

**Version:** 0.02. System and bundled FreeType integration, native XS tests,
and combined installation and relocation have been tested on Linux.
Other platforms are not yet verified.

## Requirements

- Perl 5.16 or later, a C++17 compiler compatible with the consuming XS module.
- Alien::FreeType 0.01 or later (installs FreeType when necessary).
- pkg-config or pkgconf.
- CMake (managed by Alien::Build's CMake plugin).

On Debian/Ubuntu: `sudo apt install build-essential cmake pkg-config`.
On Arch Linux: `sudo pacman -S base-devel cmake pkgconf`.
On macOS: `brew install cmake pkgconf` and Xcode command-line tools.

## Build and test

    cpanm --installdeps .
    perl Makefile.PL
    make
    make test

By default, an existing compatible native installation is preferred. Set
`ALIEN_INSTALL_TYPE=share` to force a build from the pinned source release,
or `ALIEN_INSTALL_TYPE=system` to require an existing native installation.
For pkg-config discovery, `rmlui.pc` must describe RmlUi 6.3 core, debugger
and their dependencies. Export `PKG_CONFIG_PATH` for a nonstandard native
prefix and keep it set through configuration and make.
On Linux, if pkg-config discovery fails, the build also tries upstream's
CMake package using a C++17 compile/link/run probe. Set `CMAKE_PREFIX_PATH`
or `RmlUi_DIR` for a nonstandard native install. This fallback requires
CMake 3.16+ on PATH and a GNU-style linker; other platforms fall back to
pkg-config or a share build. A failed probe falls back to a share build
unless a system install was explicitly requested.

## Installed and relocation test

    prefix=$(mktemp -d)
    make realclean
    ALIEN_INSTALL_TYPE=share perl Makefile.PL INSTALL_BASE="$prefix"
    make
    make test
    make install
    mv "$prefix" "$prefix-relocated"
    perl tools/test-installed.pl "$prefix-relocated"

The script runs the native tests from a temporary working directory and
checks that the module and native share directory are loaded from the
new installation rather than the source tree.

Alien::FreeType provides the FreeType dependency. To test the bundled
native dependency chain, first install Alien::FreeType with
`ALIEN_INSTALL_TYPE=share` and then build Alien::RmlUi with the same setting.
If both are installed under the same INSTALL_BASE, the relocation test
can move both together. Native system dependencies remain optional.

## Release verification

After the installed/relocation test above, reuse that native installation
to check the pkg-config system discovery path:

    native=$(PERL5LIB="$prefix-relocated/lib/perl5:${PERL5LIB:-}" \
        perl -MAlien::RmlUi -e 'print Alien::RmlUi->dist_dir')
    make realclean
    (
        export PKG_CONFIG_PATH="$native/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
        # For a bundled FreeType, also include its lib/pkgconfig directory.
        ALIEN_INSTALL_TYPE=system perl Makefile.PL &&
        make && make test && make alien_prop_runtime
    )

The reported installation type must be system, with nonempty compiler and
linker flags. The CMake-only discovery path is tested separately in CI using system FreeType.

To verify the CPAN distribution from a clean source-build configuration:

    make realclean
    ALIEN_INSTALL_TYPE=share perl Makefile.PL
    make dist
    ALIEN_INSTALL_TYPE=share make disttest

This tests a fresh unpacked distribution and may rebuild RmlUi.

## Usage

    use Alien::RmlUi;
    print Alien::RmlUi->version, "\n";
    print Alien::RmlUi->cflags, "\n";
    print Alien::RmlUi->libs, "\n";

Use a C++ compiler and linker for consuming XS distributions. The share build
uses static position-independent libraries so the XS module does not need to
locate RmlUi shared libraries at runtime. FreeType is supplied by Alien::FreeType for the bundled build.
The native smoke test builds and loads an XS module that calls both libraries.

This distribution does not expose a Perl UI API. Rendering, input and event
loops are outside the scope of this package. Windows is not validated.

## Upstream resources

- [RmlUi 6.3 source](https://github.com/mikke89/RmlUi/tree/6.3)
- [CMake build documentation](https://mikke89.github.io/RmlUiDoc/pages/cpp_manual/building_with_cmake.html)
- [Alien::Build CMake plugin](https://metacpan.org/pod/Alien::Build::Plugin::Build::CMake)
- [Alien::Build author guide](https://metacpan.org/pod/Alien::Build::Manual::AlienAuthor)

MIT license. Upstream license notices are preserved in the installed share directory.
