Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,49 @@ jobs:
name: emlearn-micropython-build-macos
path: dist

build-webassembly:
runs-on: ubuntu-latest
env:
MPY_DIR: ./micropython
MICROPYTHON_BIN: ./micropython/ports/unix/build-nomodules/micropython
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install OS dependencies
run: sudo add-apt-repository universe
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: actions/checkout@v4
with:
repository: jonnor/micropython
path: micropython
ref: webassembly-extra-cflags
- name: Install Python dependencies
run: pip install -r requirements.txt
- name: Setup MicroPython
working-directory: micropython
run: |
npm install terser
git clone https://github.com/emscripten-core/emsdk.git
(cd emsdk && ./emsdk install 4.0.21 && ./emsdk activate 4.0.21)
make -C mpy-cross CFLAGS_EXTRA=-Wno-error
- name: Build Webassembly
run: |
source ${MPY_DIR}/emsdk/emsdk_env.sh
make -C ${MPY_DIR}/ports/webassembly submodules
make webassembly V=1
- name: Archive dist artifacts
uses: actions/upload-artifact@v4
with:
name: emlearn-micropython-build-webassembly
path: dist

deploy-pages:
permissions:
contents: write
needs: [build-linux, build-arm, build-esp32, build-macos, build-riscv]
needs: [build-linux, build-arm, build-esp32, build-macos, build-riscv, build-webassembly]
runs-on: ubuntu-latest

steps:
Expand Down
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ PORT_BUILD_DIR=$(MPY_DIR)/ports/$(PORT)/build-$(BOARD)
PORT_DIST_DIR=./dist/ports/$(PORT)/$(BOARD)

UNIX_MICROPYTHON = ./dist/ports/unix/micropython

WEBASSEMBLY_MICROPYTHON = ./dist/ports/webassembly/micropython.mjs

# List of modules
MODULES = emlearn_trees \
Expand Down Expand Up @@ -72,6 +72,17 @@ $(UNIX_MICROPYTHON): $(PORT_DIR)

unix: $(UNIX_MICROPYTHON)

$(WEBASSEMBLY_MICROPYTHON): $(PORT_DIR)
emcc --version
mkdir -p $(PORT_DIR)/../webassembly
make -C $(MPY_DIR)/ports/webassembly VARIANT=standard V=1 USER_C_MODULES=$(C_MODULES_SRC_PATH) FROZEN_MANIFEST=$(MANIFEST_PATH) CFLAGS_EXTRA="-Wno-unused-function -Wno-unused-function ${CFLAGS_EXTRA}" -j4
cp $(MPY_DIR)/ports/webassembly/build-standard/micropython.mjs $@
cp $(MPY_DIR)/ports/webassembly/build-standard/micropython.wasm dist/ports/webassembly/


webassembly: $(WEBASSEMBLY_MICROPYTHON)


check_unix: $(UNIX_MICROPYTHON)
$(UNIX_MICROPYTHON) tests/test_all.py test_iir,test_fft,test_arrayutils
# TODO: enable more modules
Expand Down
Loading