Files
moho/scripts/build-daemon.sh
SalastilandClaude Opus 5.5 dc80485390 Settings shows "development" for development builds, the version for releases
package.json's version is what a release will be, not what a build from
the development branch is - so About said 0.1.0, then 1.0.0-rc.1, for
builds that were neither. scripts/version-label.mjs decides once, for the
window (__APP_VERSION__) and the daemon (NOBILIS_CHANNEL, exported by the
daemon build scripts): the version for CI building its v<version> tag, a
checkout on that tag, or the master branch; "development" for anything
else.

A development build is never offered a newer release: "development" is not
a version to compare.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-04 16:54:25 -04:00

35 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env sh
# Builds the daemon for this machine, with a cargo that works.
#
# See find-cargo.sh for why "run cargo" is not as simple as it sounds when the
# caller is an npm script.
set -eu
SRC_DIR="$(cd "$(dirname "$0")/.." && pwd)"
. "$SRC_DIR/scripts/find-cargo.sh"
echo "building the daemon with $CARGO"
# Whether this is a release build, decided by moho's checkout - the
# submodule's own cannot tell (in CI it is a bare commit, on no branch). The
# daemon then reports its version, or "development".
NOBILIS_CHANNEL="$(node "$SRC_DIR/scripts/version-label.mjs" --channel)"
export NOBILIS_CHANNEL
# From inside nobilis/: cargo reads .cargo/config.toml from the directory it
# runs in, not from the manifest's, and nobilis's names the version a bundled
# libopus reports (#251).
cd "$SRC_DIR/nobilis"
# --locked: build exactly what Cargo.lock names, and fail rather than quietly
# re-resolve and rewrite it when Cargo.toml and the lockfile disagree.
"$CARGO" build --release --locked --manifest-path "$SRC_DIR/nobilis/Cargo.toml"
# A bundled libopus built before .cargo/config.toml named its version still
# says "unknown", and its build script does not rerun for that setting - so a
# kept target directory (here, or CI's cache) would ship "unknown" for good.
# Only that crate is built again, and only when it happened. A daemon linked
# to the system's libopus does not contain the string at all.
if grep -aq 'libopus unknown' "$SRC_DIR/nobilis/target/release/nobilis"; then
echo "the bundled libopus does not know its version - building it again"
"$CARGO" clean --release -p libopus_sys --manifest-path "$SRC_DIR/nobilis/Cargo.toml"
"$CARGO" build --release --locked --manifest-path "$SRC_DIR/nobilis/Cargo.toml"
fi