Files
ml e07258c8bd
release / build (push) Successful in 5m34s
Fix VICE cross-compile and image cache-warming for release builds
build-image/Dockerfile: add bison (VICE's configure needs a yacc-compatible
parser generator, same category as the earlier flex fix) and exclude
packageRelease/signReleaseBundle from the cache-warm stage's gradlew run,
since those always fail there for lack of a keystore that's never baked
into the image.

vice_jni.c: guard getFrameCount()/setSoundEnabled() with #ifdef
HAVE_VICE_SRC like their sibling functions already do — they referenced
globals that only exist when VICE is linked in, breaking the documented
no-VICE placeholder build. Only surfaced now because the cache-warm stage
is the first thing to ever compile this file without VICE.

dist.sh: floor the untagged dev-build's versionCode at 1, since the
0.0.0-dev+<sha> placeholder otherwise computes to 0, which Android's
Gradle plugin rejects.

run-image.sh: wipe generated build artifacts (vice-src, vice-libs,
nibtools-src/libs, app/build, .cxx) before each run so it exercises a true
from-scratch build like CI does, instead of silently reusing artifacts
left over from a previous local run. Also chown the bind-mounted repo back
to the host user on exit, since the container runs as root and was
otherwise leaving root-owned files behind.
2026-07-04 15:11:53 +02:00

74 lines
2.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Runs dist.sh inside the local build-image container, mirroring what the
# Gitea Actions release workflow does — useful for testing build-image
# changes (or dist.sh/build_vice.sh/build_nibtools.sh changes) locally
# before pushing anything to cr.ladkau.de.
#
# Usage: ./run-image.sh [VERSION]
# VERSION is passed through to dist.sh; omit it for dist.sh's own
# git-tag-based default (see dist.sh's header comment).
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
ROOT="$(pwd)"
fail() { echo "PREFLIGHT FAIL: $*" >&2; exit 1; }
command -v docker >/dev/null 2>&1 \
|| fail "docker not found in PATH"
[ -f "$ROOT/registry.env" ] \
|| fail "registry.env not found — copy registry.env.example to registry.env and fill in your cr.ladkau.de credentials"
# shellcheck disable=SC1091
source "$ROOT/registry.env"
: "${REGISTRY_IMAGE:?registry.env must set REGISTRY_IMAGE}"
IMAGE_TAG="$(<"$ROOT/build-image/VERSION")"
[ -n "$IMAGE_TAG" ] || fail "build-image/VERSION is empty"
IMAGE="$REGISTRY_IMAGE:$IMAGE_TAG"
docker image inspect "$IMAGE" >/dev/null 2>&1 \
|| fail "$IMAGE not found locally — run ./build-image.sh first"
VERSION="${1:-${VERSION:-}}"
# CI always starts from a fresh checkout, but this script bind-mounts the live
# host repo — so build outputs left over from a previous local run (e.g. a
# vice-src/ already configured, or a libvice.a that's already built) would
# make build_vice.sh/build_nibtools.sh skip work they'd have to do on a real
# fresh checkout, silently hiding bugs (like a missing host build tool) that
# only show up in CI. Wipe them first so every run exercises a true from-
# scratch build, same as CI.
JNI="$ROOT/SchwertUndMagieOnPebbleCompanionApp/app/src/main/jni"
echo "== Cleaning generated build artifacts for a fresh build =="
rm -rf \
"$JNI/vice-src" "$JNI/vice-libs" \
"$JNI/nibtools-src" "$JNI/nibtools-libs" \
"$ROOT/SchwertUndMagieOnPebbleCompanionApp/app/build" \
"$ROOT/SchwertUndMagieOnPebbleCompanionApp/app/.cxx" \
"$ROOT/SchwertUndMagieOnPebbleWatchApp/build"
echo "== Running dist.sh inside $IMAGE =="
# The container runs as root (needed for the SDK/NDK/Gradle setup baked into
# the image), so anything it writes into this bind mount — dist/, app/build,
# .cxx, etc. — would otherwise come back owned by root, leaving the host repo
# unusable without sudo. Chown everything back to the host user on exit,
# whether dist.sh succeeds or fails.
docker run --rm \
-v "$ROOT:/workspace" \
-w /workspace \
-e VERSION="$VERSION" \
-e HOST_UID="$(id -u)" \
-e HOST_GID="$(id -g)" \
"$IMAGE" \
bash -c '
git config --global --add safe.directory /workspace
trap "chown -R \"$HOST_UID:$HOST_GID\" /workspace" EXIT
./dist.sh
'
echo "== Done — artifacts in dist/ =="
ls -la "$ROOT/dist"