From 9311f9986fb133192e8083dcfde16b3341d41011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Kov=C3=A1cs?= Date: Sat, 19 Oct 2024 23:57:20 +0200 Subject: [PATCH] Improve qmake script to report status in WebAssembly --- XaoS.pro | 1 + tools/set-document-title | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100755 tools/set-document-title diff --git a/XaoS.pro b/XaoS.pro index 7704c641..bbfae47e 100644 --- a/XaoS.pro +++ b/XaoS.pro @@ -88,6 +88,7 @@ wasm{ QMAKE_LFLAGS += --preload-file $$PWD/catalogs@$$DATAPATH/catalogs QMAKE_LFLAGS += --preload-file $$PWD/tutorial@$$DATAPATH/tutorial QMAKE_LFLAGS += -sASYNCIFY -Os # This can help avoiding to get the web application hang when the user presses "s". + QMAKE_POST_LINK = $$PWD/tools/set-document-title $$PWD/bin } executable.files = bin/xaos executable.path = $$PREFIX/bin diff --git a/tools/set-document-title b/tools/set-document-title new file mode 100755 index 00000000..bbac39df --- /dev/null +++ b/tools/set-document-title @@ -0,0 +1,24 @@ +#!/bin/bash + +# This script sets the document title for the WebAssembly version in xaos.js. + +set -e + +if [ "$1" = "" ]; then + echo "Usage: $0 [bin-folder]" + exit 1 + fi + +test "$1/xaos.js" || { + echo "The file $1/xaos.js is missing." + exit 2 + } + +# This will not work on macOS, FIXME: +sed -i 's/Module\["print"\]/\ + function mymessage(t) {\ + let statustext = "STATUS: ";\ + if (t.startsWith(statustext)) document.title = t.substring(statustext.length);\ + }\ +/' "$1/xaos.js" +# For a workaround on macOS, see https://stackoverflow.com/questions/12696125/sed-edit-file-in-place