diff --git a/templates/lv2-make/Makefile b/templates/lv2-make/Makefile index ad2ece6..3125e69 100644 --- a/templates/lv2-make/Makefile +++ b/templates/lv2-make/Makefile @@ -21,8 +21,12 @@ else endif endif +COMMON_DIR := $(or $(COMMON_DIR),.) +DATA_DIR := $(or $(DATA_DIR),.) +PLUGIN_DIR := $(or $(PLUGIN_DIR),src) + CFLAGS = -O3 -Wall -Wpedantic -Wextra -CFLAGS_ALL = -fPIC ${CFLAGS} ${CFLAGS_EXTRA} +CFLAGS_ALL = -I${DATA_DIR}/src -I${PLUGIN_DIR} -fPIC ${CFLAGS} ${CFLAGS_EXTRA} LDFLAGS = LDFLAGS_ALL = -shared ${LDFLAGS} ${LDFLAGS_EXTRA} @@ -33,7 +37,7 @@ DLL_FILE = ${BUNDLE_NAME}${DLL_SUFFIX} all: build/${BUNDLE_DIR}/manifest.ttl build/${BUNDLE_DIR}/${DLL_FILE} -build/${BUNDLE_DIR}/manifest.ttl: data/manifest.ttl.in | build/${BUNDLE_DIR} +build/${BUNDLE_DIR}/manifest.ttl: ${DATA_DIR}/data/manifest.ttl.in | build/${BUNDLE_DIR} cat $^ | sed s/@DLL_SUFFIX@/${DLL_SUFFIX}/g > $@ ifeq ($(UNAME_S), Darwin) @@ -41,19 +45,19 @@ ifeq ($(UNAME_S), Darwin) build/${BUNDLE_DIR}/${DLL_FILE}: build/tmp/x86_64 build/tmp/arm64 | build/${BUNDLE_DIR} lipo -create -output $@ $^ -build/tmp/x86_64: src/lv2.c src/data.h src/plugin.h | build/tmp - ${CC} src/lv2.c -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL} -arch x86_64 +build/tmp/x86_64: ${COMMON_DIR}/src/lv2.c ${DATA_DIR}/src/data.h ${PLUGIN_DIR}/plugin.h | build/tmp + ${CC} ${COMMON_DIR}/src/lv2.c -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL} -arch x86_64 -build/tmp/arm64: src/lv2.c src/data.h src/plugin.h | build/tmp - ${CC} src/lv2.c -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL} -arch arm64 +build/tmp/arm64: ${COMMON_DIR}/src/lv2.c ${DATA_DIR}/src/data.h ${PLUGIN_DIR}/plugin.h | build/tmp + ${CC} ${COMMON_DIR}/src/lv2.c -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL} -arch arm64 build/tmp: mkdir -p $@ else -build/${BUNDLE_DIR}/${DLL_FILE}: src/lv2.c src/data.h | build/${BUNDLE_DIR} - ${CC} src/lv2.c -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL} +build/${BUNDLE_DIR}/${DLL_FILE}: ${COMMON_DIR}/src/lv2.c ${DATA_DIR}/src/data.h ${PLUGIN_DIR}/plugin.h | build/${BUNDLE_DIR} + ${CC} ${COMMON_DIR}/src/lv2.c -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL} endif diff --git a/templates/lv2-make/vars.mk b/templates/lv2-make/vars.mk index 657892f..df24782 100644 --- a/templates/lv2-make/vars.mk +++ b/templates/lv2-make/vars.mk @@ -1,3 +1,6 @@ BUNDLE_NAME := {{=it.product.bundleName}} CFLAGS_EXTRA := {{=it.make && it.make.cflags ? it.make.cflags : ""}} {{=it.lv2_make && it.lv2_make.cflags ? it.lv2_make.cflags : ""}} LDFLAGS_EXTRA := {{=it.make && it.make.ldflags ? it.make.ldflags : ""}} {{=it.lv2_make && it.lv2_make.ldflags ? it.lv2_make.ldflags : ""}} +COMMON_DIR := {{=it.lv2_make && it.lv2_make.commonDir ? it.lv2_make.commonDir : (it.make && it.make.commonDir ? it.make.commonDir : "")}} +DATA_DIR := {{=it.lv2_make && it.lv2_make.dataDir ? it.lv2_make.dataDir : (it.make && it.make.dataDir ? it.make.dataDir : "")}} +PLUGIN_DIR := {{=it.lv2_make && it.lv2_make.pluginDir ? it.lv2_make.pluginDir : (it.make && it.make.pluginDir ? it.make.pluginDir : "")}} diff --git a/templates/lv2/src/lv2.c b/templates/lv2/src/lv2.c index 9ef088f..73b024a 100644 --- a/templates/lv2/src/lv2.c +++ b/templates/lv2/src/lv2.c @@ -71,6 +71,8 @@ static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double s } instance->uri_midi_MidiEvent = instance->map->map(instance->map->handle, LV2_MIDI__MidiEvent); +#else + (void)features; #endif plugin_init(&instance->p); @@ -230,6 +232,8 @@ static void run(LV2_Handle instance, uint32_t sample_count) { if (i->c[k] != NULL) *i->c[k] = plugin_get_parameter(&i->p, k); } +#else + (void)plugin_get_parameter; #endif } diff --git a/templates/lv2/tibia-index.js b/templates/lv2/tibia-index.js index b6d14db..d27367a 100644 --- a/templates/lv2/tibia-index.js +++ b/templates/lv2/tibia-index.js @@ -1,105 +1,107 @@ var path = require("path"); var sep = path.sep; -module.exports = function (data, api) { - data.tibia.lv2 = { - prefixes: [ - { id: "atom", uri: "http://lv2plug.in/ns/ext/atom#" }, - { id: "doap", uri: "http://usefulinc.com/ns/doap#" }, - { id: "foaf", uri: "http://xmlns.com/foaf/0.1/" }, - { id: "log", uri: "http://lv2plug.in/ns/ext/log#" }, - { id: "lv2", uri: "http://lv2plug.in/ns/lv2core#" }, - { id: "midi", uri: "http://lv2plug.in/ns/ext/midi#" }, - { id: "pprops", uri: "http://lv2plug.in/ns/ext/port-props#" }, - { id: "rdf", uri: "http://www.w3.org/1999/02/22-rdf-syntax-ns#" }, - { id: "rdfs", uri: "http://www.w3.org/2000/01/rdf-schema#" }, - { id: "units", uri: "http://lv2plug.in/ns/extensions/units#" }, - { id: "urid", uri: "http://lv2plug.in/ns/ext/urid#" } - ], - units: { - "bar": "@units:bar", - "beat": "@units:beat", - "bpm": "@units:bpm", - "cent": "@units:cent", - "cm": "@units:cm", - "coef": "@units:coef", - "db": "@units:db", - "degree": "@units:degree", - "frame": "@units:frame", - "hz": "@units:hz", - "inch": "@units:inch", - "khz": "@units:khz", - "km": "@units:km", - "m": "@units:m", - "mhz": "@units:mhz", - "midiNote": "@units:midiNote", - "mile": "@units:mile", - "min": "@units:min", - "mm": "@units:mm", - "ms": "@units:ms", - "oct": "@units:oct", - "pc": "@units:pc", - "s": "@units:s", - "semitone12TET": "@units:semitone12TET" - }, - ports: [], +module.exports = function (data, api, outputCommon, outputData) { + if (outputData) { + data.tibia.lv2 = { + prefixes: [ + { id: "atom", uri: "http://lv2plug.in/ns/ext/atom#" }, + { id: "doap", uri: "http://usefulinc.com/ns/doap#" }, + { id: "foaf", uri: "http://xmlns.com/foaf/0.1/" }, + { id: "log", uri: "http://lv2plug.in/ns/ext/log#" }, + { id: "lv2", uri: "http://lv2plug.in/ns/lv2core#" }, + { id: "midi", uri: "http://lv2plug.in/ns/ext/midi#" }, + { id: "pprops", uri: "http://lv2plug.in/ns/ext/port-props#" }, + { id: "rdf", uri: "http://www.w3.org/1999/02/22-rdf-syntax-ns#" }, + { id: "rdfs", uri: "http://www.w3.org/2000/01/rdf-schema#" }, + { id: "units", uri: "http://lv2plug.in/ns/extensions/units#" }, + { id: "urid", uri: "http://lv2plug.in/ns/ext/urid#" } + ], + units: { + "bar": "@units:bar", + "beat": "@units:beat", + "bpm": "@units:bpm", + "cent": "@units:cent", + "cm": "@units:cm", + "coef": "@units:coef", + "db": "@units:db", + "degree": "@units:degree", + "frame": "@units:frame", + "hz": "@units:hz", + "inch": "@units:inch", + "khz": "@units:khz", + "km": "@units:km", + "m": "@units:m", + "mhz": "@units:mhz", + "midiNote": "@units:midiNote", + "mile": "@units:mile", + "min": "@units:min", + "mm": "@units:mm", + "ms": "@units:ms", + "oct": "@units:oct", + "pc": "@units:pc", + "s": "@units:s", + "semitone12TET": "@units:semitone12TET" + }, + ports: [], - ttlURI: function (uri) { - return uri.charAt(0) == "@" ? uri.substring(1) : "<" + uri + ">"; - }, + ttlURI: function (uri) { + return uri.charAt(0) == "@" ? uri.substring(1) : "<" + uri + ">"; + }, - expandURI: function (uri) { - if (uri.charAt(0) != "@") - return uri; - var i = uri.indexOf(":"); - var p = uri.substring(1, uri.indexOf(":")); - return data.tibia.lv2.prefixes.find(x => x.id == p).uri + uri.substring(i + 1); - } - }; - - for (var id in data.lv2.prefixes) - data.tibia.lv2.prefixes.push({ id: id, uri: data.lv2.prefixes[id] }); - - var buses = data.product.buses; - var audioPorts = []; - var midiPorts = []; - for (var bi = 0; bi < buses.length; bi++) { - var b = buses[bi]; - if (b.type == "audio") { - if (b.channels == "mono") { - var e = { type: "audio", direction: b.direction, name: b.name, sidechain: b.sidechain, cv: b.cv, optional: b.optional, busIndex: bi }; - e.symbol = data.lv2.busSymbols[bi]; - audioPorts.push(e); - } else { - var e = { type: "audio", direction: b.direction, name: b.name + " Left", shortName: b.shortName + " L", sidechain: b.sidechain, cv: b.cv, busIndex: bi }; - e.symbol = data.lv2.busSymbols[bi] + "_L"; - data.tibia.lv2.ports.push(e); - var e = { type: "audio", direction: b.direction, name: b.name + " Right", shortName: b.shortName + " R", sidechain: b.sidechain, cv: b.cv, busIndex: bi }; - e.symbol = data.lv2.busSymbols[bi] + "_R"; - audioPorts.push(e); + expandURI: function (uri) { + if (uri.charAt(0) != "@") + return uri; + var i = uri.indexOf(":"); + var p = uri.substring(1, uri.indexOf(":")); + return data.tibia.lv2.prefixes.find(x => x.id == p).uri + uri.substring(i + 1); } - } else { - var e = { type: "midi", direction: b.direction, name: b.name, sidechain: b.sidechain, control: b.control, optional: b.optional, busIndex: bi }; - e.symbol = data.lv2.busSymbols[bi]; - midiPorts.push(e); - } - } - audioPorts.sort((a, b) => a.direction != b.direction ? (a.direction == "input" ? -1 : 1) : 0); - midiPorts.sort((a, b) => a.direction != b.direction ? (a.direction == "input" ? -1 : 1) : 0); - data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, audioPorts); - data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, midiPorts); + }; - var ports = []; - for (var i = 0; i < data.product.parameters.length; i++) { - var p = data.product.parameters[i]; - var e = Object.create(p); - e.type = "control"; - e.symbol = data.lv2.parameterSymbols[i]; - e.paramIndex = i; - ports.push(e); + for (var id in data.lv2.prefixes) + data.tibia.lv2.prefixes.push({ id: id, uri: data.lv2.prefixes[id] }); + + var buses = data.product.buses; + var audioPorts = []; + var midiPorts = []; + for (var bi = 0; bi < buses.length; bi++) { + var b = buses[bi]; + if (b.type == "audio") { + if (b.channels == "mono") { + var e = { type: "audio", direction: b.direction, name: b.name, sidechain: b.sidechain, cv: b.cv, optional: b.optional, busIndex: bi }; + e.symbol = data.lv2.busSymbols[bi]; + audioPorts.push(e); + } else { + var e = { type: "audio", direction: b.direction, name: b.name + " Left", shortName: b.shortName + " L", sidechain: b.sidechain, cv: b.cv, busIndex: bi }; + e.symbol = data.lv2.busSymbols[bi] + "_L"; + data.tibia.lv2.ports.push(e); + var e = { type: "audio", direction: b.direction, name: b.name + " Right", shortName: b.shortName + " R", sidechain: b.sidechain, cv: b.cv, busIndex: bi }; + e.symbol = data.lv2.busSymbols[bi] + "_R"; + audioPorts.push(e); + } + } else { + var e = { type: "midi", direction: b.direction, name: b.name, sidechain: b.sidechain, control: b.control, optional: b.optional, busIndex: bi }; + e.symbol = data.lv2.busSymbols[bi]; + midiPorts.push(e); + } + } + audioPorts.sort((a, b) => a.direction != b.direction ? (a.direction == "input" ? -1 : 1) : 0); + midiPorts.sort((a, b) => a.direction != b.direction ? (a.direction == "input" ? -1 : 1) : 0); + data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, audioPorts); + data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, midiPorts); + + var ports = []; + for (var i = 0; i < data.product.parameters.length; i++) { + var p = data.product.parameters[i]; + var e = Object.create(p); + e.type = "control"; + e.symbol = data.lv2.parameterSymbols[i]; + e.paramIndex = i; + ports.push(e); + } + ports.sort((a, b) => a.direction != b.direction ? (a.direction == "input" ? -1 : 1) : 0); + data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, ports); } - ports.sort((a, b) => a.direction != b.direction ? (a.direction == "input" ? -1 : 1) : 0); - data.tibia.lv2.ports.push.apply(data.tibia.lv2.ports, ports); api.generateFileFromTemplateFile(`data${sep}manifest.ttl.in`, `data${sep}manifest.ttl.in`, data); api.copyFile(`src${sep}lv2.c`, `src${sep}lv2.c`); diff --git a/tibia b/tibia index 51302c5..f531dbe 100755 --- a/tibia +++ b/tibia @@ -144,4 +144,4 @@ data.tibia = { } }; -require(path.resolve(template + path.sep + "tibia-index.js"))(data, api); +require(path.resolve(template + path.sep + "tibia-index.js"))(data, api, outputCommon, outputData);