#!/usr/bin/env bash # Compila o Zoysii (deepdaikon, GPL-3.0; gitlab.com/deepdaikon/zoysii, Flutter) 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-zoysii.sh # # Mudancas no jogo (zoysii/zoysii-fredygames.patch): # - migracao do Dart 2 / Flutter 3.3 do autor para o Dart 3 / Flutter 3.47: i18n_extension 16 (+ i18n_extension_importer # para ler os .po), textTheme.caption -> bodySmall, toggleableActiveColor -> temas de checkbox/radio/switch, # useMaterial3: false (para manter o visual do autor), Platform.localeName -> PlatformDispatcher, e # pubspec.lock novo (a build usa pub get --enforce-lockfile); # - sem links para fora: a tela Info perde Doacao, Traducao, E-mail, Bugs, Codigo e Licenca (so Versao e as licencas # de terceiros ficam), o card final do modo Levels perde os botoes de doacao e o pacote url_launcher sai; # - window_manager sai (so servia ao desktop). # 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/zoysii-/{zoysii-web.tar.gz, zoysii-.tar.gz, SHA256SUMS}, conferidos pelo # bundle.yaml do jogo. set -euo pipefail COMMIT=0029b29aa27fc72f92bda95ec5d76f6916c5425a SRC_SHA256=efc18996ab96c61c51489abed46fa52b1394367a3a9317baf886d35ceaa8ea03 here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" root="$(git -C "$here" rev-parse --show-toplevel 2>/dev/null || pwd)" out="$root/artifacts/build/zoysii-${COMMIT:0:7}" cache="$root/artifacts/build/cache" mkdir -p "$cache" # shellcheck source=flutter-web/env.sh source "$here/flutter-web/env.sh" if [ ! -f "$cache/zoysii-${COMMIT:0:7}.tar.gz" ]; then rm -rf "$cache/zoysii-git" mkdir -p "$cache/zoysii-git" git -C "$cache/zoysii-git" init -q git -C "$cache/zoysii-git" fetch -q --depth 1 https://gitlab.com/deepdaikon/zoysii.git "$COMMIT" git -C "$cache/zoysii-git" -c advice.detachedHead=false checkout -q FETCH_HEAD [ "$(git -C "$cache/zoysii-git" rev-parse HEAD)" = "$COMMIT" ] git -C "$cache/zoysii-git" archive --format=tar --prefix="zoysii-${COMMIT:0:7}/" HEAD | gzip -n -9 \ > "$cache/zoysii-${COMMIT:0:7}.tar.gz.partial" mv "$cache/zoysii-${COMMIT:0:7}.tar.gz.partial" "$cache/zoysii-${COMMIT:0:7}.tar.gz" rm -rf "$cache/zoysii-git" fi echo "$SRC_SHA256 $cache/zoysii-${COMMIT:0:7}.tar.gz" | shasum -a 256 -c - rm -rf "$out" mkdir -p "$out/project" tar -xzf "$cache/zoysii-${COMMIT:0:7}.tar.gz" -C "$out/project" --strip-components 1 cd "$out/project" patch -s -E -p1 < "$here/zoysii/zoysii-fredygames.patch" # So o Flutter web: as pastas de outras plataformas saem, e web/ e trocada pelas pecas de flutter-web/. rm -rf android ios macos windows linux snap fastlane 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" zoysii "Zoysii" '#ffffff' '#244a63' ( 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/zoysii-web.tar.gz" cp "$cache/zoysii-${COMMIT:0:7}.tar.gz" "$out/zoysii-${COMMIT:0:7}.tar.gz" ( cd "$out" && shasum -a 256 zoysii-web.tar.gz zoysii-${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"