Files
moho/scripts/build-daemon-win.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

54 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env sh
# Builds the Windows daemon and puts it where the packager expects it.
#
# Two things make this its own script rather than a line in package.json.
#
# The packager reads nobilis/target/release/nobilis.exe, but a cross-build
# writes to nobilis/target/x86_64-pc-windows-gnu/release/. Nothing connects
# those, so `pack:win` would happily bundle whatever .exe happened to be at the
# first path - which, on a machine that has been cross-building for days, is
# something old. That is the same shape of bug as an AppImage shipping a stale
# daemon, and it is worse here: it only shows up as "unknown method" on
# somebody else's computer.
#
# And it has to be a cargo that works, which is not the same as the one named
# `cargo` - see find-cargo.sh.
set -eu
TARGET=x86_64-pc-windows-gnu
SRC_DIR="$(cd "$(dirname "$0")/.." && pwd)"
MANIFEST="$SRC_DIR/nobilis/Cargo.toml"
. "$SRC_DIR/scripts/find-cargo.sh"
echo "building the Windows 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/, for its .cargo/config.toml - see build-daemon.sh.
cd "$SRC_DIR/nobilis"
# --locked: see build-daemon.sh.
"$CARGO" build --release --locked --target "$TARGET" --manifest-path "$MANIFEST"
BUILT="$SRC_DIR/nobilis/target/$TARGET/release/nobilis.exe"
# The Windows build always bundles libopus; see build-daemon.sh for why a kept
# target directory can leave it calling itself "unknown".
if [ -f "$BUILT" ] && grep -aq 'libopus unknown' "$BUILT"; then
echo "the bundled libopus does not know its version - building it again"
"$CARGO" clean --release --target "$TARGET" -p libopus_sys --manifest-path "$MANIFEST"
"$CARGO" build --release --locked --target "$TARGET" --manifest-path "$MANIFEST"
fi
WANTED="$SRC_DIR/nobilis/target/release/nobilis.exe"
# Not merely "did cargo exit 0": a build that fails after having produced an
# executable once leaves the old one in place, and copying that forward is how
# a stale daemon gets shipped.
[ -f "$BUILT" ] || { echo "no $BUILT - the build did not produce one" >&2; exit 1; }
mkdir -p "$(dirname "$WANTED")"
cp -f "$BUILT" "$WANTED"
echo "daemon -> $WANTED"