Antra

Standardbibliothek

Antra::NativeDeps

import Antra::NativeDeps

Native C libraries per project: antra native install, bundle, list.

A project lists the libraries it needs in native.and (AND, # starts a comment):

# native libraries for this game
%{raylib: "6.2", sdl2: "2.32.10"}

The map may also carry the tag %NativeDeps{...}, which says what the file is about; any other tag is an error.

install downloads them for the current platform (or --target) into native/<os>-<arch>/ next to native.and, together with their license texts; Antra::FFI finds libraries there automatically. bundle copies those files plus a THIRD-PARTY-NOTICES.txt into a release folder.

Known libraries are listed in RECIPES. A manifest entry may also be a full recipe for any other library:

%{mylib: %{version: "1.4", license: "MIT",
          platforms: %{"linux-x86_64" => %{url: "https://…/mylib-{version}.tar.gz",
                                        files: %{"libmylib.so" => "mylib-{version}/lib/libmylib.so"},
                                      license_file: "mylib-{version}/LICENSE"}}}}

Downloads are cached in ANTRA_CACHE (default: the user cache directory); ANTRA_DEPS_MIRROR (a directory or URL prefix) replaces the download location for offline or company mirrors.

Funktionen#

fn bundle(dir, out, [targets: = undef, log: = &println])

Copies the installed libraries of targets (default: every installed platform) to <out>/native/<target>/ and writes <out>/THIRD-PARTY-NOTICES.txt. Returns %Ok[report].

fn cache_dir()

The download cache directory: ANTRA_CACHE, else the platform's user cache directory (XDG_CACHE_HOME, ~/.cache, %LOCALAPPDATA%).

fn cli(argv)

Runs antra native <argv...>; returns the exit code.

fn find_project(start)

Returns %Ok[dir]: the nearest directory from start upwards that contains antra.and or native.and, or %Err when there is none.

fn has_manifest?(dir)

Whether the project in dir lists C libraries: native: in antra.and, else a native.and.

fn install(dir, [targets: = [System.platform()], force: = false, log: = &println])

Installs the manifest's libraries for targets (default: this platform). Returns %Ok[report] with one line per library and target. A library that fails does not stop the others; the lock file keeps what succeeded and the result is an %Err naming every failure. force: true reinstalls installed versions.

fn list(dir)

Prints the manifest's libraries with their state per platform. Returns %Ok[undef].

fn manifest_file(dir)

The file the libraries of dir come from: antra.and or native.and.

fn read_lock(dir, target)

Returns %Ok[map]: what install recorded for target (library => %{version:, files:, license:}), empty when nothing is installed.

fn read_manifest(dir)

Returns %Ok[map]: library name (keyword) => version string or recipe map, read from native: in <dir>/antra.and, else <dir>/native.and.

Quelle dieser Seite