Add serve-wasm.py to the emscripten bundle

This commit is contained in:
Tamás Bálint Misius
2025-07-26 21:57:21 +02:00
parent e2b1d99572
commit 968b9e1d11
2 changed files with 11 additions and 7 deletions

3
.github/build.sh vendored
View File

@@ -521,7 +521,8 @@ if [[ $BSH_HOST_PLATFORM == darwin ]]; then
exit 1
fi
elif [[ $PACKAGE_MODE == emscripten ]]; then
tar cvf $ASSET_PATH $APP_EXE.js $APP_EXE.wasm
cp resources/serve-wasm.py .
tar cvf $ASSET_PATH $APP_EXE.js $APP_EXE.wasm serve-wasm.py
elif [[ $PACKAGE_MODE == appimage ]]; then
# so far this can only happen with $BSH_HOST_PLATFORM-$BSH_HOST_LIBC == linux-gnu, but this may change later
case $BSH_HOST_ARCH in

15
resources/serve-wasm.template.py Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#!/usr/bin/python
from OpenSSL import crypto
import http.server
import json
@@ -7,12 +9,13 @@ import ssl
import sys
import time
(
script,
build_root,
) = sys.argv
os.chdir(build_root)
if len(sys.argv) >= 2:
# chdir if invoked through meson; assume that we're in the correct dir already otherwise
(
script,
build_root,
) = sys.argv
os.chdir(build_root)
HTTP_HOST = '127.0.0.1'
HTTP_PORT = 8000