From b2029e86bc1aae339a9aadd5c7c2c669e528b2e6 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 24 Jul 2022 14:32:24 +0100 Subject: [PATCH] Add wasm-mini build target Signed-off-by: falkTX --- .github/workflows/build.yml | 72 +++++++++++++++++++++++++++++++++++++ plugins/Makefile | 15 ++++++-- src/Makefile.cardinal.mk | 11 +++++- 3 files changed, 95 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 12f374a1..529cc21d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -765,6 +765,78 @@ jobs: files: | *.zip + wasm-mini: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Set up cache + id: cache + uses: actions/cache@v2 + with: + path: | + ~/emsdk + */*.a + build/CardinalFX + build/plugins + build/rack + dpf/build + src/Rack/dep/bin + src/Rack/dep/include + src/Rack/dep/lib + src/Rack/dep/share + src/Rack/dep/jansson-2.12 + src/Rack/dep/libarchive-3.4.3 + src/Rack/dep/libsamplerate-0.1.9 + src/Rack/dep/speexdsp-SpeexDSP-1.2rc3 + src/Rack/dep/zstd-1.4.5 + key: wasm-mini-v${{ env.CACHE_VERSION }} + - name: Set up dependencies + run: | + [ -e ~/emsdk ] || git clone https://github.com/emscripten-core/emsdk.git ~/emsdk + cd ~/emsdk && ./emsdk install latest && ./emsdk activate latest + - name: Build wasm-mini cross-compiled + env: + AR: emar + CC: emcc + CXX: em++ + NM: emnm + RANLIB: emranlib + STRIP: emstrip + run: | + source ~/emsdk/emsdk_env.sh + make features + make CIBUILD=true NOPLUGINS=true STATIC_BUILD=true USE_GLES2=true -j $(nproc) + - name: Set sha8 (non-release) + if: startsWith(github.ref, 'refs/tags/') != true + id: slug1 + run: echo "::set-output name=sha8::$(echo ${{ github.sha }} | cut -c1-8)" + - name: Set sha8 (release) + if: startsWith(github.ref, 'refs/tags/') + id: slug2 + run: echo "::set-output name=sha8::$(echo ${{ github.ref_name }})" + - name: Set sha8 + id: slug + run: echo "::set-output name=sha8::$(echo ${{ steps.slug1.outputs.sha8 || steps.slug2.outputs.sha8 }})" + - name: Pack binaries + run: | + cd bin; zip -r -9 ../${{ github.event.repository.name }}-wasm-mini-${{ github.event.pull_request.number || steps.slug.outputs.sha8 }}.zip $(ls *.html *.data *.js *.wasm) + - uses: actions/upload-artifact@v2 + with: + name: ${{ github.event.repository.name }}-wasm-mini-${{ github.event.pull_request.number || steps.slug.outputs.sha8 }} + path: | + *.zip + - uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + tag_name: ${{ github.ref_name }} + name: ${{ github.ref_name }} + draft: false + prerelease: false + files: | + *.zip + win32: runs-on: ubuntu-20.04 steps: diff --git a/plugins/Makefile b/plugins/Makefile index 5b38c129..fb1b3c88 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -1134,9 +1134,14 @@ clean: ifeq ($(NOPLUGINS),true) PLUGIN_LIST = Cardinal Fundamental + +RESOURCE_FILES = \ + $(wildcard Cardinal/res/*.svg) \ + $(wildcard Fundamental/res/*.svg) \ + $(wildcard Fundamental/res/components/*.svg) \ + Fundamental/presets else PLUGIN_LIST = $(subst /plugin.json,,$(wildcard */plugin.json)) -endif UNWANTED_FILES = HetrickCV/res/illustrator - deprecated/MyModule.svg UNWANTED_FILES += $(wildcard Meander/res/*) @@ -1163,7 +1168,6 @@ RESOURCE_FILES += BaconPlugs/res/Keypunch029.json RESOURCE_FILES += BaconPlugs/res/midi/chopin RESOURCE_FILES += BaconPlugs/res/midi/debussy RESOURCE_FILES += BaconPlugs/res/midi/goldberg -RESOURCE_FILES += Cardinal/res/Miku/Miku.png RESOURCE_FILES += cf/playeroscs RESOURCE_FILES += DrumKit/res/samples RESOURCE_FILES += MindMeldModular/res/ShapeMaster/CommunityPresets @@ -1178,14 +1182,20 @@ RESOURCE_FILES += $(wildcard unless_modules/art/*.art) RESOURCE_FILES += $(wildcard unless_modules/art/svg/*/*.svg) RESOURCE_FILES += $(wildcard unless_modules/font/*.ttf) # RESOURCE_FILES += $(wildcard unless_modules/manual/*) +endif + +RESOURCE_FILES += Cardinal/res/Miku/Miku.png # MOD builds only have LV2 FX variant for now ifeq ($(MOD_BUILD),true) + LV2_RESOURCES = $(PLUGIN_LIST:%=../bin/Cardinal.lv2/resources/PluginManifests/%.json) LV2_RESOURCES += $(PLUGIN_LIST:%=../bin/CardinalFX.lv2/resources/PluginManifests/%.json) LV2_RESOURCES += $(RESOURCE_FILES:%=../bin/Cardinal.lv2/resources/%) LV2_RESOURCES += $(RESOURCE_FILES:%=../bin/CardinalFX.lv2/resources/%) + else + LV2_RESOURCES = $(PLUGIN_LIST:%=../bin/Cardinal.lv2/resources/PluginManifests/%.json) LV2_RESOURCES += $(PLUGIN_LIST:%=../bin/CardinalFX.lv2/resources/PluginManifests/%.json) LV2_RESOURCES += $(PLUGIN_LIST:%=../bin/CardinalSynth.lv2/resources/PluginManifests/%.json) @@ -1209,6 +1219,7 @@ VST3_RESOURCES += $(PLUGIN_LIST:%=../bin/CardinalSynth.vst3/Contents/Resources/P VST3_RESOURCES += $(RESOURCE_FILES:%=../bin/Cardinal.vst3/Contents/Resources/%) VST3_RESOURCES += $(RESOURCE_FILES:%=../bin/CardinalFX.vst3/Contents/Resources/%) VST3_RESOURCES += $(RESOURCE_FILES:%=../bin/CardinalSynth.vst3/Contents/Resources/%) + endif resources: $(LV2_RESOURCES) $(VST2_RESOURCES) $(VST3_RESOURCES) diff --git a/src/Makefile.cardinal.mk b/src/Makefile.cardinal.mk index b77dd6cc..efa8b365 100644 --- a/src/Makefile.cardinal.mk +++ b/src/Makefile.cardinal.mk @@ -117,8 +117,10 @@ endif # FIXME ifeq ($(WASM),true) +ifneq ($(STATIC_BUILD),true) STATIC_CARLA_PLUGIN_LIBS = -lsndfile -lopus -lFLAC -lvorbisenc -lvorbis -logg -lm endif +endif EXTRA_DEPENDENCIES = $(RACK_EXTRA_LIBS) $(CARLA_EXTRA_LIBS) EXTRA_LIBS = $(RACK_EXTRA_LIBS) $(CARLA_EXTRA_LIBS) $(STATIC_CARLA_PLUGIN_LIBS) @@ -215,8 +217,10 @@ BASE_FLAGS += -Wno-unused-variable # extra linker flags ifeq ($(WASM),true) +ifneq ($(STATIC_BUILD),true) LINK_FLAGS += --preload-file=./jsfx LINK_FLAGS += --preload-file=./lv2 +endif LINK_FLAGS += --preload-file=./resources LINK_FLAGS += -sALLOW_MEMORY_GROWTH LINK_FLAGS += -sINITIAL_MEMORY=64Mb @@ -341,7 +345,12 @@ vst3: $(VST3_RESOURCES) # -------------------------------------------------------------- # Extra rules for wasm resources -wasm_resources: $(CURDIR)/lv2 $(CURDIR)/resources +WASM_RESOURCES = $(CURDIR)/resources +ifneq ($(STATIC_BUILD),true) +WASM_RESOURCES += $(CURDIR)/lv2 +endif + +wasm_resources: $(WASM_RESOURCES) $(CURDIR)/lv2: $(LV2_RESOURCES) $(shell wget https://falktx.com/data/wasm-things-2022-08-15.tar.gz && tar xf wasm-things-2022-08-15.tar.gz)