From 28f2c26872e6301d769b948c6504c65155bc18b6 Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 18 Oct 2021 04:11:05 +0100 Subject: [PATCH] Force the way binary resources are generated Signed-off-by: falkTX --- include/common.hpp | 28 ++++++++++++++++++++++++++++ plugins/res2c.py | 4 ---- src/CardinalPlugin.cpp | 1 + src/CardinalUI.cpp | 9 +++++---- 4 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 include/common.hpp diff --git a/include/common.hpp b/include/common.hpp new file mode 100644 index 0000000..97892ac --- /dev/null +++ b/include/common.hpp @@ -0,0 +1,28 @@ +/* + * DISTRHO Cardinal Plugin + * Copyright (C) 2021 Filipe Coelho + * + * 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_next "common.hpp" + +#undef BINARY +#undef BINARY_START +#undef BINARY_END +#undef BINARY_SIZE + +#define BINARY(sym) extern const unsigned char sym[]; extern const unsigned int sym##_len +#define BINARY_START(sym) ((const void*) sym) +#define BINARY_END(sym) ((const void*) sym + sym##_len) +#define BINARY_SIZE(sym) (sym##_len) diff --git a/plugins/res2c.py b/plugins/res2c.py index 52428b5..7f4f7c8 100755 --- a/plugins/res2c.py +++ b/plugins/res2c.py @@ -32,10 +32,6 @@ def res2c(filename): print("const unsigned int %s_len = %d;\n" % (resname, fhandle.tell())) - if sys.platform != "darwin": - print("const unsigned char* _binary_%s_start = %s;\n" % (resname, resname)) - print("const unsigned char* _binary_%s_end = %s + %d;\n" % (resname, resname, fhandle.tell())) - # ----------------------------------------------------- if __name__ == '__main__': diff --git a/src/CardinalPlugin.cpp b/src/CardinalPlugin.cpp index c98bb46..069d701 100644 --- a/src/CardinalPlugin.cpp +++ b/src/CardinalPlugin.cpp @@ -174,6 +174,7 @@ public: fContext->patch = new rack::patch::Manager; fContext->patch->autosavePath = fAutosavePath; fContext->patch->templatePath = CARDINAL_PLUGIN_SOURCE_DIR DISTRHO_OS_SEP_STR "template.vcv"; + fContext->patch->loadTemplate(); fContext->engine->startFallbackThread(); } diff --git a/src/CardinalUI.cpp b/src/CardinalUI.cpp index 49009e9..ef39a02 100644 --- a/src/CardinalUI.cpp +++ b/src/CardinalUI.cpp @@ -80,10 +80,11 @@ public: fContext->window = new rack::window::Window; rack::window::lastUI = nullptr; - if (fContext->patch->hasAutosave()) - fContext->patch->loadAutosave(); - else - fContext->patch->loadTemplate(); + // we need to reload current patch for things to show on screen :( + // FIXME always save + if (! fContext->patch->hasAutosave()) + fContext->patch->saveAutosave(); + fContext->patch->loadAutosave(); } ~CardinalUI() override