More wasm details, deal with requirements for -sMAIN_MODULE
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
c3f271d9e9
commit
d1d08e4704
12 changed files with 112 additions and 40 deletions
1
Makefile
1
Makefile
|
@ -64,7 +64,6 @@ DGL_EXTRA_ARGS = \
|
||||||
NVG_DISABLE_SKIPPING_WHITESPACE=true \
|
NVG_DISABLE_SKIPPING_WHITESPACE=true \
|
||||||
NVG_FONT_TEXTURE_FLAGS=NVG_IMAGE_NEAREST \
|
NVG_FONT_TEXTURE_FLAGS=NVG_IMAGE_NEAREST \
|
||||||
USE_NANOVG_FBO=true \
|
USE_NANOVG_FBO=true \
|
||||||
WASM_EXCEPTIONS=true \
|
|
||||||
WINDOWS_ICON_ID=401
|
WINDOWS_ICON_ID=401
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
|
|
2
carla
2
carla
|
@ -1 +1 @@
|
||||||
Subproject commit b8fa8f2faa42f69f6093a03fafb86b374ed46145
|
Subproject commit 7a9b7ba35e261f519b4ab38b7f506e2745998e90
|
2
dpf
2
dpf
|
@ -1 +1 @@
|
||||||
Subproject commit b9e654c3d331933dbeae0413246be8dc2bd64a58
|
Subproject commit 02216aba747685fe3d8c1e7b95d7fc008249fee2
|
|
@ -30,16 +30,19 @@
|
||||||
|
|
||||||
#include_next "common.hpp"
|
#include_next "common.hpp"
|
||||||
|
|
||||||
// Workaround for wrong file permissions from zstd extraction
|
// Workaround for wrong file permissions from zstd extraction and system usage
|
||||||
#ifdef __EMSCRIPTEN__
|
#ifdef __EMSCRIPTEN__
|
||||||
#define fopen fopen_wasm
|
#define fopen fopen_wasm
|
||||||
|
#define system system_wasm
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
FILE* fopen_wasm(const char* filename, const char* mode);
|
FILE* fopen_wasm(const char* filename, const char* mode);
|
||||||
|
inline int system_wasm(const char*) { return 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
using ::fopen_wasm;
|
using ::fopen_wasm;
|
||||||
|
using ::system_wasm;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -17,16 +17,13 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef __HAIKU__
|
|
||||||
// these are missing from HaikuOS
|
|
||||||
#define pthread_setname_np(...)
|
#define pthread_setname_np(...)
|
||||||
|
|
||||||
static int pthread_getcpuclockid(pthread_t, clockid_t* const clock_id)
|
int pthread_getcpuclockid(pthread_t, clockid_t* const clock_id)
|
||||||
{
|
{
|
||||||
*clock_id = CLOCK_REALTIME;
|
*clock_id = CLOCK_REALTIME;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int backtrace(void**, int)
|
static int backtrace(void**, int)
|
||||||
{
|
{
|
||||||
|
|
|
@ -515,7 +515,7 @@ PLUGIN_FILES += $(filter-out Bidoo/src/plugin.cpp Bidoo/src/ANTN.cpp,$(wildcard
|
||||||
PLUGIN_FILES += $(wildcard Bidoo/src/dep/*.cpp)
|
PLUGIN_FILES += $(wildcard Bidoo/src/dep/*.cpp)
|
||||||
PLUGIN_FILES += $(wildcard Bidoo/src/dep/filters/*.cpp)
|
PLUGIN_FILES += $(wildcard Bidoo/src/dep/filters/*.cpp)
|
||||||
PLUGIN_FILES += $(wildcard Bidoo/src/dep/freeverb/*.cpp)
|
PLUGIN_FILES += $(wildcard Bidoo/src/dep/freeverb/*.cpp)
|
||||||
PLUGIN_FILES += $(wildcard Bidoo/src/dep/lodepng/*.cpp)
|
PLUGIN_FILES += $(filter-out Bidoo/src/dep/lodepng/pngdetail.cpp,$(wildcard Bidoo/src/dep/lodepng/*.cpp))
|
||||||
PLUGIN_FILES += $(filter-out Bidoo/src/dep/resampler/main.cpp,$(wildcard Bidoo/src/dep/resampler/*.cpp))
|
PLUGIN_FILES += $(filter-out Bidoo/src/dep/resampler/main.cpp,$(wildcard Bidoo/src/dep/resampler/*.cpp))
|
||||||
PLUGIN_FILES += BidooDark/plugin.cpp
|
PLUGIN_FILES += BidooDark/plugin.cpp
|
||||||
|
|
||||||
|
@ -1024,6 +1024,10 @@ BASE_FLAGS += -I../src/Rack/dep/pffft
|
||||||
|
|
||||||
ifeq ($(DEBUG),true)
|
ifeq ($(DEBUG),true)
|
||||||
BASE_FLAGS += -UDEBUG
|
BASE_FLAGS += -UDEBUG
|
||||||
|
ifeq ($(WASM),true)
|
||||||
|
# SSE must always be enabled on wasm, even in debug builds
|
||||||
|
BASE_FLAGS += -msse -msse2 -msse3 -msimd128
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HEADLESS),true)
|
ifeq ($(HEADLESS),true)
|
||||||
|
@ -1098,6 +1102,23 @@ ifeq ($(MACOS),true)
|
||||||
BASE_FLAGS += -Wno-unknown-warning-option
|
BASE_FLAGS += -Wno-unknown-warning-option
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# --------------------------------------------------------------
|
||||||
|
# Carla and friends build flags
|
||||||
|
|
||||||
|
CARLA_FLAGS = \
|
||||||
|
-DCARLA_BACKEND_NAMESPACE=Cardinal \
|
||||||
|
-DREAL_BUILD \
|
||||||
|
-DSTATIC_PLUGIN_TARGET \
|
||||||
|
-I../deps/aubio/src \
|
||||||
|
-I../carla/source/backend \
|
||||||
|
-I../carla/source/includes \
|
||||||
|
-I../carla/source/modules \
|
||||||
|
-I../carla/source/utils
|
||||||
|
|
||||||
|
ifeq ($(WASM),true)
|
||||||
|
CARLA_FLAGS += -DDISTRHO_RUNNER_INDIRECT_WASM_CALLS
|
||||||
|
endif
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# Build targets
|
# Build targets
|
||||||
|
|
||||||
|
@ -1314,14 +1335,7 @@ $(BUILD_DIR)/Cardinal/%.cpp.o: Cardinal/%.cpp
|
||||||
-Dstbtt_fontinfo=stbtt_fontinfo_cardinal \
|
-Dstbtt_fontinfo=stbtt_fontinfo_cardinal \
|
||||||
-Dstbrp_node=stbrp_node_cardinal \
|
-Dstbrp_node=stbrp_node_cardinal \
|
||||||
-Dstbrp_rect=stbrp_rect_cardinal \
|
-Dstbrp_rect=stbrp_rect_cardinal \
|
||||||
-DCARLA_BACKEND_NAMESPACE=Cardinal \
|
$(CARLA_FLAGS)
|
||||||
-DREAL_BUILD \
|
|
||||||
-DSTATIC_PLUGIN_TARGET \
|
|
||||||
-I../deps/aubio/src \
|
|
||||||
-I../carla/source/backend \
|
|
||||||
-I../carla/source/includes \
|
|
||||||
-I../carla/source/modules \
|
|
||||||
-I../carla/source/utils
|
|
||||||
|
|
||||||
$(BUILD_DIR)/21kHz/%.cpp.o: 21kHz/%.cpp
|
$(BUILD_DIR)/21kHz/%.cpp.o: 21kHz/%.cpp
|
||||||
-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
|
-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
|
||||||
|
|
|
@ -284,7 +284,7 @@ void openBrowser(const std::string& url)
|
||||||
window.open(UTF8ToString($0), '_blank');
|
window.open(UTF8ToString($0), '_blank');
|
||||||
}, url.c_str());
|
}, url.c_str());
|
||||||
#else
|
#else
|
||||||
patchUtils::openBrowser(url);
|
system::openBrowser(url);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,16 +104,18 @@ bool d_isDiffHigherThanLimit(const T& v1, const T& v2, const T& limit)
|
||||||
// -----------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef DISTRHO_OS_WASM
|
#ifdef DISTRHO_OS_WASM
|
||||||
EM_JS(char*, getPatchStorageSlug, (), {
|
static char* getPatchStorageSlug() {
|
||||||
var searchParams = new URLSearchParams(window.location.search);
|
return static_cast<char*>(EM_ASM_PTR({
|
||||||
var patch = searchParams.get('patchstorage');
|
var searchParams = new URLSearchParams(window.location.search);
|
||||||
if (!patch)
|
var patch = searchParams.get('patchstorage');
|
||||||
return null;
|
if (!patch)
|
||||||
var length = lengthBytesUTF8(patch) + 1;
|
return null;
|
||||||
var str = _malloc(length);
|
var length = lengthBytesUTF8(patch) + 1;
|
||||||
stringToUTF8(patch, str, length);
|
var str = _malloc(length);
|
||||||
return str;
|
stringToUTF8(patch, str, length);
|
||||||
});
|
return str;
|
||||||
|
}));
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -388,20 +388,9 @@ public:
|
||||||
|
|
||||||
#ifdef DISTRHO_OS_WASM
|
#ifdef DISTRHO_OS_WASM
|
||||||
if (rack::patchStorageSlug != nullptr)
|
if (rack::patchStorageSlug != nullptr)
|
||||||
{
|
|
||||||
std::string url("/patchstorage.php?slug=");
|
|
||||||
url += rack::patchStorageSlug;
|
|
||||||
std::free(rack::patchStorageSlug);
|
|
||||||
rack::patchStorageSlug = nullptr;
|
|
||||||
|
|
||||||
psDialog = new WasmPatchStorageLoadingDialog();
|
psDialog = new WasmPatchStorageLoadingDialog();
|
||||||
emscripten_async_wget(url.c_str(), context->patch->templatePath.c_str(),
|
|
||||||
downloadPatchStorageSucceeded, downloadPatchStorageFailed);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
new WasmWelcomeDialog();
|
new WasmWelcomeDialog();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
context->window->step();
|
context->window->step();
|
||||||
|
@ -443,6 +432,19 @@ public:
|
||||||
{
|
{
|
||||||
counterForSelfFocus = -1;
|
counterForSelfFocus = -1;
|
||||||
getWindow().focus();
|
getWindow().focus();
|
||||||
|
|
||||||
|
#ifdef DISTRHO_OS_WASM
|
||||||
|
if (rack::patchStorageSlug != nullptr)
|
||||||
|
{
|
||||||
|
std::string url("/patchstorage.php?slug=");
|
||||||
|
url += rack::patchStorageSlug;
|
||||||
|
std::free(rack::patchStorageSlug);
|
||||||
|
rack::patchStorageSlug = nullptr;
|
||||||
|
|
||||||
|
emscripten_async_wget(url.c_str(), context->patch->templatePath.c_str(),
|
||||||
|
downloadPatchStorageSucceeded, downloadPatchStorageFailed);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filebrowserhandle != nullptr && fileBrowserIdle(filebrowserhandle))
|
if (filebrowserhandle != nullptr && fileBrowserIdle(filebrowserhandle))
|
||||||
|
|
12
src/Makefile
12
src/Makefile
|
@ -64,6 +64,10 @@ BASE_FLAGS += -IRack/dep/pffft
|
||||||
|
|
||||||
ifeq ($(DEBUG),true)
|
ifeq ($(DEBUG),true)
|
||||||
BASE_FLAGS += -UDEBUG
|
BASE_FLAGS += -UDEBUG
|
||||||
|
ifeq ($(WASM),true)
|
||||||
|
# SSE must always be enabled on wasm, even in debug builds
|
||||||
|
BASE_FLAGS += -msse -msse2 -msse3 -msimd128
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HAVE_LIBLO),true)
|
ifeq ($(HAVE_LIBLO),true)
|
||||||
|
@ -168,6 +172,10 @@ RACK_FILES += $(wildcard Rack/src/*/*.c)
|
||||||
RACK_FILES += $(filter-out $(IGNORED_FILES),$(wildcard Rack/src/*.cpp))
|
RACK_FILES += $(filter-out $(IGNORED_FILES),$(wildcard Rack/src/*.cpp))
|
||||||
RACK_FILES += $(filter-out $(IGNORED_FILES), $(wildcard Rack/src/*/*.cpp))
|
RACK_FILES += $(filter-out $(IGNORED_FILES), $(wildcard Rack/src/*/*.cpp))
|
||||||
|
|
||||||
|
ifeq ($(WASM),true)
|
||||||
|
RACK_FILES += emscripten/WasmUtils.cpp
|
||||||
|
endif
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
# lots of warnings from VCV side
|
# lots of warnings from VCV side
|
||||||
|
|
||||||
|
@ -194,6 +202,8 @@ all: $(TARGET)
|
||||||
ifeq ($(MOD_BUILD),true)
|
ifeq ($(MOD_BUILD),true)
|
||||||
$(MAKE) -C Cardinal lv2
|
$(MAKE) -C Cardinal lv2
|
||||||
$(MAKE) -C CardinalFX lv2
|
$(MAKE) -C CardinalFX lv2
|
||||||
|
else ifeq ($(WASM),true)
|
||||||
|
$(MAKE) -C CardinalSynth jack
|
||||||
else
|
else
|
||||||
$(MAKE) -C Cardinal
|
$(MAKE) -C Cardinal
|
||||||
$(MAKE) -C CardinalFX $(CARDINAL_FX_ARGS)
|
$(MAKE) -C CardinalFX $(CARDINAL_FX_ARGS)
|
||||||
|
@ -244,6 +254,8 @@ $(BUILD_DIR)/%.cpp.o: %.cpp
|
||||||
@echo "Compiling $<"
|
@echo "Compiling $<"
|
||||||
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@
|
$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@
|
||||||
|
|
||||||
|
$(BUILD_DIR)/emscripten/WasmUtils.cpp.o: BUILD_CXX_FLAGS += -fno-exceptions
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
-include $(RACK_OBJS:%.o=%.d)
|
-include $(RACK_OBJS:%.o=%.d)
|
||||||
|
|
|
@ -20,7 +20,6 @@ endif
|
||||||
ifneq ($(STATIC_BUILD),true)
|
ifneq ($(STATIC_BUILD),true)
|
||||||
|
|
||||||
CWD = ../../carla/source
|
CWD = ../../carla/source
|
||||||
STATIC_PLUGIN_TARGET = true
|
|
||||||
include $(CWD)/Makefile.deps.mk
|
include $(CWD)/Makefile.deps.mk
|
||||||
|
|
||||||
CARLA_BUILD_DIR = ../../carla/build
|
CARLA_BUILD_DIR = ../../carla/build
|
||||||
|
@ -35,7 +34,9 @@ CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/carla_engine_
|
||||||
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/carla_plugin.a
|
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/carla_plugin.a
|
||||||
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/native-plugins.a
|
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/native-plugins.a
|
||||||
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/audio_decoder.a
|
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/audio_decoder.a
|
||||||
|
ifneq ($(WASM),true)
|
||||||
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/jackbridge.min.a
|
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/jackbridge.min.a
|
||||||
|
endif
|
||||||
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/lilv.a
|
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/lilv.a
|
||||||
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/rtmempool.a
|
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/rtmempool.a
|
||||||
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/sfzero.a
|
CARLA_EXTRA_LIBS += $(CARLA_BUILD_DIR)/modules/$(CARLA_BUILD_TYPE)/sfzero.a
|
||||||
|
@ -114,6 +115,11 @@ endif
|
||||||
|
|
||||||
# --------------------------------------------------------------
|
# --------------------------------------------------------------
|
||||||
|
|
||||||
|
# FIXME
|
||||||
|
ifeq ($(WASM),true)
|
||||||
|
STATIC_CARLA_PLUGIN_LIBS = -lsndfile -lopus -lFLAC -lvorbisenc -lvorbis -logg -lm
|
||||||
|
endif
|
||||||
|
|
||||||
EXTRA_DEPENDENCIES = $(RACK_EXTRA_LIBS) $(CARLA_EXTRA_LIBS)
|
EXTRA_DEPENDENCIES = $(RACK_EXTRA_LIBS) $(CARLA_EXTRA_LIBS)
|
||||||
EXTRA_LIBS = $(RACK_EXTRA_LIBS) $(CARLA_EXTRA_LIBS) $(STATIC_CARLA_PLUGIN_LIBS)
|
EXTRA_LIBS = $(RACK_EXTRA_LIBS) $(CARLA_EXTRA_LIBS) $(STATIC_CARLA_PLUGIN_LIBS)
|
||||||
|
|
||||||
|
@ -206,6 +212,7 @@ BASE_FLAGS += -Wno-unused-variable
|
||||||
|
|
||||||
ifeq ($(WASM),true)
|
ifeq ($(WASM),true)
|
||||||
LINK_FLAGS += --preload-file=./jsfx
|
LINK_FLAGS += --preload-file=./jsfx
|
||||||
|
LINK_FLAGS += --preload-file=./lv2
|
||||||
LINK_FLAGS += --preload-file=./resources
|
LINK_FLAGS += --preload-file=./resources
|
||||||
LINK_FLAGS += -sALLOW_MEMORY_GROWTH
|
LINK_FLAGS += -sALLOW_MEMORY_GROWTH
|
||||||
LINK_FLAGS += -sINITIAL_MEMORY=64Mb
|
LINK_FLAGS += -sINITIAL_MEMORY=64Mb
|
||||||
|
|
36
src/emscripten/WasmUtils.cpp
Normal file
36
src/emscripten/WasmUtils.cpp
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* DISTRHO Cardinal Plugin
|
||||||
|
* Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 3 of
|
||||||
|
* the License, or any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* For a full copy of the GNU General Public License see the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <emscripten/html5.h>
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace CardinalDISTRHO {
|
||||||
|
|
||||||
|
long d_emscripten_set_interval(void (*cb)(void* userData), double intervalMsecs, void* userData)
|
||||||
|
{
|
||||||
|
return emscripten_set_interval(cb, intervalMsecs, userData);
|
||||||
|
}
|
||||||
|
|
||||||
|
void d_emscripten_clear_interval(long setIntervalId)
|
||||||
|
{
|
||||||
|
emscripten_clear_interval(setIntervalId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------------------------------------
|
Loading…
Add table
Add a link
Reference in a new issue