Skip to content

Commit 1b011f2

Browse files
authored
Merge pull request #23 from iPlug2/add-wasm-target
Add WASM target support to TemplateProject
2 parents bfc8832 + e4c9204 commit 1b011f2

26 files changed

Lines changed: 522 additions & 486 deletions

.github/workflows/build-cmake.yml

Lines changed: 80 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ on:
3030
description: 'Include WAM/Emscripten build'
3131
type: boolean
3232
default: false
33+
wasm:
34+
description: 'Include WASM/Emscripten build'
35+
type: boolean
36+
default: false
3337
universal:
3438
description: 'Include macOS Universal build (arm64+x86_64)'
3539
type: boolean
@@ -66,6 +70,7 @@ jobs:
6670
all_generators: ${{ steps.parse.outputs.all_generators }}
6771
ios: ${{ steps.parse.outputs.ios }}
6872
wam: ${{ steps.parse.outputs.wam }}
73+
wasm: ${{ steps.parse.outputs.wasm }}
6974
universal: ${{ steps.parse.outputs.universal }}
7075
backends: ${{ steps.parse.outputs.backends }}
7176
arm64ec: ${{ steps.parse.outputs.arm64ec }}
@@ -86,13 +91,15 @@ jobs:
8691
echo "all_generators=true" >> $GITHUB_OUTPUT
8792
echo "ios=true" >> $GITHUB_OUTPUT
8893
echo "wam=true" >> $GITHUB_OUTPUT
94+
echo "wasm=true" >> $GITHUB_OUTPUT
8995
echo "universal=true" >> $GITHUB_OUTPUT
9096
echo "backends=true" >> $GITHUB_OUTPUT
9197
echo "arm64ec=true" >> $GITHUB_OUTPUT
9298
else
9399
[[ "$COMMENT" == *"/ci all-generators"* || "$COMMENT" == *"/ci generators"* ]] && echo "all_generators=true" >> $GITHUB_OUTPUT || echo "all_generators=false" >> $GITHUB_OUTPUT
94100
[[ "$COMMENT" == *"/ci ios"* ]] && echo "ios=true" >> $GITHUB_OUTPUT || echo "ios=false" >> $GITHUB_OUTPUT
95101
[[ "$COMMENT" == *"/ci wam"* ]] && echo "wam=true" >> $GITHUB_OUTPUT || echo "wam=false" >> $GITHUB_OUTPUT
102+
[[ "$COMMENT" == *"/ci wasm"* ]] && echo "wasm=true" >> $GITHUB_OUTPUT || echo "wasm=false" >> $GITHUB_OUTPUT
96103
[[ "$COMMENT" == *"/ci universal"* ]] && echo "universal=true" >> $GITHUB_OUTPUT || echo "universal=false" >> $GITHUB_OUTPUT
97104
[[ "$COMMENT" == *"/ci backends"* ]] && echo "backends=true" >> $GITHUB_OUTPUT || echo "backends=false" >> $GITHUB_OUTPUT
98105
[[ "$COMMENT" == *"/ci arm64ec"* ]] && echo "arm64ec=true" >> $GITHUB_OUTPUT || echo "arm64ec=false" >> $GITHUB_OUTPUT
@@ -102,6 +109,7 @@ jobs:
102109
echo "all_generators=${{ inputs.all_generators }}" >> $GITHUB_OUTPUT
103110
echo "ios=${{ inputs.ios }}" >> $GITHUB_OUTPUT
104111
echo "wam=${{ inputs.wam }}" >> $GITHUB_OUTPUT
112+
echo "wasm=${{ inputs.wasm }}" >> $GITHUB_OUTPUT
105113
echo "universal=${{ inputs.universal }}" >> $GITHUB_OUTPUT
106114
echo "backends=${{ inputs.backends }}" >> $GITHUB_OUTPUT
107115
echo "arm64ec=${{ inputs.arm64ec }}" >> $GITHUB_OUTPUT
@@ -111,6 +119,7 @@ jobs:
111119
echo "all_generators=false" >> $GITHUB_OUTPUT
112120
echo "ios=false" >> $GITHUB_OUTPUT
113121
echo "wam=false" >> $GITHUB_OUTPUT
122+
echo "wasm=false" >> $GITHUB_OUTPUT
114123
echo "universal=false" >> $GITHUB_OUTPUT
115124
echo "backends=false" >> $GITHUB_OUTPUT
116125
echo "arm64ec=false" >> $GITHUB_OUTPUT
@@ -700,21 +709,85 @@ jobs:
700709
./download-iplug-sdks.sh
701710
702711
- name: CMake Configure
703-
run: cmake --preset=wam
712+
run: cmake --preset=web
704713

705714
- name: Build WAM
706-
run: cmake --build --preset=wam
715+
run: cmake --build --preset=web --target ${{env.PROJECT_NAME}}-web-dist
707716

