#!/usr/bin/env bash # Compila StickFighter (homebrew de Arduboy de Tony Mamacos, MIT) do commit deb2492 de # github.com/tonym128/stickfighter, com versoes fixas: o nucleo Arduino AVR 1.8.6 (LGPL-2.1; avr-gcc 7.3.0) e a # biblioteca Arduboy2 6.0.0 (BSD-3), pelo arduino-cli 1.5.1. O autor nao publicou .hex no repositorio (so o Makefile, # que pede o pacote arduboy:avr); servimos este build, com a placa arduino:avr:leonardo, cujo fonte completo # hospedamos junto: o jogo no commit (sem os dois executaveis de Linux e o GEMINI.md do repositorio), o Arduboy2, # o nucleo AVR e este script. O codigo do jogo entra sem alteracoes. Dois builds seguidos dao o mesmo sha256. # # src/FredGames.Bundler/Builds/build-stickfighter.sh # # Saida: artifacts/build/stickfighter-deb2492/stickfighter.hex set -euo pipefail CLI=1.5.1 CLI_SHA256=cb952e8c1621c95ef5f1d17831c945e3d0ec5973f89c557a7ec8feb9c4f7d4c9 COMMIT=deb2492720c4dc15427a72f9516116ada189438e GAME_SHA256=6f05ceb29d2ecf06ac83d38e820a396127b85d21e723df7fdc754d5e76db0b18 ARDUBOY2=6.0.0 ARDUBOY2_SHA256=34c5530b98167106f7fa7f5e7568e39512f689bf819b370abc9f6a212077bf06 CORE=1.8.6 here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/stickfighter-${COMMIT:0:7}" cache="$root/artifacts/build/cache" tools="$root/artifacts/tools/arduino-$CLI" mkdir -p "$cache" "$tools" cli="$cache/arduino-cli_${CLI}_macOS_ARM64.tar.gz" game="$cache/stickfighter-${COMMIT:0:7}.tar.gz" lib="$cache/Arduboy2-$ARDUBOY2.tar.gz" [ -f "$cli" ] || curl -fsSL "https://github.com/arduino/arduino-cli/releases/download/v$CLI/arduino-cli_${CLI}_macOS_ARM64.tar.gz" -o "$cli" [ -f "$game" ] || curl -fsSL "https://github.com/tonym128/stickfighter/archive/$COMMIT.tar.gz" -o "$game" [ -f "$lib" ] || curl -fsSL "https://github.com/MLXXXp/Arduboy2/archive/refs/tags/$ARDUBOY2.tar.gz" -o "$lib" echo "$CLI_SHA256 $cli" | shasum -a 256 -c - echo "$GAME_SHA256 $game" | shasum -a 256 -c - echo "$ARDUBOY2_SHA256 $lib" | shasum -a 256 -c - tar -xzf "$cli" -C "$tools" arduino-cli export ARDUINO_DIRECTORIES_DATA="$tools/data" ARDUINO_DIRECTORIES_DOWNLOADS="$tools/staging" ARDUINO_DIRECTORIES_USER="$tools/user" "$tools/arduino-cli" core update-index >/dev/null "$tools/arduino-cli" core install "arduino:avr@$CORE" >/dev/null rm -rf "$out" mkdir -p "$out/src/stickfighter" "$out/lib/Arduboy2" "$out/hex" tar -xzf "$game" -C "$out/src/stickfighter" --strip-components 1 tar -xzf "$lib" -C "$out/lib/Arduboy2" --strip-components 1 "$tools/arduino-cli" compile -b arduino:avr:leonardo --library "$out/lib/Arduboy2" \ --output-dir "$out/hex" "$out/src/stickfighter" > "$out/compile.log" tail -4 "$out/compile.log" cp "$out/hex/stickfighter.ino.hex" "$out/stickfighter.hex" shasum -a 256 "$out/stickfighter.hex"