Standardbibliothek
Antra::Packer
import Antra::PackerReady-to-run app folders and archives: antra pack.
pack puts everything a program needs into one folder per target
platform and packs it as .zip (Windows) or .tar.gz:
dist/breakout-windows-x86_64/
breakout.exe the antra runtime, renamed — double-click starts the app
antra-app.txt tells the runtime which script to run
lib/Antra/ the standard library
app/ the project: scripts, assets, its own lib/
app/native/windows-x86_64/ the C libraries from native.and
licenses/ antra's and the libraries' license noticesEvery target is built from every system: the runtime for another platform
comes from the antra release of the same version (cached like native
libraries, ANTRA_CACHE), native libraries from antra native install.
Settings come from the command line or an optional app.and next to the
main script:
# antra pack settings
%Packer{name: "breakout", main: "breakout.ant", version: "1.0",
targets: ["windows-x86_64", "linux-x86_64", "macos-aarch64"],
exclude: ["tests", "*.tmp"]}Written as %Packer{...} the file says what it is; plain %{...} works as
well.
The packed app starts in the folder of its main script (cwd: "main",
the default), so relative paths like "resources/ball.png" work as in
development; cwd: "keep" keeps the caller's directory (command-line
tools that take file arguments). System.script_dir() finds the app's
files either way.
With macos_app: true (or --macos-app) a macOS target becomes an app
bundle that starts with a double-click:
dist/breakout-macos-aarch64/Breakout.app/Contents/
Info.plist name, bundle id, version, icon
MacOS/breakout the antra runtime, with antra-app.txt next to it
Resources/ lib/Antra/, app/, licenses/, the icondisplay_name names the bundle (default: name), bundle_id sets
CFBundleIdentifier, icon is a PNG (16 to 1024 pixels square, or a list
of them) or an .icns file. Output goes to ~/Library/Logs/<name>.log
when the app runs without a terminal. On a Mac the bundle is signed ad hoc
(codesign -s -).
With onefile: true (or --onefile) the app is a single executable: the
runtime with its files appended as one payload. It unpacks them on the
first start into the cache (ANTRA_CACHE, else %LOCALAPPDATA%\antra\cache
or ~/.cache/antra, in apps/<hash>/) and runs from there. On macOS an
appended payload would break the code signature, so the payload is an
app.pack file next to the executable (in Contents/Resources/ of a
bundle).
Funktionen#
fn cli(argv)Runs antra pack <argv...>; returns the exit code.
fn icns(pngs)An .icns icon from square PNG images (ByteStrings) of 16, 32, 64,
128, 256, 512 or 1024 pixels: %Ok[bytes]. macOS scales the largest
one for the sizes that are missing.
fn info_plist(info)The Info.plist of an app bundle; info has name, display_name,
bundle_id, version, exe and icon (a file name or undef).
fn pack(dir, [main: = undef, targets: = undef, out: = undef, name: = undef, version: = undef,
macos_app: = undef, onefile: = undef, native_build: = undef, dmg: = undef, runtimes: = %{}, archive: = true, log: = &println])Packs the project in dir for targets. Options default to app.and
(see the package description), then to: main main.ant or the only
script, name from the main script, targets [System.platform()], out
<dir>/dist. runtimes maps a target to a release archive (path or
URL) or unpacked release folder to take antra from. Returns
%Ok[[path, ...]]: one archive (or, with archive: false, folder) per
target.
fn read_config(dir)%Ok[map]: the settings from <dir>/antra.and (pack: plus name,
version and main), else from <dir>/app.and, an empty map without
either.
fn runtime_url(target)The URL of the antra release archive for target: ANTRA_RELEASE_URL
if set, else the release of the running version (the latest release
for a development build).