708717
- name: Verify WAM Output
709718
run: |
710-
test -f build/wam/out/${{env.PROJECT_NAME}}/index.html
711-
test -f build/wam/out/${{env.PROJECT_NAME}}/scripts/${{env.PROJECT_NAME}}-wam.js
712-
test -f build/wam/out/${{env.PROJECT_NAME}}/scripts/${{env.PROJECT_NAME}}-web.js
713-
test -f build/wam/out/${{env.PROJECT_NAME}}/scripts/${{env.PROJECT_NAME}}-web.wasm
719+
test -f build/web/out/${{env.PROJECT_NAME}}/index.html
720+
test -f build/web/out/${{env.PROJECT_NAME}}/scripts/${{env.PROJECT_NAME}}-wam.js
721+
test -f build/web/out/${{env.PROJECT_NAME}}/scripts/${{env.PROJECT_NAME}}-web.js
722+
test -f build/web/out/${{env.PROJECT_NAME}}/scripts/${{env.PROJECT_NAME}}-web.wasm
714723
echo "WAM distribution verified"
715724
716725
- name: Upload WAM Artifact
717726
uses: actions/upload-artifact@v4
718727
with:
719728
name: ${{env.PROJECT_NAME}}-wam
720-
path: build/wam/out/${{env.PROJECT_NAME}}
729+
path: build/web/out/${{env.PROJECT_NAME}}
730+
731+
# ==========================================================================
732+
# Emscripten - WASM Build - Optional: /ci wasm
733+
# ==========================================================================
734+
emscripten-wasm:
735+
name: WASM (Emscripten)
736+
needs: parse-commands
737+
if: needs.parse-commands.outputs.wasm == 'true'
738+
runs-on: ubuntu-latest
739+
steps:
740+
- name: Checkout
741+
uses: actions/checkout@v4
742+
with:
743+
ref: ${{ needs.parse-commands.outputs.pr_sha || github.sha }}
744+
submodules: recursive
745+
746+
- name: Setup Python
747+
uses: actions/setup-python@v5
748+
with:
749+
python-version: '3.x'
750+
751+
- name: Setup Emscripten
752+
uses: mymindstorm/setup-emsdk@v14
753+
754+
- name: Install Ninja
755+
run: sudo apt-get install -y ninja-build
756+
757+
- name: Cache IPlug SDKs
758+
id: cache-sdks
759+
uses: actions/cache@v4
760+
with:
761+
path: |
762+
iPlug2/Dependencies/IPlug/VST3_SDK
763+
iPlug2/Dependencies/IPlug/CLAP_SDK
764+
iPlug2/Dependencies/IPlug/CLAP_HELPERS
765+
key: iplug-sdks-${{ hashFiles('iPlug2/Dependencies/IPlug/download-iplug-sdks.sh') }}
766+
767+
- name: Get SDKs
768+
if: steps.cache-sdks.outputs.cache-hit != 'true'
769+
run: |
770+
cd iPlug2/Dependencies/IPlug
771+
./download-iplug-sdks.sh
772+
773+
- name: CMake Configure
774+
run: cmake --preset=web
775+
776+
- name: Build WASM
777+
run: cmake --build --preset=web --target ${{env.PROJECT_NAME}}-wasm-dist
778+
779+
- name: Verify WASM Output
780+
run: |
781+
test -f build/web/out/${{env.PROJECT_NAME}}/index.html
782+
test -f build/web/out/${{env.PROJECT_NAME}}/scripts/${{env.PROJECT_NAME}}-dsp.js
783+
test -f build/web/out/${{env.PROJECT_NAME}}/scripts/${{env.PROJECT_NAME}}-bundle.js
784+
test -f build/web/out/${{env.PROJECT_NAME}}/scripts/${{env.PROJECT_NAME}}-processor.js
785+
test -f build/web/out/${{env.PROJECT_NAME}}/styles/style.css
786+
echo "WASM distribution verified"
787+
788+
- name: Upload WASM Artifact
789+
uses: actions/upload-artifact@v4
790+
with:
791+
name: ${{env.PROJECT_NAME}}-wasm-cmake
792+
path: build/web/out/
793+
if-no-files-found: warn

.github/workflows/build-wam.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

