Browse Source

Merge 73052e16a1 into f693e76333

pull/73/merge
Steve Russell GitHub 2 years ago
parent
commit
8e6d9a884f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 92 additions and 44 deletions
  1. +54
    -20
      Makefile
  2. +1
    -1
      src/DuktapeEngine.cpp
  3. +6
    -2
      src/FaustEngine.cpp
  4. +1
    -1
      src/LibPDEngine.cpp
  5. +2
    -2
      src/LuaJITEngine.cpp
  6. +8
    -8
      src/Prototype.cpp
  7. +1
    -1
      src/PythonEngine.cpp
  8. +1
    -1
      src/QuickJSEngine.cpp
  9. +2
    -2
      src/SuperColliderEngine.cpp
  10. +16
    -6
      src/VultEngine.cpp

+ 54
- 20
Makefile View File

@@ -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.


+ 1
- 1
src/DuktapeEngine.cpp View File

@@ -219,5 +219,5 @@ struct DuktapeEngine : ScriptEngine {

__attribute__((constructor(1000)))
static void constructor() {
addScriptEngine<DuktapeEngine>("js");
addScriptEngine<DuktapeEngine>(".js");
}

+ 6
- 2
src/FaustEngine.cpp View File

@@ -29,6 +29,10 @@
#include <vector>
#include <algorithm>
#include <functional>
#if defined ARCH_WIN
#include <fileapi.h>
#include <windef.h>
#endif

#pragma GCC diagnostic push
#ifndef __clang__
@@ -250,7 +254,7 @@ public:
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 @@ private:

__attribute__((constructor(1000)))
static void constructor() {
addScriptEngine<FaustEngine>("dsp");
addScriptEngine<FaustEngine>(".dsp");
}

+ 1
- 1
src/LibPDEngine.cpp View File

@@ -331,5 +331,5 @@ void LibPDEngine::sendInitialStates(const ProcessBlock* block) {

__attribute__((constructor(1000)))
static void constructor() {
addScriptEngine<LibPDEngine>("pd");
addScriptEngine<LibPDEngine>(".pd");
}

+ 2
- 2
src/LuaJITEngine.cpp View File

@@ -1,5 +1,5 @@
#include "ScriptEngine.hpp"
#include <luajit-2.0/lua.hpp>
#include <luajit-2.1/lua.hpp>


struct LuaJITEngine : ScriptEngine {
@@ -246,5 +246,5 @@ struct LuaJITEngine : ScriptEngine {

__attribute__((constructor(1000)))
static void constructor() {
addScriptEngine<LuaJITEngine>("lua");
addScriptEngine<LuaJITEngine>(".lua");
}

+ 8
- 8
src/Prototype.cpp View File

@@ -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;
}


+ 1
- 1
src/PythonEngine.cpp View File

@@ -252,5 +252,5 @@ struct PythonEngine : ScriptEngine {

__attribute__((constructor(1000)))
static void constructor() {
addScriptEngine<PythonEngine>("py");
addScriptEngine<PythonEngine>(".py");
}

+ 1
- 1
src/QuickJSEngine.cpp View File

@@ -329,5 +329,5 @@ struct QuickJSEngine : ScriptEngine {

__attribute__((constructor(1000)))
static void constructor() {
addScriptEngine<QuickJSEngine>("js");
addScriptEngine<QuickJSEngine>(".js");
}

+ 2
- 2
src/SuperColliderEngine.cpp View File

@@ -405,6 +405,6 @@ bool SC_VcvPrototypeClient::copyArrayOfFloatArrays(const PyrSlot& inSlot, const

__attribute__((constructor(1000)))
static void constructor() {
addScriptEngine<SuperColliderEngine>("sc");
addScriptEngine<SuperColliderEngine>("scd");
addScriptEngine<SuperColliderEngine>(".sc");
addScriptEngine<SuperColliderEngine>(".scd");
}

+ 16
- 6
src/VultEngine.cpp View File

@@ -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<VultEngine>("vult");
addScriptEngine<VultEngine>(".vult");
}

Loading…
Cancel
Save