#!/bin/bash

set -euxo pipefail

# Use runner-specific build directory if EAGLE0_BUILD_DIR is set, otherwise default
BUILD_BASE="${EAGLE0_BUILD_DIR:-/tmp/eagle0}"

COMMIT=$(/usr/bin/git rev-parse --short HEAD)

/bin/echo "build protos"
./scripts/build_protos.sh

/bin/echo "build Sparkle plugin"
./scripts/build_sparkle_plugin.sh

git log -3

/bin/echo "build Mac"
LOG_PATH="${BUILD_BASE}/editor_mac.log"
BUILD_DIR=$1
BUILD_ADDRESSABLES=${2:-true}
ADDRESSABLES_BUILD_LAYOUT=${3:-$BUILD_ADDRESSABLES}

./ci/github_actions/build_mac.sh "$BUILD_DIR" "$LOG_PATH" "$BUILD_ADDRESSABLES" "$ADDRESSABLES_BUILD_LAYOUT"
