Files
desi_explorer/scripts/install_odin.sh
sam_oneal 8c74efcedb
CI / Detect changed paths (pull_request) Successful in 5s
CI / Odin unit tests and build (pull_request) Successful in 1m10s
CI / API unit tests and lint (pull_request) Has been skipped
CI / Infra unit tests, vet, and preview (pull_request) Successful in 59s
updated the runner to utilize caching
2026-09-06 20:11:38 +00:00

49 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Installs the pinned Odin release matching the runner's native architecture.
# The Odin release tarballs are named odin-linux-{amd64,arm64}-<version>.tar.gz;
# on an arm64 runner the amd64 Odin binary only runs under emulation and emits
# amd64 objects, which a natively-installed clang/ld cannot link ("Relocations
# in generic ELF (EM: 62)").
set -euo pipefail
VERSION="${ODIN_VERSION:-dev-2026-07}"
ARCH="$(uname -m)"
case "$ARCH" in
x86_64 | amd64) OBJ_ARCH="amd64" ;;
aarch64 | arm64) OBJ_ARCH="arm64" ;;
*)
echo "Unsupported runner architecture: $ARCH" >&2
exit 1
;;
esac
# If a prior job restored the install from cache, reuse it instead of
# re-downloading. The extracted Odin binary already on PATH is authoritative;
# otherwise fetch the version (plus the raylib workaround) fresh.
if [ -x /tmp/odin/odin ]; then
echo "Odin ${VERSION} found in cache (host arch: ${ARCH}, release arch: ${OBJ_ARCH})"
BIN_DIR=/tmp/odin
else
curl -fL -o /tmp/odin.tar.gz \
"https://github.com/odin-lang/Odin/releases/download/${VERSION}/odin-linux-${OBJ_ARCH}-${VERSION}.tar.gz"
mkdir -p /tmp/odin
tar -xzf /tmp/odin.tar.gz -C /tmp/odin --strip-components=1
BIN_DIR=/tmp/odin
fi
# Work around an Odin binding bug: for ODIN_ARCH == .arm64 the vendored
# raylib references `vendor/raylib/linux-arm/libraylib.a`, but the release
# tarball ships it under `linux-arm64/` (see vendor/raylib/raylib.odin).
if [ "${OBJ_ARCH}" = "arm64" ] \
&& [ -d /tmp/odin/vendor/raylib/linux-arm64 ] \
&& [ ! -e /tmp/odin/vendor/raylib/linux-arm ]; then
ln -s linux-arm64 /tmp/odin/vendor/raylib/linux-arm
fi
if [ -n "${GITHUB_PATH:-}" ]; then
echo "${BIN_DIR}" >> "$GITHUB_PATH"
fi
echo "Odin ${VERSION} ready (host arch: ${ARCH}, release arch: ${OBJ_ARCH})"