Tweaks for proper plugin resource usage
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
588f316fd6
commit
28bcac708f
7 changed files with 82 additions and 65 deletions
|
|
@ -234,13 +234,6 @@ PLUGIN_FILES += $(filter-out rackwindows/src/plugin.cpp,$(wildcard rackwindows/s
|
|||
|
||||
PLUGIN_FILES += $(filter-out ZetaCarinaeModules/src/plugin.cpp,$(wildcard ZetaCarinaeModules/src/*.cpp))
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# Resources to symlink
|
||||
|
||||
# TODO
|
||||
# PLUGIN_RESOURCES = res/Befaco/res
|
||||
# PLUGIN_RESOURCES = res/Befaco/res
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# Build setup
|
||||
|
||||
|
|
@ -296,17 +289,6 @@ BASE_FLAGS += -Wno-unused-variable
|
|||
# also lots of plugins not updated to v2 yet
|
||||
BASE_FLAGS += -Wno-deprecated-declarations
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# temporary macro just to get the ball rolling
|
||||
|
||||
ifeq ($(EXE_WRAPPER),wine)
|
||||
PLUGINS_DIR = Z:$(subst /,\\,$(CURDIR))
|
||||
else
|
||||
PLUGINS_DIR = $(CURDIR)
|
||||
endif
|
||||
|
||||
BUILD_CXX_FLAGS += -DCARDINAL_PLUGINS_DIR='"$(PLUGINS_DIR)"'
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# Build targets
|
||||
|
||||
|
|
@ -321,20 +303,28 @@ clean:
|
|||
# --------------------------------------------------------------
|
||||
|
||||
PLUGIN_LIST = $(subst /plugin.json,,$(wildcard */plugin.json))
|
||||
PLUGIN_RESOURCES = ../bin/Cardinal.lv2/resources/PluginManifests/Core.json
|
||||
PLUGIN_RESOURCES += $(PLUGIN_LIST:%=../bin/Cardinal.lv2/resources/%)
|
||||
PLUGIN_RESOURCES += $(PLUGIN_LIST:%=../bin/Cardinal.lv2/resources/PluginManifests/%.json)
|
||||
ifeq ($(MACOS),true)
|
||||
PLUGIN_RESOURCES += ../bin/Cardinal.vst/Contents/Resources/PluginManifests/Core.json
|
||||
PLUGIN_RESOURCES += $(PLUGIN_LIST:%=../bin/Cardinal.vst/Contents/Resources/%)
|
||||
PLUGIN_RESOURCES += $(PLUGIN_LIST:%=../bin/Cardinal.vst/Contents/Resources/PluginManifests/%.json)
|
||||
else
|
||||
PLUGIN_RESOURCES += ../bin/Cardinal.vst/resources/PluginManifests/Core.json
|
||||
PLUGIN_RESOURCES += $(PLUGIN_LIST:%=../bin/Cardinal.vst/resources/%)
|
||||
PLUGIN_RESOURCES += $(PLUGIN_LIST:%=../bin/Cardinal.vst/resources/PluginManifests/%.json)
|
||||
endif
|
||||
PLUGIN_RESOURCES += ../bin/Cardinal.vst3/Contents/Resources/PluginManifests/Core.json
|
||||
PLUGIN_RESOURCES += $(PLUGIN_LIST:%=../bin/Cardinal.vst3/Contents/Resources/%)
|
||||
PLUGIN_RESOURCES += $(PLUGIN_LIST:%=../bin/Cardinal.vst3/Contents/Resources/PluginManifests/%.json)
|
||||
|
||||
resources: $(PLUGIN_RESOURCES)
|
||||
|
||||
../bin/Cardinal.%/Core.json: Core.json
|
||||
-@mkdir -p "$(shell dirname $@)"
|
||||
ln -sf $(abspath $<) $@
|
||||
|
||||
../bin/Cardinal.lv2/resources/%: %/res
|
||||
-@mkdir -p "$(shell dirname $@)"
|
||||
ln -sf $(abspath $<) $@
|
||||
|
|
|
|||
|
|
@ -256,6 +256,11 @@ Plugin* pluginInstance__ZetaCarinaeModules;
|
|||
|
||||
namespace rack {
|
||||
|
||||
namespace asset {
|
||||
std::string pluginManifest(const std::string& dirname);
|
||||
std::string pluginPath(const std::string& dirname);
|
||||
}
|
||||
|
||||
// core plugins
|
||||
namespace core {
|
||||
extern Model* modelAudioInterface;
|
||||
|
|
@ -280,42 +285,14 @@ struct StaticPluginLoader {
|
|||
FILE* file;
|
||||
json_t* rootJ;
|
||||
|
||||
// core
|
||||
StaticPluginLoader(Plugin* const p)
|
||||
: plugin(p),
|
||||
file(nullptr),
|
||||
rootJ(nullptr)
|
||||
{
|
||||
p->path = system::join(CARDINAL_PLUGINS_DIR, "Core.json");
|
||||
|
||||
if ((file = std::fopen(p->path.c_str(), "r")) == nullptr)
|
||||
{
|
||||
d_stderr2("Manifest file %s does not exist", p->path.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
json_error_t error;
|
||||
if ((rootJ = json_loadf(file, 0, &error)) == nullptr)
|
||||
{
|
||||
d_stderr2("JSON parsing error at %s %d:%d %s", p->path.c_str(), error.line, error.column, error.text);
|
||||
return;
|
||||
}
|
||||
|
||||
// force ABI, we use static plugins so this doesnt matter as long as it builds
|
||||
json_t* const version = json_string((APP_VERSION_MAJOR + ".0").c_str());
|
||||
json_object_set(rootJ, "version", version);
|
||||
json_decref(version);
|
||||
}
|
||||
|
||||
// regular plugins
|
||||
StaticPluginLoader(Plugin* const p, const char* const name)
|
||||
: plugin(p),
|
||||
file(nullptr),
|
||||
rootJ(nullptr)
|
||||
{
|
||||
p->path = system::join(CARDINAL_PLUGINS_DIR, name);
|
||||
p->path = asset::pluginPath(name);
|
||||
|
||||
const std::string manifestFilename = system::join(p->path, "plugin.json");
|
||||
const std::string manifestFilename = asset::pluginManifest(name);
|
||||
|
||||
if ((file = std::fopen(manifestFilename.c_str(), "r")) == nullptr)
|
||||
{
|
||||
|
|
@ -359,7 +336,7 @@ static void initStatic__Core()
|
|||
{
|
||||
Plugin* const p = new Plugin;
|
||||
|
||||
const StaticPluginLoader spl(p);
|
||||
const StaticPluginLoader spl(p, "Core");
|
||||
if (spl.ok())
|
||||
{
|
||||
p->addModel(rack::core::modelAudioInterface);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue