Skip to content

bpo-40280: Add build target for Emscripten/node.js #30495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
10 changes: 9 additions & 1 deletion Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ $(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS)
# wasm32-emscripten build
# wasm assets directory is relative to current build dir, e.g. "./usr/local".
# --preload-file turns a relative asset path into an absolute path.
# With node.js, we use the rawfs which is much easier for tests
WASM_ASSETS_DIR=".$(prefix)"
WASM_STDLIB="$(WASM_ASSETS_DIR)/local/lib/python$(VERSION)/os.py"

Expand All @@ -844,7 +845,14 @@ $(WASM_STDLIB): $(srcdir)/Lib/*.py $(srcdir)/Lib/*/*.py \
python.html: Programs/python.o $(LIBRARY_DEPS) $(WASM_STDLIB)
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o \
$(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) \
-s ASSERTIONS=1 --preload-file $(WASM_ASSETS_DIR)
-s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 \
--preload-file $(WASM_ASSETS_DIR)

python.js: Programs/python.o $(LIBRARY_DEPS) $(WASM_STDLIB)
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o \
$(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) \
-s ASSERTIONS=1 -s NODERAWFS=1 -s ALLOW_MEMORY_GROWTH=1 \
-s EXIT_RUNTIME=1

##########################################################################
# Build static libmpdec.a
Expand Down
19 changes: 18 additions & 1 deletion Tools/wasm/wasm_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,21 @@
"unittest/test/",
)

SKIP_COMPILE = (
"test/bad_coding.py",
"test/bad_coding2.py",
"test/badsyntax_3131.py",
"test/badsyntax_future3.py",
"test/badsyntax_future4.py",
"test/badsyntax_future5.py",
"test/badsyntax_future6.py",
"test/badsyntax_future7.py",
"test/badsyntax_future8.py",
"test/badsyntax_future9.py",
"test/badsyntax_future10.py",
"test/badsyntax_pep3120.py",
)


OMIT_ABSOLUTE = {SRCDIR_LIB / name for name in OMIT_FILES}
OMIT_SUBDIRS_ABSOLUTE = tuple(str(SRCDIR_LIB / name) for name in OMIT_SUBDIRS)
Expand All @@ -124,7 +139,9 @@ def create_stdlib_zip(
continue
if entry in OMIT_ABSOLUTE:
continue
if entry.name.endswith(".py") or entry.is_dir():
if entry in SKIP_COMPILE:
pzf.write(entry)
elif entry.name.endswith(".py") or entry.is_dir():
# writepy() writes .pyc files (bytecode).
pzf.writepy(entry, filterfunc=filterfunc)
for entry in sysconfig_data:
Expand Down