#!/usr/bin/env bash # Compila German Whist (homebrew de Arduboy de Press Play On Tape, BSD-3-Clause) do commit b4651f2 de # github.com/Press-Play-On-Tape/GermanWhist, com versoes fixas: o nucleo Arduino AVR 1.8.6 (LGPL-2.1; avr-gcc 7.3.0) e as # bibliotecas Arduboy2 6.0.0 (BSD-3), pelo arduino-cli 1.5.1. O .hex publicado pelo autor nao e reproduzivel # (as versoes das bibliotecas e do nucleo que ele usou nao estao registradas); servimos este, cujo # fonte completo hospedamos junto: o jogo no commit, as bibliotecas, o nucleo AVR e este script. # # src/FredGames.Bundler/Builds/build-german-whist.sh # # Saida: artifacts/build/german-whist-b4651f2/GermanWhist.hex set -euo pipefail CLI=1.5.1 CLI_SHA256=cb952e8c1621c95ef5f1d17831c945e3d0ec5973f89c557a7ec8feb9c4f7d4c9 CORE=1.8.6 GAME_URL=https://github.com/Press-Play-On-Tape/GermanWhist/archive/b4651f281c1523ab5e8950f602e9c1e264599412.tar.gz GAME_SHA256=c8d586ad13f5fd082313dcd46d4545df954b4b3b06798b9fab86162cfb48468a SKETCH_DIR="Whist" SKETCH=Whist LIB0=("Arduboy2" "https://github.com/MLXXXp/Arduboy2/archive/refs/tags/6.0.0.tar.gz" "34c5530b98167106f7fa7f5e7568e39512f689bf819b370abc9f6a212077bf06" "Arduboy2-6.0.0.tar.gz") here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/german-whist-b4651f2" cache="$root/artifacts/build/cache" tools="$root/artifacts/tools/arduino-$CLI" fetch() { # url sha256 arquivo [ -f "$cache/$3" ] || curl -fsSL "$1" -o "$cache/$3" echo "$2 $cache/$3" | shasum -a 256 -c - >/dev/null } mkdir -p "$cache" "$tools" fetch "https://github.com/arduino/arduino-cli/releases/download/v$CLI/arduino-cli_${CLI}_macOS_ARM64.tar.gz" "$CLI_SHA256" "arduino-cli_${CLI}_macOS_ARM64.tar.gz" fetch "$GAME_URL" "$GAME_SHA256" "GermanWhist-b4651f2.tar.gz" tar -xzf "$cache/arduino-cli_${CLI}_macOS_ARM64.tar.gz" -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/repo" "$out/src/$SKETCH" "$out/lib" "$out/hex" tar -xzf "$cache/GermanWhist-b4651f2.tar.gz" -C "$out/repo" --strip-components 1 cp -R "$out/repo/$SKETCH_DIR/." "$out/src/$SKETCH/" libs=() for v in LIB0; do eval "lib=(\"\${$v[@]}\")" fetch "${lib[1]}" "${lib[2]}" "${lib[3]}" mkdir -p "$out/lib/${lib[0]}" tar -xzf "$cache/${lib[3]}" -C "$out/lib/${lib[0]}" --strip-components 1 libs+=(--library "$out/lib/${lib[0]}") done "$tools/arduino-cli" compile -b arduino:avr:leonardo "${libs[@]}" \ --output-dir "$out/hex" "$out/src/$SKETCH" >/dev/null cp "$out/hex/$SKETCH.ino.hex" "$out/GermanWhist.hex" shasum -a 256 "$out/GermanWhist.hex"