Skip to content

Commit

Permalink
Preparations for a future DISTRHO_PLUGIN_WANT_WEBVIEW
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Mar 16, 2024
1 parent 9f4fcf9 commit 370af7f
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 16 deletions.
18 changes: 11 additions & 7 deletions Makefile.plugins.mk
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ HAVE_DGL = false
endif
endif

ifeq ($(HAVE_DGL)$(LINUX)$(USING_WEBVIEW),truetruetrue)
DGL_LIB_SHARED = $(shell $(CC) -print-file-name=Scrt1.o)
endif

DGL_LIBS += $(DGL_SYSTEM_LIBS) -lm

# TODO split dsp and ui object build flags
Expand Down Expand Up @@ -545,9 +549,9 @@ lv2_dsp: $(lv2_dsp)
lv2_sep: $(lv2_dsp) $(lv2_ui)

ifeq ($(HAVE_DGL),true)
$(lv2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB)
$(lv2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB) $(DGL_LIB_SHARED)
else
$(lv2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o
$(lv2): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o
endif
-@mkdir -p $(shell dirname $@)
@echo "Creating LV2 plugin for $(NAME)"
Expand All @@ -558,7 +562,7 @@ $(lv2_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o
@echo "Creating LV2 plugin library for $(NAME)"
$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(EXTRA_LIBS) $(EXTRA_DSP_LIBS) $(SHARED) $(SYMBOLS_LV2DSP) -o $@

$(lv2_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB)
$(lv2_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB) $(DGL_LIB_SHARED)
-@mkdir -p $(shell dirname $@)
@echo "Creating LV2 plugin UI for $(NAME)"
$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(EXTRA_LIBS) $(EXTRA_UI_LIBS) $(DGL_LIBS) $(SHARED) $(SYMBOLS_LV2UI) -o $@
Expand Down Expand Up @@ -663,7 +667,7 @@ modgui:
vst2 vst: $(vst2) $(vst2files)

ifeq ($(HAVE_DGL),true)
$(vst2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_VST2.cpp.o $(BUILD_DIR)/DistrhoUIMain_VST2.cpp.o $(DGL_LIB)
$(vst2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_VST2.cpp.o $(BUILD_DIR)/DistrhoUIMain_VST2.cpp.o $(DGL_LIB) $(DGL_LIB_SHARED)
else
$(vst2): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_VST2.cpp.o
endif
Expand All @@ -677,7 +681,7 @@ endif
vst3: $(vst3) $(vst3files)

ifeq ($(HAVE_DGL),true)
$(vst3): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_VST3.cpp.o $(BUILD_DIR)/DistrhoUIMain_VST3.cpp.o $(DGL_LIB)
$(vst3): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_VST3.cpp.o $(BUILD_DIR)/DistrhoUIMain_VST3.cpp.o $(DGL_LIB) $(DGL_LIB_SHARED)
else
$(vst3): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_VST3.cpp.o
endif
Expand All @@ -699,7 +703,7 @@ endif
clap: $(clap) $(clapfiles)

ifeq ($(HAVE_DGL),true)
$(clap): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_CLAP.cpp.o $(BUILD_DIR)/DistrhoUIMain_CLAP.cpp.o $(DGL_LIB)
$(clap): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_CLAP.cpp.o $(BUILD_DIR)/DistrhoUIMain_CLAP.cpp.o $(DGL_LIB) $(DGL_LIB_SHARED)
else
$(clap): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_CLAP.cpp.o
endif
Expand Down Expand Up @@ -739,7 +743,7 @@ endif
shared: $(shared)

ifeq ($(HAVE_DGL),true)
$(shared): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_SHARED.cpp.o $(BUILD_DIR)/DistrhoUIMain_SHARED.cpp.o $(DGL_LIB)
$(shared): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_SHARED.cpp.o $(BUILD_DIR)/DistrhoUIMain_SHARED.cpp.o $(DGL_LIB) $(DGL_LIB_SHARED)
else
$(shared): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_SHARED.cpp.o
endif
Expand Down
12 changes: 7 additions & 5 deletions distrho/DistrhoUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,15 @@ int32_t d_roundToInt(const T& value)
/** @} */

/* --------------------------------------------------------------------------------------------------------------------
* math functions */
* other stuff */

#ifndef DONT_SET_USING_DISTRHO_NAMESPACE
// If your code uses a lot of DISTRHO classes, then this will obviously save you
// a lot of typing, but can be disabled by setting DONT_SET_USING_DISTRHO_NAMESPACE.
namespace DISTRHO_NAMESPACE {}
using namespace DISTRHO_NAMESPACE;
/**
If your code uses a lot of DISTRHO classes, then this will obviously save you a lot of typing,
but can be disabled by setting DONT_SET_USING_DISTRHO_NAMESPACE.
*/
namespace DISTRHO_NAMESPACE {}
using namespace DISTRHO_NAMESPACE;
#endif

#endif // DISTRHO_UTILS_HPP_INCLUDED
15 changes: 15 additions & 0 deletions distrho/src/DistrhoPluginChecks.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
# define DISTRHO_PLUGIN_WANT_TIMEPOS 0
#endif

#ifndef DISTRHO_PLUGIN_WANT_WEBVIEW
# define DISTRHO_PLUGIN_WANT_WEBVIEW 0
#endif

#ifndef DISTRHO_UI_FILE_BROWSER
# if defined(DGL_FILE_BROWSER_DISABLED) || DISTRHO_PLUGIN_HAS_EXTERNAL_UI
# define DISTRHO_UI_FILE_BROWSER 0
Expand Down Expand Up @@ -257,6 +261,17 @@ static_assert(sizeof(STRINGIFY(DISTRHO_PLUGIN_UNIQUE_ID)) == 5, "The macro DISTR
# error DISTRHO_UI_IS_STANDALONE must not be defined
#endif

#ifdef DPF_USING_LD_LINUX_WEBVIEW
# error DPF_USING_LD_LINUX_WEBVIEW must not be defined
#endif

// --------------------------------------------------------------------------------------------------------------------
// Set DPF_USING_LD_LINUX_WEBVIEW for internal use

#if DISTRHO_PLUGIN_WANT_WEBVIEW && defined(__linux__)
# define DPF_USING_LD_LINUX_WEBVIEW
#endif

// --------------------------------------------------------------------------------------------------------------------

#endif // DISTRHO_PLUGIN_CHECKS_H_INCLUDED
11 changes: 10 additions & 1 deletion distrho/src/DistrhoPluginJACK.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Plugin Framework (DPF)
* Copyright (C) 2012-2022 Filipe Coelho <[email protected]>
* Copyright (C) 2012-2024 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -86,6 +86,10 @@ static const writeMidiFunc writeMidiCallback = nullptr;
static const requestParameterValueChangeFunc requestParameterValueChangeCallback = nullptr;
#endif

#ifdef DPF_USING_LD_LINUX_WEBVIEW
int dpf_webview_start(int argc, char* argv[]);
#endif

// -----------------------------------------------------------------------

static volatile bool gCloseSignalReceived = false;
Expand Down Expand Up @@ -996,6 +1000,11 @@ int main(int argc, char* argv[])
}
#endif

#ifdef DPF_USING_LD_LINUX_WEBVIEW
if (argc >= 2 && std::strcmp(argv[1], "dpf-ld-linux-webview") == 0)
return dpf_webview_start(argc - 1, argv + 1);
#endif

if (argc == 2 && std::strcmp(argv[1], "selftest") == 0)
{
#ifdef DPF_RUNTIME_TESTING
Expand Down
6 changes: 5 additions & 1 deletion distrho/src/DistrhoPluginVST2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1720,13 +1720,17 @@ const vst_effect* VSTPluginMain(const vst_host_callback audioMaster)
return effect;
}

#if !(defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WASM) || defined(DISTRHO_OS_WINDOWS))
#if !(defined(DISTRHO_OS_MAC) || defined(DISTRHO_OS_WASM) || defined(DISTRHO_OS_WINDOWS) || DISTRHO_PLUGIN_WANT_WEBVIEW)
DISTRHO_PLUGIN_EXPORT
const vst_effect* VSTPluginMainCompat(vst_host_callback) asm ("main");

DISTRHO_PLUGIN_EXPORT
const vst_effect* VSTPluginMainCompat(const vst_host_callback audioMaster)
{
// protect main symbol against running as executable
if (reinterpret_cast<uintptr_t>(audioMaster) < 0xff)
return nullptr;

return VSTPluginMain(audioMaster);
}
#endif
Expand Down
9 changes: 9 additions & 0 deletions distrho/src/DistrhoUIDSSI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ static constexpr const setSizeFunc setSizeCallback = nullptr;
// unsupported in DSSI
static constexpr const fileRequestFunc fileRequestCallback = nullptr;

#ifdef DPF_USING_LD_LINUX_WEBVIEW
int dpf_webview_start(int argc, char* argv[]);
#endif

// --------------------------------------------------------------------------------------------------------------------


Expand Down Expand Up @@ -387,6 +391,11 @@ int main(int argc, char* argv[])
{
USE_NAMESPACE_DISTRHO

#ifdef DPF_USING_LD_LINUX_WEBVIEW
if (argc >= 2 && std::strcmp(argv[1], "dpf-ld-linux-webview") == 0)
return dpf_webview_start(argc - 1, argv + 1);
#endif

// dummy test mode
if (argc == 1)
{
Expand Down
16 changes: 14 additions & 2 deletions distrho/src/DistrhoUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID)

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------

const char* getBinaryFilename()
{
Expand Down Expand Up @@ -165,6 +165,18 @@ bool requestBufferSizeChange(uint) { return false; }
bool requestMIDI() { return false; }
#endif

// -----------------------------------------------------------------------
/* define webview start */
#ifdef DPF_USING_LD_LINUX_WEBVIEW
int dpf_webview_start(int argc, char* argv[]);
#endif

// --------------------------------------------------------------------------------------------------------------------

END_NAMESPACE_DISTRHO

#if defined(DPF_USING_LD_LINUX_WEBVIEW) && !DISTRHO_IS_STANDALONE
int main(int argc, char* argv[])
{
return DISTRHO_NAMESPACE::dpf_webview_start(argc, argv);
}
#endif

0 comments on commit 370af7f

Please sign in to comment.