Repository navigation
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·75 lines (68 loc) · 3.94 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·75 lines (68 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
# One-command casual-dev bootstrap for aether-ui.
#
# Ensures the Aether toolchain (`ae`) and the build runner (`aeb`) are present
# and recent enough, then runs `aeb` to build the project's targets (the
# .build.ae / .tests.ae files in the tree). Mirrors servirtium-vcr/bootstrap.sh.
#
# Toolchains install via their canonical remote installers (work from a bare
# clone, install released builds to a user prefix):
# aether: https://raw.githubusercontent.com/aether-lang-org/aether/main/get.sh
# aeb: https://raw.githubusercontent.com/aether-lang-org/aeb/main/install.sh
#
# Idempotent: a no-op for the toolchain when `ae`/`aeb` are already good.
# Requires `curl` to install them; no build-from-source fallback. Platform-wise
# the build itself targets the host: GTK4 on Linux (needs gtk4 dev libs),
# AppKit on macOS, Win32 on Windows — the .build.ae files branch on the OS.
#
# Env overrides:
# PREFIX install prefix (default: $HOME/.local; no sudo)
# AETHER_REF ae tag/branch/SHA to install (default: latest tag) — pin in CI
# AEB_REF aeb tag/branch/SHA to install (default: latest tag) — pin in CI
# MIN_AE minimum acceptable ae version (default: 0.841.0, the family's: `@keep` in a function type, `fn(@keep ptr, float)`, in 0.841.0, #2980; `@keep ptr` parameters arrived in 0.818.0, #2926; the typed accessors map.get_string, list.get_string and string.from_ptr in 0.830.0, #2981)
# Extra args pass through to `aeb` (e.g. ./bootstrap.sh aevg/.analog-clock.ae).
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
PREFIX="${PREFIX:-$HOME/.local}"; export PREFIX
MIN_AE="${MIN_AE:-0.841.0}"
AETHER_GET_URL="https://raw.githubusercontent.com/aether-lang-org/aether/main/get.sh"
AEB_INSTALL_URL="https://raw.githubusercontent.com/aether-lang-org/aeb/main/install.sh"
say() { printf '\033[1;36m==>\033[0m %s\n' "$*"; }
die() { printf '\033[1;31merror:\033[0m %s\n' "$*" >&2; exit 1; }
version_ge() { [ "$(printf '%s\n%s\n' "$2" "$1" | sort -V | head -n1)" = "$2" ]; }
ae_version() { ae --version 2>/dev/null | head -n1 | sed -E 's/^ae ([0-9]+\.[0-9]+\.[0-9]+).*/\1/'; }
# fetch_run URL : download an installer to a temp file and run it under sh,
# inheriting the (exported) env the caller set. Downloads first, then runs the
# saved file, so a fetch failure can't be masked the way piping curl into a
# shell would.
fetch_run() {
command -v curl >/dev/null 2>&1 || die "curl is required to install the Aether toolchain (or install ae/aeb yourself and re-run)."
local tmp rc; tmp="$(mktemp)"
if curl -fsSL "$1" -o "$tmp"; then sh "$tmp"; rc=$?; else rc=$?; fi
rm -f "$tmp"; return $rc
}
export PATH="$PREFIX/bin:$PATH" # so freshly-installed ae/aeb are found below
# ---- 1. Aether toolchain (ae) ----
if command -v ae >/dev/null 2>&1 && have="$(ae_version || true)" && [ -n "$have" ] && version_ge "$have" "$MIN_AE"; then
say "ae $have already on PATH (>= $MIN_AE) — skipping"
else
say "installing ae via get.sh (AETHER_REF=${AETHER_REF:-latest}, PREFIX=$PREFIX)"
AETHER_REF="${AETHER_REF:-}" fetch_run "$AETHER_GET_URL" || die "ae install failed (get.sh)."
command -v ae >/dev/null 2>&1 || die "ae installed but not on PATH — ensure $PREFIX/bin is on PATH."
say "ae $(ae_version) ready"
fi
# ---- 2. Build runner (aeb) ----
if command -v aeb >/dev/null 2>&1; then
say "aeb already on PATH — skipping"
else
say "installing aeb via install.sh (AEB_REF=${AEB_REF:-latest}, PREFIX=$PREFIX)"
AEB_REF="${AEB_REF:-}" AETHER="$(command -v ae)" fetch_run "$AEB_INSTALL_URL" || die "aeb install failed (install.sh)."
command -v aeb >/dev/null 2>&1 || die "aeb installed but not on PATH — ensure $PREFIX/bin is on PATH."
fi
say "using aeb: $(command -v aeb)"
# ---- 3. Build the project ----
case ":$PATH:" in *":$PREFIX/bin:"*) : ;; *) say "tip: add '$PREFIX/bin' to your shell PATH permanently";; esac
say "running aeb"
cd "$HERE"
aeb "$@" || die "aeb build failed."
say "done."