Skip to content

Update README

Update README #188

Workflow file for this run

name: WebAssembly
on:
pull_request_target:
branches:
- master
types:
- closed
workflow_dispatch:
branches:
- master
repository_dispatch: # listening to rv32emu-prebuilt events
types: [deploy_user_wasm, deploy_system_wasm]
jobs:
wasm-system-deploy:
if: github.event.pull_request.merged == true ||
github.event_name == 'workflow_dispatch' ||
github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm'
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: install-dependencies
run: |
sudo apt-get update -q=2
sudo apt-get install -q=2 device-tree-compiler
- name: Verify if the JS or HTML files has been modified
id: changed-files
uses: tj-actions/changed-files@v46
with:
files: |
assets/wasm/html/system.html
assets/wasm/js/system-pre.js
src/em_runtime.c
# Files below may have a potential performance impact (reference from benchmark.yml)
src/devices/*.c
src/system.c
src/riscv.c
src/decode.c
src/emulate.c
src/rv32_template.c
src/rv32_constopt.c
- name: install emcc
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm') }}
run: |
git clone https://github.com/emscripten-core/emsdk -b 3.1.51
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
echo "$PATH" >> $GITHUB_PATH
shell: bash
- name: fetch artifact
run: |
make artifact
# get from rv32emu-prebuilt
wget -O build/shareware_doom_iwad.zip "https://raw.githubusercontent.com/sysprog21/rv32emu-prebuilt/doom-artifact/shareware_doom_iwad.zip"
unzip -d build/ build/shareware_doom_iwad.zip
- name: build with emcc and move application files to /tmp
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm') }}
run: |
make CC=emcc ENABLE_SYSTEM=1 ENABLE_SDL=1 INITRD_SIZE=32 -j
mkdir /tmp/rv32emu-system-demo
mv assets/wasm/html/system.html /tmp/rv32emu-system-demo/index.html
mv assets/wasm/js/coi-serviceworker.min.js /tmp/rv32emu-system-demo
mv build/rv32emu.js /tmp/rv32emu-system-demo
mv build/rv32emu.wasm /tmp/rv32emu-system-demo
mv build/rv32emu.worker.js /tmp/rv32emu-system-demo
ls -al /tmp/rv32emu-system-demo
- name: Check out the rv32emu-system-demo repo
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm') }}
uses: actions/checkout@v4
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
repository: sysprog21/rv32emu-demo
- name: Create local changes
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm') }}
run: |
mkdir -p system
mv /tmp/rv32emu-system-demo/index.html ./system
mv /tmp/rv32emu-system-demo/coi-serviceworker.min.js ./system
mv /tmp/rv32emu-system-demo/rv32emu.js ./system
mv /tmp/rv32emu-system-demo/rv32emu.wasm ./system
mv /tmp/rv32emu-system-demo/rv32emu.worker.js ./system
- name: Commit files
id: commit
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_system_wasm') }}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add system/
if git diff --cached --quiet; then
echo "committed=false" >> $GITHUB_OUTPUT
else
git commit -m "Add changes to system emulation"
echo "committed=true" >> $GITHUB_OUTPUT
fi
- name: Push changes
if: steps.commit.outputs.committed == 'true'
uses: ad-m/github-push-action@master
with:
repository: sysprog21/rv32emu-demo
github_token: ${{ secrets.RV32EMU_DEMO_TOKEN }}
branch: main
wasm-user-deploy:
needs: wasm-system-deploy # run jobs sequentially since two jobs operate on same reposity: rv32emu-demo
if: always() # ensures wasm-user-deploy runs regardless of the outcome or condition of wasm-system-deploy
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Verify if the JS or HTML or ELF executable files has been modified
id: changed-files
uses: tj-actions/changed-files@v46
with:
files: |
assets/wasm/html/user.html
assets/wasm/js/user-pre.js
build/*.elf
tools/gen-elf-list-js.py
src/em_runtime.c
# Files below may have a potential performance impact (reference from benchmark.yml)
src/riscv.c
src/decode.c
src/emulate.c
src/rv32_template.c
src/rv32_constopt.c
- name: install emcc
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_user_wasm') }}
run: |
git clone https://github.com/emscripten-core/emsdk -b 3.1.51
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
echo "$PATH" >> $GITHUB_PATH
shell: bash
- name: fetch artifact
run: |
make artifact
# get from rv32emu-prebuilt
wget -O build/shareware_doom_iwad.zip "https://raw.githubusercontent.com/sysprog21/rv32emu-prebuilt/doom-artifact/shareware_doom_iwad.zip"
unzip -d build/ build/shareware_doom_iwad.zip
- name: build with emcc and move application files to /tmp
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_user_wasm') }}
run: |
make CC=emcc ENABLE_SDL=1
mkdir /tmp/rv32emu-demo
mv assets/wasm/html/user.html /tmp/rv32emu-demo/index.html
mv assets/wasm/js/coi-serviceworker.min.js /tmp/rv32emu-demo
mv build/elf_list.js /tmp/rv32emu-demo
mv build/rv32emu.js /tmp/rv32emu-demo
mv build/rv32emu.wasm /tmp/rv32emu-demo
mv build/rv32emu.worker.js /tmp/rv32emu-demo
ls -al /tmp/rv32emu-demo
- name: Check out the rv32emu-demo repo
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_user_wasm') }}
uses: actions/checkout@v4
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
repository: sysprog21/rv32emu-demo
- name: Create local changes
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_user_wasm') }}
run: |
mv /tmp/rv32emu-demo/index.html .
mv /tmp/rv32emu-demo/coi-serviceworker.min.js .
mv /tmp/rv32emu-demo/elf_list.js .
mv /tmp/rv32emu-demo/rv32emu.js .
mv /tmp/rv32emu-demo/rv32emu.wasm .
mv /tmp/rv32emu-demo/rv32emu.worker.js .
- name: Commit files
id: commit
if: ${{ steps.changed-files.outputs.any_modified == 'true' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'repository_dispatch' && github.event.action == 'deploy_user_wasm') }}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add --all
if git diff --cached --quiet; then
echo "committed=false" >> $GITHUB_OUTPUT
else
git commit -m "Add changes to user emulation"
echo "committed=true" >> $GITHUB_OUTPUT
fi
- name: Push changes
if: steps.commit.outputs.committed == 'true'
uses: ad-m/github-push-action@master
with:
repository: sysprog21/rv32emu-demo
github_token: ${{ secrets.RV32EMU_DEMO_TOKEN }}
branch: main