Skip to content

Commit

Permalink
Add CI tests in Pyodide
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed Jun 14, 2022
1 parent 0767912 commit 8ac85a0
Show file tree
Hide file tree
Showing 18 changed files with 1,987 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- emscripten-ci2
pull_request:

concurrency:
Expand Down Expand Up @@ -350,3 +351,33 @@ jobs:
CIBW_BUILD_VERBOSITY: 1
with:
package-dir: examples/namespace_package

emscripten:
name: emscripten
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
id: setup-python
with:
python-version: "3.10"
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-unknown-emscripten
- uses: actions/setup-node@v3
with:
node-version: 18
- run: pip install nox
- uses: actions/cache@v3
id: cache
with:
path: |
emscripten/pyodide
key: ${{ hashFiles('emscripten/*') }} - ${{ hashFiles('noxfile.py') }} - ${{ steps.setup-python.outputs.python-path }}
- uses: Swatinem/rust-cache@v1
with:
key: cargo-emscripten-wasm32
- name: Test
run: nox -s test-emscripten
6 changes: 6 additions & 0 deletions emscripten/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
builddir
main.*
!main.c
pybuilddir.txt
pyodide
node_modules
16 changes: 16 additions & 0 deletions emscripten/_sysconfigdata__emscripten_wasm32-emscripten.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# system configuration generated and used by the sysconfig module
build_time_vars = {
"ABIFLAGS": "",
"AR": "/src/emsdk/emsdk/upstream/emscripten/emar",
"ARFLAGS": "rcs",
"BLDSHARED": "emcc -sSIDE_MODULE=1",
"CC": "emcc -I../../emscripten",
"CCSHARED": "",
"CFLAGS": "-Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g "
"-fwrapv -O3 -Wall -O2 -g0 -fPIC",
"EXT_SUFFIX": ".cpython-310-wasm32-emscripten.so",
"HOST_GNU_TYPE": "wasm32-unknown-emscripten",
"LDSHARED": "emcc -sSIDE_MODULE=1",
"Py_DEBUG": "0",
"py_version_nodot": "310",
}
42 changes: 42 additions & 0 deletions emscripten/emcc_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
import subprocess
import sys


def update_args(args):
# https://github.com/emscripten-core/emscripten/issues/17109
args.insert(0, "-Wl,--no-whole-archive")

# Remove -s ASSERTIONS=1
# See https://github.com/rust-lang/rust/pull/97928
for i in range(len(args)):
if "ASSERTIONS" in args[i]:
del args[i - 1 : i + 1]
break

# remove -lc. Not sure if it makes a difference but -lc doesn't belong here.
# https://github.com/emscripten-core/emscripten/issues/17191
for i in reversed(range(len(args))):
if args[i] == "c" and args[i - 1] == "-l":
del args[i - 1 : i + 1]

# Prevent a bunch of errors caused by buggy behavior in
# `esmcripten/tools/building.py:lld_flags_for_executable` REQUIRED_EXPORTS
# contains symbols that should come from the main module.
# https://github.com/emscripten-core/emscripten/issues/17202
args.append("-sERROR_ON_UNDEFINED_SYMBOLS=0")
# Seems like --no-entry should be implied by SIDE_MODULE but apparently it
# isn't?
args.append("-Wl,--no-entry")

return args


def main(args):
args = update_args(args)
return subprocess.call(["emcc"] + args)


if __name__ == "__main__":
args = sys.argv[1:]
sys.exit(main(args))
Loading

0 comments on commit 8ac85a0

Please sign in to comment.