.github/workflows/build-wasm.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Build Wasm
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
build_system:
7+
description: 'Build system to use'
8+
type: choice
9+
options:
10+
- makefile
11+
- cmake
12+
- both
13+
default: makefile
14+
15+
env:
16+
PROJECT_NAME: TemplateProject
17+
18+
jobs:
19+
build-makefile:
20+
name: Build-Wasm (Makefile)
21+
if: inputs.build_system != 'cmake'
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Check out repository
26+
uses: actions/checkout@v4
27+
with:
28+
submodules: recursive
29+
persist-credentials: false
30+
31+
- name: Setup Python 3
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: '3.x'
35+
36+
- name: Setup Emscripten
37+
uses: mymindstorm/setup-emsdk@v14
38+
with:
39+
actions-cache-folder: 'emsdk-cache'
40+
41+
- name: Build Wasm
42+
run: |
43+
cd ${{env.PROJECT_NAME}}/scripts
44+
./makedist-wasm.sh off
45+
46+
- name: Verify WASM Output
47+
run: |
48+
test -f ${{env.PROJECT_NAME}}/build-web-wasm/index.html
49+
test -f ${{env.PROJECT_NAME}}/build-web-wasm/scripts/${{env.PROJECT_NAME}}-dsp.js
50+
test -f ${{env.PROJECT_NAME}}/build-web-wasm/scripts/${{env.PROJECT_NAME}}-bundle.js
51+
test -f ${{env.PROJECT_NAME}}/build-web-wasm/scripts/${{env.PROJECT_NAME}}-processor.js
52+
echo "WASM distribution verified"
53+
54+
- name: Upload artifact
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: ${{env.PROJECT_NAME}}-wasm
58+
path: ${{env.PROJECT_NAME}}/build-web-wasm
59+
60+
- name: Publish to pages
61+
uses: JamesIves/github-pages-deploy-action@v4
62+
with:
63+
token: ${{secrets.GITHUB_TOKEN}}
64+
branch: gh-pages
65+
folder: ${{env.PROJECT_NAME}}/build-web-wasm
66+
67+
build-cmake:
68+
name: Build-Wasm (CMake)
69+
if: inputs.build_system != 'makefile'
70+
runs-on: ubuntu-latest
71+
72+
steps:
73+
- name: Check out repository
74+
uses: actions/checkout@v4
75+
with:
76+
submodules: recursive
77+
persist-credentials: false
78+
79+
- name: Setup Python 3
80+
uses: actions/setup-python@v5
81+
with:
82+
python-version: '3.x'
83+
84+
- name: Setup Emscripten
85+
uses: mymindstorm/setup-emsdk@v14
86+
with:
87+
actions-cache-folder: 'emsdk-cache'
88+
89+
- name: Install Ninja
90+
run: sudo apt-get install -y ninja-build
91+
92+
- name: Configure CMake
93+
run: cmake --preset web
94+
95+
- name: Build
96+
run: cmake --build --preset web --target ${{env.PROJECT_NAME}}-wasm-dist
97+
98+
- name: Verify WASM Output
99+
run: |
100+
test -f build/web/out/${{env.PROJECT_NAME}}/index.html
101+
test -f build/web/out/${{env.PROJECT_NAME}}/scripts/${{env.PROJECT_NAME}}-dsp.js
102+
test -f build/web/out/${{env.PROJECT_NAME}}/scripts/${{env.PROJECT_NAME}}-bundle.js
103+
test -f build/web/out/${{env.PROJECT_NAME}}/scripts/${{env.PROJECT_NAME}}-processor.js
104+
test -f build/web/out/${{env.PROJECT_NAME}}/styles/style.css
105+
echo "WASM distribution verified"
106+
107+
- name: Upload artifact
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: ${{env.PROJECT_NAME}}-wasm-cmake
111+
path: build/web/out/
112+
if-no-files-found: warn

.vscode/tasks.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,10 @@
6060
"Debug",
6161
"SYMROOT=$HOME/Library/Developer/Xcode/DerivedData"
6262
],
63-
"group": "build"
64-
},
65-
{
66-
"label": "build WAM",
67-
"type": "shell",
68-
"command": "${workspaceFolder}/TemplateProject/scripts/makedist-web.sh container",
69-
"args": [],
7063
"group": {
7164
"kind": "build",
7265
"isDefault": true
73-
},
66+
}
7467
}
7568
]
7669
}

CMakePresets.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@
166166
}
167167
},
168168
{
169-
"name": "wam",
170-
"displayName": "WAM (Emscripten)",
171-
"description": "Web Audio Module build with Emscripten/WebAssembly",
169+
"name": "web",
170+
"displayName": "Web (Emscripten)",
171+
"description": "Web build with Emscripten/WebAssembly (WAM + WASM)",
172172
"inherits": "base",
173173
"generator": "Ninja",
174174
"toolchainFile": "$env{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake",
@@ -247,8 +247,8 @@
247247
"configuration": "Release"
248248
},
249249
{
250-
"name": "wam",
251-
"configurePreset": "wam"
250+
"name": "web",
251+
"configurePreset": "web"
252252
}
253253
]
254254
}

TemplateProject/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
cmake_minimum_required(VERSION 3.25)
22
project(TemplateProject VERSION 1.0.0)
33

4-
set(IPLUG2_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../iPlug2 CACHE PATH "iPlug2 root directory")
4+
if(NOT DEFINED IPLUG2_DIR)
5+
set(IPLUG2_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../iPlug2" CACHE PATH "iPlug2 root directory")
6+
endif()
7+
58
include(${IPLUG2_DIR}/iPlug2.cmake)
69

710
find_package(iPlug2 REQUIRED)
@@ -14,5 +17,5 @@ iplug_add_plugin(${PROJECT_NAME}
1417
RESOURCES
1518
resources/fonts/Roboto-Regular.ttf
1619
FORMATS
17-
MINIMAL_PLUGINS APP
20+
MINIMAL_PLUGINS APP WASM
1821
)

0 commit comments

Comments
 (0)