@@ -269,10 +269,6 @@ SRCDIRS= @SRCDIRS@
269269# Other subdirectories
270270SUBDIRSTOO= Include Lib Misc
271271
272- # assets for Emscripten browser builds
273- WASM_ASSETS_DIR=.$(prefix)
274- WASM_STDLIB=$(WASM_ASSETS_DIR)/lib/python$(VERSION)/os.py
275-
276272# Files and directories to be distributed
277273CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in
278274DISTFILES= README.rst ChangeLog $(CONFIGFILES)
@@ -737,6 +733,9 @@ build_all: check-clean-src check-app-store-compliance $(BUILDPYTHON) platform sh
737733build_wasm: check-clean-src $(BUILDPYTHON) platform sharedmods \
738734 python-config checksharedmods
739735
736+ .PHONY: build_emscripten
737+ build_emscripten: build_wasm web_example
738+
740739# Check that the source is clean when building out of source.
741740.PHONY: check-clean-src
742741check-clean-src:
@@ -1016,23 +1015,38 @@ $(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS)
10161015 else true; \
10171016 fi
10181017
1019- # wasm32-emscripten browser build
1020- # wasm assets directory is relative to current build dir, e.g. "./usr/local".
1021- # --preload-file turns a relative asset path into an absolute path.
1018+ # wasm32-emscripten browser web example
1019+
1020+ WEBEX_DIR=$(srcdir)/Tools/wasm/emscripten/web_example/
1021+ web_example/python.html: $(WEBEX_DIR)/python.html
1022+ @mkdir -p web_example
1023+ @cp $< $@
1024+
1025+ web_example/python.worker.mjs: $(WEBEX_DIR)/python.worker.mjs
1026+ @mkdir -p web_example
1027+ @cp $< $@
10221028
1023- .PHONY: wasm_stdlib
1024- wasm_stdlib: $(WASM_STDLIB)
1025- $(WASM_STDLIB): $(srcdir)/Lib/*.py $(srcdir)/Lib/*/*.py \
1026- $(srcdir)/Tools/wasm/wasm_assets.py \
1029+ web_example/server.py: $(WEBEX_DIR)/server.py
1030+ @mkdir -p web_example
1031+ @cp $< $@
1032+
1033+ WEB_STDLIB=web_example/python$(VERSION)$(ABI_THREAD).zip
1034+ $(WEB_STDLIB): $(srcdir)/Lib/*.py $(srcdir)/Lib/*/*.py \
1035+ $(WEBEX_DIR)/wasm_assets.py \
10271036 Makefile pybuilddir.txt Modules/Setup.local
1028- $(PYTHON_FOR_BUILD) $(srcdir)/Tools/wasm /wasm_assets.py \
1029- --buildroot . --prefix $(prefix)
1037+ $(PYTHON_FOR_BUILD) $(WEBEX_DIR) /wasm_assets.py \
1038+ --buildroot . --prefix $(prefix) -o $@
10301039
1031- python.html: $(srcdir)/Tools/wasm/python.html python.worker.js
1032- @cp $(srcdir)/Tools/wasm/python.html $@
1040+ web_example/python.mjs web_example/python.wasm: $(BUILDPYTHON)
1041+ @if test $(HOST_GNU_TYPE) != 'wasm32-unknown-emscripten' ; then \
1042+ echo "Can only build web_example when target is Emscripten" ;\
1043+ exit 1 ;\
1044+ fi
1045+ cp python.mjs web_example/python.mjs
1046+ cp python.wasm web_example/python.wasm
10331047
1034- python.worker.js: $(srcdir)/Tools/wasm/python.worker.js
1035- @cp $(srcdir)/Tools/wasm/ python.worker.js $@
1048+ .PHONY: web_example
1049+ web_example: web_example/python.mjs web_example/ python.worker.mjs web_example/python.html web_example/server.py $(WEB_STDLIB)
10361050
10371051############################################################################
10381052# Header files
@@ -3053,8 +3067,7 @@ clean-retain-profile: pycremoval
30533067 find build -name '*.py[co]' -exec rm -f {} ';' || true
30543068 -rm -f pybuilddir.txt
30553069 -rm -f _bootstrap_python
3056- -rm -f python.html python*.js python.data python*.symbols python*.map
3057- -rm -f $(WASM_STDLIB)
3070+ -rm -rf web_example python.mjs python.wasm python*.symbols python*.map
30583071 -rm -f Programs/_testembed Programs/_freeze_module
30593072 -rm -rf Python/deepfreeze
30603073 -rm -f Python/frozen_modules/*.h
0 commit comments