#!/usr/bin/env bash # Compila o Xeonjia: Ice Adventures (deepdaikon, GPL-3.0-or-later; gitlab.com/deepdaikon/Xeonjia, Flutter + Flame) # para a web com o Flutter 3.47.1 oficial (flutter-web/env.sh instala em artifacts/tools/flutter), em dart2js + # CanvasKit completo auto-hospedado (sem CDN do Google, sem service worker). # # src/FredGames.Bundler/Builds/build-xeonjia.sh # # Mudancas no jogo (xeonjia/xeonjia-fredygames.patch + xeonjia/sounds.py): # - sem links para fora: o menu Info perde Site, Doacao, Traducao, E-mail, Bugs, Codigo e Licenca (so Creditos, Versao # e as licencas de terceiros ficam), o pedido de doacao do final do jogo e o NPC da casa pos-jogo que cobra # doacao saem (hideDonationInfo/hideDonationWorker = true, o NPC fala outra fala que o jogo ja tem) e o pacote # url_launcher sai do pubspec (pubspec.lock acompanha: a build usa pub get --enforce-lockfile); # - na web as dicas de tecla mostram o teclado (X, Q, E, R), como no desktop; # - 7 efeitos sonoros (collision, damage, dialog, explosion, money, punch, snowball) sem credito de origem no # repositorio do autor sao trocados por sons nossos, sintetizados e dedicados ao dominio publico (CC0) por # xeonjia/sounds.py + o wav2ogg do projeto (artifacts/tools/pygame-music/wav2ogg, ver Builds/pygame-music/). # A pasta web/ do projeto (PWA, manifest, icones, service worker) e trocada pelas pecas de flutter-web/. # # O fonte do autor vem por git no commit pinado (o GitLab nao serve tarball a robos); o tar.gz do fonte # (git archive, gzip -n -9) e o que vai ao lado do jogo. # # Saida: artifacts/build/xeonjia-/{xeonjia-web.tar.gz, xeonjia-.tar.gz, SHA256SUMS}, conferidos pelo # bundle.yaml do jogo. set -euo pipefail COMMIT=bd4103e3981568978b302c40dd87897d1492ca68 SRC_SHA256=34575b04003dfc567cf42e699228fdc5d2edd6d5a29ace67f29900d80870e7c4 here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/xeonjia-${COMMIT:0:7}" cache="$root/artifacts/build/cache" wav2ogg="$root/artifacts/tools/pygame-music/wav2ogg" mkdir -p "$cache" [ -x "$wav2ogg" ] || { echo "Falta $wav2ogg (compilar Builds/pygame-music/wav2ogg.c, ver o README la)." >&2; exit 1; } # shellcheck source=flutter-web/env.sh source "$here/flutter-web/env.sh" if [ ! -f "$cache/xeonjia-${COMMIT:0:7}.tar.gz" ]; then rm -rf "$cache/xeonjia-git" mkdir -p "$cache/xeonjia-git" git -C "$cache/xeonjia-git" init -q git -C "$cache/xeonjia-git" fetch -q --depth 1 https://gitlab.com/deepdaikon/Xeonjia.git "$COMMIT" git -C "$cache/xeonjia-git" -c advice.detachedHead=false checkout -q FETCH_HEAD [ "$(git -C "$cache/xeonjia-git" rev-parse HEAD)" = "$COMMIT" ] git -C "$cache/xeonjia-git" archive --format=tar --prefix="xeonjia-${COMMIT:0:7}/" HEAD | gzip -n -9 \ > "$cache/xeonjia-${COMMIT:0:7}.tar.gz.partial" mv "$cache/xeonjia-${COMMIT:0:7}.tar.gz.partial" "$cache/xeonjia-${COMMIT:0:7}.tar.gz" rm -rf "$cache/xeonjia-git" fi echo "$SRC_SHA256 $cache/xeonjia-${COMMIT:0:7}.tar.gz" | shasum -a 256 -c - rm -rf "$out" mkdir -p "$out/project" tar -xzf "$cache/xeonjia-${COMMIT:0:7}.tar.gz" -C "$out/project" --strip-components 1 cd "$out/project" patch -s -E -p1 < "$here/xeonjia/xeonjia-fredygames.patch" python3 -I "$here/xeonjia/sounds.py" assets/audio/sfx "$wav2ogg" rm -rf web mkdir web cp "$here/flutter-web/flutter_bootstrap.js" web/flutter_bootstrap.js cp "$here/flutter-web/index.html.in" web/index.html flutter pub get --enforce-lockfile > "$out/pub-get.log" 2>&1 || { tail -30 "$out/pub-get.log" >&2; exit 1; } flutter build web --release --no-web-resources-cdn --no-source-maps --no-wasm-dry-run > "$out/build.log" 2>&1 || { tail -40 "$out/build.log" >&2; exit 1; } "$here/flutter-web/post.sh" build/web "$out/web" xeonjia "Xeonjia" '#000000' '#ffffff' ( cd "$out" && find web -type f | LC_ALL=C sort > "$out/web-files.txt" ) ( cd "$out" && COPYFILE_DISABLE=1 tar --format=ustar --uid 0 --gid 0 --uname root --gname root -n \ -cf - -T "$out/web-files.txt" ) | gzip -n -9 > "$out/xeonjia-web.tar.gz" cp "$cache/xeonjia-${COMMIT:0:7}.tar.gz" "$out/xeonjia-${COMMIT:0:7}.tar.gz" ( cd "$out" && shasum -a 256 xeonjia-web.tar.gz xeonjia-${COMMIT:0:7}.tar.gz && cd web && find . -type f -print0 | LC_ALL=C sort -z | xargs -0 shasum -a 256 ) > "$out/SHA256SUMS" head -2 "$out/SHA256SUMS" du -sh "$out/web"