From ea18b1a1ad6712a8071bd536da925e8a489dcefb Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 4 Jul 2022 14:18:28 +0100 Subject: [PATCH] Get all plugins to build for wasm Signed-off-by: falkTX --- Makefile.base.mk | 12 +++++++++--- Makefile.plugins.mk | 4 ++-- distrho/src/DistrhoPluginVST2.cpp | 2 +- distrho/src/jackbridge/SDLBridge.hpp | 2 ++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Makefile.base.mk b/Makefile.base.mk index 14c55d32..3156686e 100644 --- a/Makefile.base.mk +++ b/Makefile.base.mk @@ -175,20 +175,24 @@ endif endif ifeq ($(MACOS),true) + # MacOS linker flags LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip,-dead_strip_dylibs ifneq ($(SKIP_STRIPPING),true) LINK_OPTS += -Wl,-x endif + else + # Common linker flags LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-O1,--gc-sections +ifneq ($(WASM),true) +LINK_OPTS += -Wl,--as-needed ifneq ($(SKIP_STRIPPING),true) LINK_OPTS += -Wl,--strip-all endif -ifneq ($(WASM),true) -LINK_OPTS += -Wl,--as-needed endif + endif ifeq ($(SKIP_STRIPPING),true) @@ -535,6 +539,8 @@ endif ifeq ($(MACOS),true) LIB_EXT = .dylib +else ifeq ($(WASM),true) +LIB_EXT = .wasm else ifeq ($(WINDOWS),true) LIB_EXT = .dll else @@ -547,7 +553,7 @@ endif ifeq ($(MACOS),true) SHARED = -dynamiclib else ifeq ($(WASM),true) -SHARED = -sSIDE_MODULE=1 +SHARED = -sSIDE_MODULE=2 else SHARED = -shared endif diff --git a/Makefile.plugins.mk b/Makefile.plugins.mk index 619b44bc..59f91dd5 100644 --- a/Makefile.plugins.mk +++ b/Makefile.plugins.mk @@ -170,9 +170,9 @@ SYMBOLS_SHARED = -Wl,-exported_symbols_list,$(DPF_PATH)/utils/symbols/shared.exp else ifeq ($(WASM),true) SYMBOLS_LADSPA = -sEXPORTED_FUNCTIONS="['ladspa_descriptor']" SYMBOLS_DSSI = -sEXPORTED_FUNCTIONS="['ladspa_descriptor','dssi_descriptor']" -SYMBOLS_LV2DSP = -sEXPORTED_FUNCTIONS="['lv2_descriptor']" +SYMBOLS_LV2DSP = -sEXPORTED_FUNCTIONS="['lv2_descriptor','lv2_generate_ttl']" SYMBOLS_LV2UI = -sEXPORTED_FUNCTIONS="['lv2ui_descriptor']" -SYMBOLS_LV2 = -sEXPORTED_FUNCTIONS="['lv2_descriptor','lv2ui_descriptor']" +SYMBOLS_LV2 = -sEXPORTED_FUNCTIONS="['lv2_descriptor','lv2_generate_ttl','lv2ui_descriptor']" SYMBOLS_VST2 = -sEXPORTED_FUNCTIONS="['VSTPluginMain']" SYMBOLS_VST3 = -sEXPORTED_FUNCTIONS="['GetPluginFactory','ModuleEntry','ModuleExit']" SYMBOLS_SHARED = -sEXPORTED_FUNCTIONS="['createSharedPlugin']" diff --git a/distrho/src/DistrhoPluginVST2.cpp b/distrho/src/DistrhoPluginVST2.cpp index 56a3e116..b158629d 100644 --- a/distrho/src/DistrhoPluginVST2.cpp +++ b/distrho/src/DistrhoPluginVST2.cpp @@ -1665,7 +1665,7 @@ static struct Cleanup { END_NAMESPACE_DISTRHO DISTRHO_PLUGIN_EXPORT -#if DISTRHO_OS_WINDOWS || DISTRHO_OS_MAC +#if DISTRHO_OS_MAC || DISTRHO_OS_WASM || DISTRHO_OS_WINDOWS const AEffect* VSTPluginMain(audioMasterCallback audioMaster); #else const AEffect* VSTPluginMain(audioMasterCallback audioMaster) asm ("main"); diff --git a/distrho/src/jackbridge/SDLBridge.hpp b/distrho/src/jackbridge/SDLBridge.hpp index 149963ca..2c5138ac 100644 --- a/distrho/src/jackbridge/SDLBridge.hpp +++ b/distrho/src/jackbridge/SDLBridge.hpp @@ -204,11 +204,13 @@ struct SDLBridge { self->jackProcessCallback(numFrames, self->jackProcessArg); +#if DISTRHO_PLUGIN_NUM_OUTPUTS > 0 for (uint i=0; i < DISTRHO_PLUGIN_NUM_OUTPUTS; ++i) { for (uint j=0; j < numFrames; ++j) fstream[j * DISTRHO_PLUGIN_NUM_OUTPUTS + i] = self->audioBuffers[DISTRHO_PLUGIN_NUM_INPUTS+i][j]; } +#endif } };