A `-Dprofile=development` build is a separate application identity: the app id carries a `.Devel` suffix, and the desktop file, AppStream id, icon, GSettings schema id/path, GResource bundle name, D-Bus name and data directories all follow, with a `regent-devel` binary so it installs beside the stable one instead of replacing it. The Rust side switches `APP_ID` on a cargo `devel` feature (a feature, not an env var, so the shared cargo target dir cannot return a binary built for the other profile); the metadata files become `.in` templates configured from `app_id`. The nightly uses the banded nightly app icon and libadwaita's striped `devel` header bar. The dev deploy selects it with `REGENT_PROFILE=development`; the release `--pkg` build stays stable, and a nightly install leaves the `nostrconnect://` scheme handler to the stable build. Two Meson details this depends on: the GResource prefix is fixed by `resources.gresource.xml` (not the resource id) and is shared by both profiles, and `gnome.compile_schemas()` scans the source directory, so the generated schema is compiled by a `glib-compile-schemas` target instead.
111 lines
4.0 KiB
Bash
Executable File
111 lines
4.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build Regent and produce something installable elsewhere.
|
|
#
|
|
# Runs on the build host. Modes:
|
|
# --emit stream a tar.zst of the install tree on stdout (logs go to
|
|
# stderr) so the other machine can pipe it straight into tar:
|
|
# ssh HOST '<repo>/build-aux/deploy-dev.sh --emit' \
|
|
# | tar -x --zstd -C ~/.local
|
|
# (default) write that same tarball to a file and print its path
|
|
# --pkg build the `regent-git` pacman package and print its path
|
|
# --versions print the GTK/libadwaita versions this host builds against
|
|
#
|
|
# REGENT_PROFILE=development builds the nightly `.Devel` identity (its own app id,
|
|
# icon, desktop file, D-Bus name and data directories, and a `regent-devel`
|
|
# binary) instead of the stable one; see meson.options. The release `--pkg` build
|
|
# is always stable.
|
|
#
|
|
# The install tree is rooted at /usr, so extracting it into $HOME/.local yields
|
|
# the XDG layout: ~/.local/bin/regent, ~/.local/share/<app-id>/, ...
|
|
set -euo pipefail
|
|
|
|
log() { printf 'deploy: %s\n' "$*" >&2; }
|
|
die() { printf 'deploy: %s\n' "$*" >&2; exit 1; }
|
|
|
|
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
cd "$ROOT"
|
|
|
|
MODE=stage
|
|
case "${1:-}" in
|
|
--emit) MODE=emit ;;
|
|
--pkg) MODE=pkg ;;
|
|
--versions) MODE=versions ;;
|
|
''|--stage) ;;
|
|
-h|--help) sed -n '2,20p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
*) die "unknown option: $1 (try --help)" ;;
|
|
esac
|
|
|
|
if [ "$MODE" = versions ]; then
|
|
printf 'gtk4=%s libadwaita=%s\n' \
|
|
"$(pkg-config --modversion gtk4)" "$(pkg-config --modversion libadwaita-1)"
|
|
exit 0
|
|
fi
|
|
|
|
# Which application identity to build. `development` is the `.Devel` nightly,
|
|
# which gets its own app id, icon, desktop file, D-Bus name and data directories
|
|
# so it can be installed beside the stable one. The release `--pkg` build is
|
|
# always stable, whatever the caller asked for.
|
|
PROFILE=${REGENT_PROFILE:-default}
|
|
case "$PROFILE" in
|
|
default|development) ;;
|
|
*) die "unknown profile: $PROFILE (default or development)" ;;
|
|
esac
|
|
if [ "$MODE" = pkg ]; then
|
|
PROFILE=default
|
|
fi
|
|
|
|
for tool in cargo meson pkg-config tar zstd; do
|
|
command -v "$tool" >/dev/null || die "$tool not found"
|
|
done
|
|
|
|
# Version stamp: crate version plus commit count and short SHA, so each build
|
|
# from a new commit sorts higher than the previous one.
|
|
CARGO_VER=$(sed -n 's/^version *= *"\(.*\)"/\1/p' Cargo.toml | head -1)
|
|
SHA=$(git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
|
COUNT=$(git rev-list --count HEAD 2>/dev/null || echo 0)
|
|
DIRTY=""
|
|
git diff --quiet --ignore-submodules HEAD 2>/dev/null || DIRTY=".dirty"
|
|
PKGVER="${CARGO_VER:-0.0.0}.r${COUNT}.g${SHA}${DIRTY}"
|
|
log "version ${PKGVER}"
|
|
|
|
OUT_DIR=${REGENT_OUT_DIR:-/tmp/regent-dev}
|
|
mkdir -p "$OUT_DIR"
|
|
|
|
if [ "$MODE" = pkg ]; then
|
|
command -v makepkg >/dev/null || die "makepkg not found"
|
|
log "building regent-git with makepkg"
|
|
( cd build-aux/regent-git \
|
|
&& REGENT_DEV_PKGVER="$PKGVER" REGENT_REPO="$ROOT" makepkg -f --noconfirm ) >&2
|
|
PKG=$(ls -t build-aux/regent-git/regent-git-*.pkg.tar.* | head -1)
|
|
install -m644 "$PKG" "$OUT_DIR/"
|
|
printf '%s\n' "$OUT_DIR/$(basename "$PKG")"
|
|
exit 0
|
|
fi
|
|
|
|
BUILD_DIR=${REGENT_BUILD_DIR:-_build}
|
|
# `meson install` cannot change the prefix, so the build directory is always
|
|
# configured with /usr — the staged tree is then $STAGE/usr, which unpacks into
|
|
# $HOME/.local as the standard XDG layout.
|
|
if [ -d "$BUILD_DIR" ]; then
|
|
meson setup --reconfigure --prefix=/usr -Dprofile="$PROFILE" "$BUILD_DIR" >&2
|
|
else
|
|
log "configuring $BUILD_DIR (profile: $PROFILE)"
|
|
meson setup --prefix=/usr -Dprofile="$PROFILE" "$BUILD_DIR" >&2
|
|
fi
|
|
log "compiling"
|
|
meson compile -C "$BUILD_DIR" >&2
|
|
|
|
STAGE=$(mktemp -d "${TMPDIR:-/tmp}/regent-stage.XXXXXX")
|
|
trap 'rm -rf "$STAGE"' EXIT
|
|
log "staging the install tree"
|
|
meson install -C "$BUILD_DIR" --destdir "$STAGE" --quiet >&2
|
|
|
|
if [ "$MODE" = emit ]; then
|
|
log "streaming the install tree to stdout"
|
|
tar -C "$STAGE/usr" -cf - . | zstd -q -c
|
|
else
|
|
OUT="$OUT_DIR/regent-$PKGVER.tar.zst"
|
|
tar -C "$STAGE/usr" -cf - . | zstd -q -c > "$OUT"
|
|
printf '%s\n' "$OUT"
|
|
fi
|