Skip to content

Commit

Permalink
Improve qmake script to report status in WebAssembly
Browse files Browse the repository at this point in the history
  • Loading branch information
kovzol committed Oct 19, 2024
1 parent 77a6a58 commit 9311f99
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions XaoS.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions tools/set-document-title
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9311f99

Please sign in to comment.