diff --git a/Makefile b/Makefile index c1e56bb..5d7e4f7 100644 --- a/Makefile +++ b/Makefile @@ -29,14 +29,33 @@ endif # Entropia File System Watcher -efsw := dep/lib/libefsw-static-release.a +ifeq (, $(shell which premake4)) + ifeq (, $(shell which premake5)) + $(error premake is not installed. Please install either premake4 or premake5) + else + PREMAKE = premake5 + endif +else + PREMAKE = premake4 +endif +ifdef ARCH_WIN + efsw := dep/lib/efsw-static-release.lib +else + efsw := dep/lib/libefsw-static-release.a +endif DEPS += $(efsw) OBJECTS += $(efsw) $(efsw): - cd efsw && premake4 gmake + cd efsw && $(PREMAKE) gmake +ifdef ARCH_WIN + cd efsw && $(MAKE) -C make/* config=release_x86_64 efsw-static-lib + mkdir -p dep/lib dep/include + cd efsw && cp lib/efsw-static-release.lib $(DEP_PATH)/lib/ +else cd efsw && $(MAKE) -C make/* config=release efsw-static-lib mkdir -p dep/lib dep/include cd efsw && cp lib/libefsw-static-release.a $(DEP_PATH)/lib/ +endif cd efsw && cp -R include/efsw $(DEP_PATH)/include/ @@ -74,45 +93,60 @@ endif # LuaJIT ifeq ($(LUAJIT), 1) SOURCES += src/LuaJITEngine.cpp -luajit := dep/lib/libluajit-5.1.a +luajit := dep/LuaJIT/src/libluajit.a OBJECTS += $(luajit) DEPS += $(luajit) $(luajit): - $(WGET) "http://luajit.org/download/LuaJIT-2.0.5.tar.gz" - $(SHA256) LuaJIT-2.0.5.tar.gz 874b1f8297c697821f561f9b73b57ffd419ed8f4278c82e05b48806d30c1e979 - cd dep && $(UNTAR) ../LuaJIT-2.0.5.tar.gz - cd dep/LuaJIT-2.0.5 && $(MAKE) BUILDMODE=static PREFIX="$(DEP_PATH)" install + cd dep && git clone "https://github.com/LuaJIT/LuaJIT.git" + cd dep/LuaJIT && git checkout v2.1 + cd dep/LuaJIT && MACOSX_DEPLOYMENT_TARGET=10.9 $(MAKE) BUILDMODE=static PREFIX="$(DEP_PATH)" install endif # SuperCollider ifeq ($(SUPERCOLLIDER), 1) SOURCES += src/SuperColliderEngine.cpp -FLAGS += -Idep/supercollider/include -Idep/supercollider/include/common -Idep/supercollider/lang -Idep/supercollider/common -Idep/supercollider/include/plugin_interface +FLAGS += -Idep/supercollider/include -Idep/supercollider/include/common -Idep/supercollider/lang -Idep/supercollider/common -Idep/supercollider/include/plugin_interface -Idep/supercollider/external_libraries/boost # FLAGS += -DSC_VCV_ENGINE_TIMING # uncomment to turn on timing printing while running -supercollider := dep/supercollider/build/lang/libsclang.a +ifdef ARCH_WIN + supercollider := dep/supercollider/build/lang/liblibsclang.a +else + supercollider := dep/supercollider/build/lang/libsclang.a +endif OBJECTS += $(supercollider) DEPS += $(supercollider) DISTRIBUTABLES += dep/supercollider/SCClassLibrary DISTRIBUTABLES += support/supercollider_extensions SUPERCOLLIDER_CMAKE_FLAGS += -DSUPERNOVA=0 -DSC_EL=0 -DSC_VIM=0 -DSC_ED=0 -DSC_IDE=0 -DSC_ABLETON_LINK=0 -DSC_QT=0 -DCMAKE_BUILD_TYPE=Release -DSCLANG_SERVER=0 -DBUILD_TESTING=0 -DNO_LIBSNDFILE=1 -SUPERCOLLIDER_SUBMODULES += external_libraries/hidapi external_libraries/nova-simd external_libraries/nova-tt external_libraries/portaudio_sc_org external_libraries/yaml-cpp -SUPERCOLLIDER_BRANCH := topic/vcv-prototype-support +SUPERCOLLIDER_SUBMODULES += external_libraries/hidapi external_libraries/nova-simd external_libraries/nova-tt external_libraries/portaudio/portaudio_submodule external_libraries/yaml-cpp +SUPERCOLLIDER_BRANCH := 3.13 -OBJECTS += dep/supercollider/build/external_libraries/libtlsf.a -OBJECTS += dep/supercollider/build/external_libraries/hidapi/linux/libhidapi.a +ifdef ARCH_WIN + OBJECTS += dep/supercollider/build/external_libraries/hidapi/windows/libhidapi.a +endif +ifdef ARCH_LIN + OBJECTS += dep/supercollider/build/external_libraries/hidapi/linux/libhidapi.a +endif +ifdef ARCH_MAC + OBJECTS += dep/supercollider/build/external_libraries/hidapi/mac/libhidapi.a +endif OBJECTS += dep/supercollider/build/external_libraries/hidapi/hidapi_parser/libhidapi_parser.a OBJECTS += dep/supercollider/build/external_libraries/libboost_thread_lib.a OBJECTS += dep/supercollider/build/external_libraries/libboost_system_lib.a OBJECTS += dep/supercollider/build/external_libraries/libboost_regex_lib.a OBJECTS += dep/supercollider/build/external_libraries/libboost_filesystem_lib.a +OBJECTS += dep/supercollider/build/external_libraries/libtlsf.a OBJECTS += dep/supercollider/build/external_libraries/libyaml.a -LDFLAGS += -lpthread -lasound -ludev +ifdef ARCH_LIN + LDFLAGS += -lpthread -lasound -ludev +else + LDFLAGS += -lpthread +endif $(supercollider): cd dep && git clone "https://github.com/supercollider/supercollider" --branch $(SUPERCOLLIDER_BRANCH) --depth 1 - cd dep/supercollider && git checkout 84b14d10d49edce6dd8303045a884fb7f2bc92e8 + cd dep/supercollider && git checkout c64c5244c5e7bbcb26a829e9cf72d249a529c213 cd dep/supercollider && git submodule update --depth 1 --init -- $(SUPERCOLLIDER_SUBMODULES) cd dep/supercollider && mkdir build cd dep/supercollider/build && $(CMAKE) .. $(SUPERCOLLIDER_CMAKE_FLAGS) @@ -195,8 +229,8 @@ SOURCES += src/VultEngine.cpp vult := dep/vult/vultc.h $(vult): cd dep && mkdir -p vult - cd dep/vult && $(WGET) "https://github.com/modlfo/vult/releases/download/v0.4.12/vultc.h" - $(SHA256) $(vult) 3e80f6d30defe7df2804568f0314dbb33e6bf69d53d18a804c8b8132cf5ad146 + cd dep/vult && $(WGET) "https://github.com/vult-dsp/vult/releases/download/v0.4.15/vultc.h" + $(SHA256) $(vult) 5c5e6c7c92caacc10dacd8e4dd5e8134b520e630562e1f928ab1332218266638 FLAGS += -Idep/vult DEPS += $(vult) endif @@ -208,7 +242,7 @@ libpd := dep/lib/libpd.a SOURCES += src/LibPDEngine.cpp OBJECTS += $(libpd) DEPS += $(libpd) -FLAGS += -Idep/include/libpd -DHAVE_LIBDL +FLAGS += -Idep/include/libpd -DHAVE_LIBDL -DPDINSTANCE -DPDTHREADS ifdef ARCH_WIN # PD_INTERNAL leaves the function declarations for libpd unchanged @@ -223,8 +257,8 @@ endif $(libpd): cd dep && git clone "https://github.com/libpd/libpd.git" --recursive - cd dep/libpd && git checkout 5772a612527f06597d44d195843307ad0e3578fe - + cd dep/libpd && git checkout e3980d2fe45ef9eaaec1d45e4d68637eaf76a8b1 + ifdef ARCH_MAC # libpd's Makefile is handmade, and it doesn't honor CFLAGS and LDFLAGS environments. # So in order for Mac 10.15 (for example) to make a build that works on Mac 10.7+, we have to manually add DEP_MAC_SDK_FLAGS to CFLAGS and LDFLAGS. diff --git a/src/DuktapeEngine.cpp b/src/DuktapeEngine.cpp index d9db2b9..b4ac027 100644 --- a/src/DuktapeEngine.cpp +++ b/src/DuktapeEngine.cpp @@ -219,5 +219,5 @@ struct DuktapeEngine : ScriptEngine { __attribute__((constructor(1000))) static void constructor() { - addScriptEngine("js"); + addScriptEngine(".js"); } diff --git a/src/FaustEngine.cpp b/src/FaustEngine.cpp index 6d6a987..39008b2 100644 --- a/src/FaustEngine.cpp +++ b/src/FaustEngine.cpp @@ -29,6 +29,10 @@ #include #include #include +#if defined ARCH_WIN +#include +#include +#endif #pragma GCC diagnostic push #ifndef __clang__ @@ -250,7 +254,7 @@ class FaustEngine : public ScriptEngine { std::string temp_cache = "/tmp/VCVPrototype_" + generateSHA1(script); #elif defined ARCH_WIN char buf[MAX_PATH + 1] = {0}; - GetTempPath(sizeof(buf), buf); + GetTempPathA(sizeof(buf), buf); std::string temp_cache = std::string(buf) + "/VCVPrototype_" + generateSHA1(script); #endif std::string error_msg; @@ -369,5 +373,5 @@ class FaustEngine : public ScriptEngine { __attribute__((constructor(1000))) static void constructor() { - addScriptEngine("dsp"); + addScriptEngine(".dsp"); } diff --git a/src/LibPDEngine.cpp b/src/LibPDEngine.cpp index 7be549f..1786ce2 100644 --- a/src/LibPDEngine.cpp +++ b/src/LibPDEngine.cpp @@ -331,5 +331,5 @@ void LibPDEngine::sendInitialStates(const ProcessBlock* block) { __attribute__((constructor(1000))) static void constructor() { - addScriptEngine("pd"); + addScriptEngine(".pd"); } diff --git a/src/LuaJITEngine.cpp b/src/LuaJITEngine.cpp index 0ec77ef..df1fb59 100644 --- a/src/LuaJITEngine.cpp +++ b/src/LuaJITEngine.cpp @@ -1,5 +1,5 @@ #include "ScriptEngine.hpp" -#include +#include struct LuaJITEngine : ScriptEngine { @@ -246,5 +246,5 @@ struct LuaJITEngine : ScriptEngine { __attribute__((constructor(1000))) static void constructor() { - addScriptEngine("lua"); + addScriptEngine(".lua"); } diff --git a/src/Prototype.cpp b/src/Prototype.cpp index 71c0673..70c4d44 100644 --- a/src/Prototype.cpp +++ b/src/Prototype.cpp @@ -334,7 +334,7 @@ struct Prototype : Module { std::string extension = system::getExtension(path); scriptEngine = createScriptEngine(extension); if (!scriptEngine) { - message = string::f("No engine for .%s extension", extension.c_str()); + message = string::f("No engine for %s extension", extension.c_str()); return; } scriptEngine->module = this; @@ -406,13 +406,13 @@ struct Prototype : Module { } void newScriptDialog() { - std::string ext = "js"; + std::string ext = ".js"; // Get current extension if a script is currently loaded if (!path.empty()) { ext = system::getExtension(path); } std::string dir = asset::plugin(pluginInstance, "examples"); - std::string filename = "Untitled." + ext; + std::string filename = "Untitled" + ext; char* newPathC = osdialog_file(OSDIALOG_SAVE, dir.c_str(), filename.c_str(), NULL); if (!newPathC) { return; @@ -436,7 +436,7 @@ struct Prototype : Module { } // Copy template to new script - std::string templatePath = asset::plugin(pluginInstance, "examples/template." + ext); + std::string templatePath = asset::plugin(pluginInstance, "examples/template" + ext); { std::ifstream templateFile(templatePath, std::ios::binary); std::ofstream newFile(newPath, std::ios::binary); @@ -468,7 +468,7 @@ struct Prototype : Module { std::string ext = system::getExtension(path); std::string dir = asset::plugin(pluginInstance, "examples"); - std::string filename = "Untitled." + ext; + std::string filename = "Untitled" + ext; char* newPathC = osdialog_file(OSDIALOG_SAVE, dir.c_str(), filename.c_str(), NULL); if (!newPathC) { return; @@ -478,7 +478,7 @@ struct Prototype : Module { // Add extension if user didn't specify one std::string newExt = system::getExtension(newPath); if (newExt == "") - newPath += "." + ext; + newPath += ext; // Write and close file { @@ -504,7 +504,7 @@ struct Prototype : Module { (void) std::system(command.c_str()); #elif defined ARCH_WIN std::string command = editorPath + " \"" + path + "\""; - std::wstring commandW = string::toWstring(command); + std::wstring commandW = string::UTF8toUTF16(command); STARTUPINFOW startupInfo; std::memset(&startupInfo, 0, sizeof(startupInfo)); startupInfo.cb = sizeof(startupInfo); @@ -594,7 +594,7 @@ struct Prototype : Module { if (path == "") return ""; // HACK check if extension is .pd - if (system::getExtension(path) == "pd") + if (system::getExtension(path) == ".pd") return settingsPdEditorPath; return settingsEditorPath; } diff --git a/src/PythonEngine.cpp b/src/PythonEngine.cpp index edcb0ec..022699f 100644 --- a/src/PythonEngine.cpp +++ b/src/PythonEngine.cpp @@ -252,5 +252,5 @@ struct PythonEngine : ScriptEngine { __attribute__((constructor(1000))) static void constructor() { - addScriptEngine("py"); + addScriptEngine(".py"); } diff --git a/src/QuickJSEngine.cpp b/src/QuickJSEngine.cpp index d137d9b..b1de404 100644 --- a/src/QuickJSEngine.cpp +++ b/src/QuickJSEngine.cpp @@ -329,5 +329,5 @@ struct QuickJSEngine : ScriptEngine { __attribute__((constructor(1000))) static void constructor() { - addScriptEngine("js"); + addScriptEngine(".js"); } diff --git a/src/SuperColliderEngine.cpp b/src/SuperColliderEngine.cpp index 6db72b1..910c0df 100644 --- a/src/SuperColliderEngine.cpp +++ b/src/SuperColliderEngine.cpp @@ -405,6 +405,6 @@ bool SC_VcvPrototypeClient::copyArrayOfFloatArrays(const PyrSlot& inSlot, const __attribute__((constructor(1000))) static void constructor() { - addScriptEngine("sc"); - addScriptEngine("scd"); + addScriptEngine(".sc"); + addScriptEngine(".scd"); } diff --git a/src/VultEngine.cpp b/src/VultEngine.cpp index 4370f53..3bfd95d 100644 --- a/src/VultEngine.cpp +++ b/src/VultEngine.cpp @@ -11,7 +11,7 @@ // Special version of createScriptEngine that only creates Lua engines ScriptEngine* createLuaEngine() { - auto it = scriptEngineFactories.find("lua"); + auto it = scriptEngineFactories.find(".lua"); if (it == scriptEngineFactories.end()) return NULL; return it->second->createScriptEngine(); @@ -26,7 +26,10 @@ struct VultEngine : ScriptEngine { JSRuntime* rt = NULL; JSContext* ctx = NULL; + bool js_failure; + VultEngine() { + js_failure = false; rt = JS_NewRuntime(); // Create QuickJS context ctx = JS_NewContext(rt); @@ -41,9 +44,11 @@ struct VultEngine : ScriptEngine { JSValue val = JS_Eval(ctx, (const char*)vultc_h, vultc_h_size, "vultc.js", 0); if (JS_IsException(val)) { - display("Error loading the Vult compiler"); + WARN("Error loading the Vult compiler"); + WARN("%s", JS_ToCString(ctx, JS_ToString(ctx,val))); JS_FreeValue(ctx, val); JS_FreeValue(ctx, global_obj); + js_failure = true; return; } } @@ -62,6 +67,11 @@ struct VultEngine : ScriptEngine { } int run(const std::string& path, const std::string& script) override { + if (js_failure) { + display("Error loading the Vult compiler"); + return -1; + } + display("Loading..."); JSValue global_obj = JS_GetGlobalObject(ctx); @@ -119,7 +129,7 @@ struct VultEngine : ScriptEngine { JSValue luacode = JS_GetPropertyStr(ctx, first, "code"); std::string luacode_str(JS_ToCString(ctx, luacode)); - //WARN("Generated Code: %s", luacode_str.c_str()); + WARN("Generated Code: %s", luacode_str.c_str()); luaEngine = createLuaEngine(); @@ -142,13 +152,13 @@ struct VultEngine : ScriptEngine { } int process() override { - if (!luaEngine) - return -1; + if (!luaEngine || js_failure) + return -1; return luaEngine->process(); } }; __attribute__((constructor(1000))) static void constructor() { - addScriptEngine("vult"); + addScriptEngine(".vult"); }