#!/usr/bin/env bash # Compila o Super Mango (jonathanperis/super-mango-editor, MIT; C11 + raylib 6.2 + Emscripten) do commit 615c748 para o # fredygames.com, com o Emscripten 6.0.10 (o repositorio fixa o 6.0.13 no CI; EMSCRIPTEN_VERSION=6.0.10 troca so a conferencia). # # src/FredGames.Bundler/Builds/build-super-mango.sh # precisa de cmake, make e python3 # # So o jogo: o alvo "make out/super-mango.html" (o editor de fases e o inspetor de debug nao entram; a pagina de debug tambem # nao). O repositorio ja traz a pagina da build web (web/shell.html, com CSP sem rede externa) e nao tem links para fora, entao # nao ha patch. A arte e do pacote Super Mango de JuhoSprite (CC BY 4.0), os sons sao gerados em codigo pelo proprio projeto # (tools/gen_sounds.py) e o texto usa a fonte embutida do raylib. O raylib vem do tarball do commit que vendor/raylib/manifest.json # fixa (sha256 conferido), passado ao build_raylib.py com --archive. # # Saida: artifacts/build/super-mango-615c748/super-mango-615c748-dist.tar.gz + licenses.txt set -euo pipefail COMMIT=615c748e20f28a37bc2179216bac2514cb392fc4 SHA256=20b9034f35caf2d8be37c4f605f33c478d94f9e51cbbe2797af72effb029dd02 RAYLIB=02566453880e06bec97f5b8160fa6fe1e98397ca RAYLIB_SHA256=46d2b8ab1960480d197d84e6d01620c1d920603c2970169c8964d5e6f7a1085a EMSCRIPTEN=6.0.10 here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/super-mango-${COMMIT:0:7}" cache="$root/artifacts/build/cache" if ! emcc --version 2>/dev/null | head -1 | grep -q " $EMSCRIPTEN "; then [ -f "$root/artifacts/tools/emsdk/emsdk_env.sh" ] && source "$root/artifacts/tools/emsdk/emsdk_env.sh" >/dev/null 2>&1 fi emcc --version 2>/dev/null | head -1 | grep -q " $EMSCRIPTEN " || { echo "Precisa do Emscripten $EMSCRIPTEN no PATH." >&2; exit 1; } for tool in cmake make python3; do command -v "$tool" >/dev/null || { echo "Precisa do $tool no PATH." >&2; exit 1; }; done mkdir -p "$cache" fetch() { # nome url sha256 if [ ! -f "$cache/$1" ]; then curl -fsSL --retry 4 "$2" -o "$cache/$1.partial" && mv "$cache/$1.partial" "$cache/$1" fi echo "$3 $cache/$1" | shasum -a 256 -c - >/dev/null } fetch "super-mango-${COMMIT:0:7}.tar.gz" "https://github.com/jonathanperis/super-mango-editor/archive/$COMMIT.tar.gz" "$SHA256" fetch "raylib-${RAYLIB:0:7}.tar.gz" "https://codeload.github.com/raysan5/raylib/tar.gz/$RAYLIB" "$RAYLIB_SHA256" rm -rf "$out" mkdir -p "$out/tree" "$out/dist" tar -xzf "$cache/super-mango-${COMMIT:0:7}.tar.gz" -C "$out/tree" --strip-components 1 cd "$out/tree" make out/super-mango.html EMSCRIPTEN_VERSION="$EMSCRIPTEN" RAYLIB_ARCHIVE="$cache/raylib-${RAYLIB:0:7}.tar.gz" \ -j"$(sysctl -n hw.ncpu 2>/dev/null || nproc)" > "$out/make.log" 2>&1 || { tail -30 "$out/make.log"; exit 1; } for f in super-mango.html super-mango.js super-mango.wasm super-mango.data; do cp "out/$f" "$out/dist/"; done { echo "== Super Mango (LICENSE, MIT): ver o LICENSE.txt do jogo no site" echo echo "== tomlc17 (vendor/tomlc17/LICENSE, MIT)" cat vendor/tomlc17/LICENSE echo echo "== raylib 6.2 (LICENSE, zlib)" tar -xzf "$cache/raylib-${RAYLIB:0:7}.tar.gz" -O "raylib-$RAYLIB/LICENSE" echo echo "== Emscripten (LICENSE, MIT / UIUC)" cat "$root/artifacts/tools/emsdk/upstream/emscripten/LICENSE" } > "$out/licenses.txt" find "$out/dist" -exec touch -t 202404180000 {} + ( cd "$out" && find dist -type f | LC_ALL=C sort > files.txt \ && COPYFILE_DISABLE=1 tar --format=ustar --uid 0 --gid 0 --uname root --gname root -n -cf - -T files.txt \ | gzip -n -9 > "super-mango-${COMMIT:0:7}-dist.tar.gz" && rm files.txt ) cd "$root" rm -rf "$out/tree" ls -l "$out/super-mango-${COMMIT:0:7}-dist.tar.gz" shasum -a 256 "$out/super-mango-${COMMIT:0:7}-dist.tar.gz" "$out/licenses.txt"