fix: build.sh now accepts REPO_URL arg, clones repo, and auto-pushes artifacts
This commit is contained in:
@ -2,28 +2,34 @@
|
||||
|
||||
# MPVJ Build Script
|
||||
# Runs on x86_64 (e.g., Docker) to cross-compile artifacts for aarch64 (RPi 3B).
|
||||
# Outputs:
|
||||
# Outputs (committed back to the repo):
|
||||
# frontend/dist/ — pre-built Vite bundle
|
||||
# bin/ofxPiMapper — aarch64 binary
|
||||
#
|
||||
# Usage: bash scripts/build.sh [REPO_DIR]
|
||||
# REPO_DIR defaults to the directory containing this script's parent.
|
||||
# Usage:
|
||||
# bash build.sh <REPO_URL> # clones repo into ./mapper, then builds
|
||||
# bash build.sh <REPO_URL> <DIR> # clones into DIR, then builds
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_DIR="${1:-$(dirname "$SCRIPT_DIR")}"
|
||||
REPO_URL="${1:-}"
|
||||
REPO_DIR="${2:-$(pwd)/mapper}"
|
||||
OF_VERSION="0.12.1"
|
||||
OF_DIR="$REPO_DIR/.build/openFrameworks"
|
||||
OF_FILE="of_v${OF_VERSION}_linuxaarch64_release.tar.gz"
|
||||
OF_URL="https://github.com/openframeworks/openFrameworks/releases/download/${OF_VERSION}/${OF_FILE}"
|
||||
BIN_OUT="$REPO_DIR/bin"
|
||||
|
||||
# ── Validate repo ────────────────────────────────────────────────────────────
|
||||
if [ ! -d "$REPO_DIR/frontend" ] || [ ! -d "$REPO_DIR/backend" ]; then
|
||||
echo "ERROR: $REPO_DIR does not look like the mapper repo (missing frontend/ or backend/)."
|
||||
if [ -z "$REPO_URL" ]; then
|
||||
echo "Usage: bash $0 <REPO_URL> [CLONE_DIR]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ── Clone repo if needed ─────────────────────────────────────────────────────
|
||||
if [ ! -d "$REPO_DIR/frontend" ] || [ ! -d "$REPO_DIR/backend" ]; then
|
||||
echo "Cloning $REPO_URL into $REPO_DIR ..."
|
||||
git clone "$REPO_URL" "$REPO_DIR"
|
||||
fi
|
||||
echo "Building from: $REPO_DIR"
|
||||
|
||||
# ── 1. Install build dependencies ───────────────────────────────────────────
|
||||
@ -173,13 +179,22 @@ mkdir -p "$BIN_OUT"
|
||||
cp bin/example_basic "$BIN_OUT/ofxPiMapper"
|
||||
chmod +x "$BIN_OUT/ofxPiMapper"
|
||||
|
||||
# ── 7. Commit and push artifacts back to repo ───────────────────────────────
|
||||
echo ""
|
||||
echo "=== Pushing artifacts to remote ==="
|
||||
cd "$REPO_DIR"
|
||||
git config user.email "build-bot@mpvj" 2>/dev/null || true
|
||||
git config user.name "MPVJ Build Bot" 2>/dev/null || true
|
||||
git add frontend/dist/ bin/ofxPiMapper
|
||||
git commit -m "ci: add pre-built artifacts (frontend/dist + bin/ofxPiMapper)" || echo "(nothing new to commit)"
|
||||
git push
|
||||
|
||||
echo ""
|
||||
echo "============================================"
|
||||
echo " BUILD COMPLETE"
|
||||
echo " BUILD COMPLETE + PUSHED"
|
||||
echo "============================================"
|
||||
echo " Frontend: $REPO_DIR/frontend/dist/"
|
||||
echo " ofxPiMapper: $BIN_OUT/ofxPiMapper (aarch64)"
|
||||
echo ""
|
||||
echo " Commit and push these artifacts, then run"
|
||||
echo " setup.sh on the Pi to deploy."
|
||||
echo " Run setup.sh on the Pi to deploy."
|
||||
echo "============================================"
|
||||
|
||||
Reference in New Issue
Block a user