tentative x-platform makefiles + vst3 fixes

This commit is contained in:
Stefano D'Angelo 2024-01-30 15:41:30 +01:00
parent 03813fe631
commit 0ac57b290f
7 changed files with 179 additions and 40 deletions

View File

@ -1,26 +1,42 @@
include vars.mk include vars.mk
PHONY_TARGETS = all clean
ifeq ($(OS), Windows_NT) ifeq ($(OS), Windows_NT)
EXE_SUFFIX = .exe EXE_SUFFIX = .exe
else else
UNAME_S = $(shell uname -s)
EXE_SUFFIX = EXE_SUFFIX =
PHONY_TARGETS += install
PREFIX = /usr/local PREFIX = /usr/local
BINDIR = ${PREFIX}/bin BINDIR = ${PREFIX}/bin
endif endif
CC = gcc CC = gcc
CFLAGS = -I${TINYWAV_DIR} -I${MIDI_PARSER_DIR}/include -fPIC -Wall -Wpedantic -Wextra -Wno-unused-parameter CFLAGS = -I${TINYWAV_DIR} -I${MIDI_PARSER_DIR}/include -O3 -fPIC -Wall -Wpedantic -Wextra -Wno-unused-parameter
PROGRAM = ${BUNDLE_NAME}${EXE_SUFFIX} PROGRAM = ${BUNDLE_NAME}${EXE_SUFFIX}
all: build/${PROGRAM} all: build/${PROGRAM}
build/${PROGRAM}: src/main.c ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c | build ifeq ($(UNAME_S), Darwin)
${CC} $^ -o $@ ${CFLAGS} ${CFLAGS_EXTRA} ${LDFLAGS_EXTRA}
build/${PROGRAM}: build/tmp/x86_64 build/tmp/arm64
lipo -create -output $@ $^
build/tmp/x86_64: src/main.c src/data.h src/plugin.h ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c | build
${CC} src/main.c ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c -o $@ ${CFLAGS} ${CFLAGS_EXTRA} ${LDFLAGS_EXTRA} -arch x86_64
build/tmp/arm64: src/main.c src/data.h src/plugin.h ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c | build
${CC} src/main.c ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c -o $@ ${CFLAGS} ${CFLAGS_EXTRA} ${LDFLAGS_EXTRA} -arch arm64
build/tmp:
mkdir -p $@
else
build/${PROGRAM}: src/main.c src/data.h src/plugin.h ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c | build
${CC} src/main.c ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c -o $@ ${CFLAGS} ${CFLAGS_EXTRA} ${LDFLAGS_EXTRA}
endif
build: build:
mkdir -p $@ mkdir -p $@
@ -28,10 +44,16 @@ build:
clean: clean:
rm -fr build rm -fr build
ifneq ($(OS), Windows_NT) ifeq ($(OS), Windows_NT)
.PHONY: all clean
else
install: all install: all
mkdir -p -m 0755 ${BINDIR} mkdir -p -m 0755 ${BINDIR}
install -m 0755 build/${PROGRAM} ${BINDIR} install -m 0755 build/${PROGRAM} ${BINDIR}
endif
.PHONY: ${PHONY_TARGETS} .PHONY: all clean install
endif

View File

@ -6,23 +6,24 @@ ifeq ($(OS), Windows_NT)
APPDATA = $(shell echo '${APPDATA}' | sed 's:\\:/:g') APPDATA = $(shell echo '${APPDATA}' | sed 's:\\:/:g')
LV2DIR = ${COMMONPROGRAMFILES}/LV2 LV2DIR = ${COMMONPROGRAMFILES}/LV2
LV2DIR_USER = ${APPDATA}/LV2 LV2DIR_USER = ${APPDATA}/LV2
CC = gcc
else else
UNAME_S = $(shell uname -s) UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S), Darwin) ifeq ($(UNAME_S), Darwin)
DLL_SUFFIX = .dylib DLL_SUFFIX = .dylib
LV2DIR = /Library/Audio/Plug-Ins/LV2 LV2DIR = /Library/Audio/Plug-Ins/LV2
LV2DIR_USER = ${HOME}/Library/Audio/Plug-Ins/LV2 LV2DIR_USER = ${HOME}/Library/Audio/Plug-Ins/LV2
CC = clang
else else
DLL_SUFFIX = .so DLL_SUFFIX = .so
PREFIX = /usr/local PREFIX = /usr/local
LV2DIR = ${PREFIX}/lib/lv2 LV2DIR = ${PREFIX}/lib/lv2
LV2DIR_USER = ${HOME}/.lv2 LV2DIR_USER = ${HOME}/.lv2
CC = gcc
endif endif
endif endif
CC = gcc CFLAGS = -O3 -fPIC -Wall -Wpedantic -Wextra -Wno-unused-parameter
CFLAGS = -fPIC -Wall -Wpedantic -Wextra -Wno-unused-parameter
LDFLAGS = -shared LDFLAGS = -shared
BUNDLE_DIR = ${BUNDLE_NAME}.lv2 BUNDLE_DIR = ${BUNDLE_NAME}.lv2
@ -34,8 +35,26 @@ 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/manifest.ttl.in | build/${BUNDLE_DIR}
cat $^ | sed s/@DLL_SUFFIX@/${DLL_SUFFIX}/g > $@ cat $^ | sed s/@DLL_SUFFIX@/${DLL_SUFFIX}/g > $@
build/${BUNDLE_DIR}/${DLL_FILE}: src/lv2.c | build/${BUNDLE_DIR} ifeq ($(UNAME_S), Darwin)
${CC} $^ -o $@ ${CFLAGS} ${CFLAGS_EXTRA} ${LDFLAGS} ${LDFLAGS_EXTRA}
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} ${CFLAGS_EXTRA} ${LDFLAGS} ${LDFLAGS_EXTRA} -arch x86_64
build/tmp/arm64: src/lv2.c src/data.h src/plugin.h | build/tmp
${CC} src/lv2.c -o $@ ${CFLAGS} ${CFLAGS_EXTRA} ${LDFLAGS} ${LDFLAGS_EXTRA} -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} ${CFLAGS_EXTRA} ${LDFLAGS} ${LDFLAGS_EXTRA}
endif
build/${BUNDLE_DIR}: build/${BUNDLE_DIR}:
mkdir -p $@ mkdir -p $@
@ -44,13 +63,13 @@ clean:
rm -fr build rm -fr build
install: all install: all
mkdir -p -m 0755 ${LV2DIR}/${BUNDLE_DIR} mkdir -p -m 0755 "${LV2DIR}/${BUNDLE_DIR}"
install -m 0644 build/${BUNDLE_DIR}/manifest.ttl ${LV2DIR}/${BUNDLE_DIR} install -m 0644 build/${BUNDLE_DIR}/manifest.ttl "${LV2DIR}/${BUNDLE_DIR}"
install -m 0755 build/${BUNDLE_DIR}/${DLL_FILE} ${LV2DIR}/${BUNDLE_DIR} install -m 0755 build/${BUNDLE_DIR}/${DLL_FILE} "${LV2DIR}/${BUNDLE_DIR}"
install-user: all install-user: all
mkdir -p -m 0755 ${LV2DIR_USER}/${BUNDLE_DIR} mkdir -p -m 0755 "${LV2DIR_USER}/${BUNDLE_DIR}"
install -m 0644 build/${BUNDLE_DIR}/manifest.ttl ${LV2DIR_USER}/${BUNDLE_DIR} install -m 0644 build/${BUNDLE_DIR}/manifest.ttl "${LV2DIR_USER}/${BUNDLE_DIR}"
install -m 0755 build/${BUNDLE_DIR}/${DLL_FILE} ${LV2DIR_USER}/${BUNDLE_DIR} install -m 0755 build/${BUNDLE_DIR}/${DLL_FILE} "${LV2DIR_USER}/${BUNDLE_DIR}"
.PHONY: all clean install install-user .PHONY: all clean install install-user

View File

@ -1,27 +1,94 @@
include vars.mk include vars.mk
CC = gcc ifeq ($(OS), Windows_NT)
DLL_SUFFIX = .vst3
PLATFORM = x86_64-win
COMMONPROGRAMFILES = $(shell echo '${COMMONPROGRAMFILES}' | sed 's:\\:/:g')
LOCALAPPDATA = $(shell echo '${LOCALAPPDATA}' | sed 's:\\:/:g')
VST3DIR = ${COMMONPROGRAMFILES}/VST3
VST3DIR_USER = ${LOCALAPPDATA}/VST3
CC = gcc
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S), Darwin)
DLL_SUFFIX =
PLATFORM = MacOS
VST3DIR = /Library/Audio/Plug-Ins/VST3
VST3DIR_USER = ${HOME}/Library/Audio/Plug-Ins/VST3
CC = clang
else
DLL_SUFFIX = .so
PLATFORM = $(shell uname -m)-linux
VST3DIR = /usr/local/lib/vst3
VST3DIR_USER = ${HOME}/.vst3
CC = gcc
endif
endif
CFLAGS = -fPIC -Wall -Wpedantic -Wextra -Wno-unused-parameter CFLAGS = -O3 -fPIC -Wall -Wpedantic -Wextra -Wno-unused-parameter
LDFLAGS = -shared -lm LDFLAGS = -shared -lm
BUNDLE_DIR = ${BUNDLE_NAME}.vst3 BUNDLE_DIR = ${BUNDLE_NAME}.vst3
SO_DIR = $(shell uname -m)-linux DLL_DIR = Contents/${PLATFORM}
SO_FILE = ${SO_DIR}/${BUNDLE_NAME}.so DLL_FILE = ${DLL_DIR}/${BUNDLE_NAME}${DLL_SUFFIX}
all: build/${BUNDLE_DIR}/Contents/Info.plist build/${BUNDLE_DIR}/Contents/${SO_FILE} ifeq ($(UNAME_S), Darwin)
all: build/${BUNDLE_DIR}/${DLL_FILE} build/${BUNDLE_DIR}/Contents/Info.plist
build/${BUNDLE_DIR}/Contents/Info.plist: data/Info.plist | build/${BUNDLE_DIR}/Contents build/${BUNDLE_DIR}/Contents/Info.plist: data/Info.plist | build/${BUNDLE_DIR}/Contents
cp $^ $@ cp $^ $@
build/${BUNDLE_DIR}/Contents/${SO_FILE}: src/vst3.c | build/${BUNDLE_DIR}/Contents/${SO_DIR} build/${BUNDLE_DIR}/${DLL_FILE}: build/tmp/x86_64 build/tmp/arm64 | buindle/${BUNDLE_DIR}/Contents
${CC} $^ -o $@ ${CFLAGS} ${CFLAGS_EXTRA} ${LDFLAGS} ${LDFLAGS_EXTRA} lipo -create -output $@ $^
build/${BUNDLE_DIR}/Contents build/${BUNDLE_DIR}/Contents/${SO_DIR}: build/tmp/x86_64: src/vst3.c src/data.h src/plugin.h | build/tmp
${CC} src/vst3.c -o $@ ${CFLAGS} ${CFLAGS_EXTRA} ${LDFLAGS} ${LDFLAGS_EXTRA} -arch x86_64
build/tmp/arm64: src/vst3.c src/data.h src/plugin.h | build/tmp
${CC} src/vst3.c -o $@ ${CFLAGS} ${CFLAGS_EXTRA} ${LDFLAGS} ${LDFLAGS_EXTRA} -arch arm64
build/tmp:
mkdir -p $@
else
all: build/${BUNDLE_DIR}/${DLL_FILE}
build/${BUNDLE_DIR}/${DLL_FILE}: src/vst3.c src/data.h | build/${BUNDLE_DIR}/${DLL_DIR}
${CC} src/vst3.c -o $@ ${CFLAGS} ${CFLAGS_EXTRA} ${LDFLAGS} ${LDFLAGS_EXTRA}
endif
build/${BUNDLE_DIR}/Contents build/${BUNDLE_DIR}/${DLL_DIR}:
mkdir -p $@ mkdir -p $@
clean: clean:
rm -fr build rm -fr build
.PHONY: all clean ifeq ($(UNAME_S), Darwin)
install: all
mkdir -p -m 0755 "${VST3DIR}/${BUNDLE_DIR}/${DLL_DIR}"
install -m 0755 build/${BUNDLE_DIR}/${DLL_FILE} "${VST3DIR}/${BUNDLE_DIR}/${DLL_DIR}"
install -m 0644 build/${BUNDLE_DIR}/Contents/Info.plist "${VST3DIR}/${BUNDLE_DIR}/Contents/Info.plist"
install-user: all
mkdir -p -m 0755 "${VST3DIR_USER}/${BUNDLE_DIR}/${DLL_DIR}"
install -m 0755 build/${BUNDLE_DIR}/${DLL_FILE} "${VST3DIR_USER}/${BUNDLE_DIR}/${DLL_DIR}"
install -m 0644 build/${BUNDLE_DIR}/Contents/Info.plist "${VST3DIR_USER}/${BUNDLE_DIR}/Contents/Info.plist"
else
install: all
mkdir -p -m 0755 "${VST3DIR}/${BUNDLE_DIR}/${DLL_DIR}"
install -m 0755 build/${BUNDLE_DIR}/${DLL_FILE} "${VST3DIR}/${BUNDLE_DIR}/${DLL_DIR}"
install-user: all
mkdir -p -m 0755 "${VST3DIR_USER}/${BUNDLE_DIR}/${DLL_DIR}"
install -m 0755 build/${BUNDLE_DIR}/${DLL_FILE} "${VST3DIR_USER}/${BUNDLE_DIR}/${DLL_DIR}"
endif
.PHONY: all clean install install-user

View File

@ -1 +0,0 @@
BNDL????

View File

@ -1,2 +0,0 @@
[.ShellClassInfo]
IconResource=Plugin.ico,0

View File

@ -162,6 +162,8 @@ static struct Steinberg_Vst_ParameterInfo parameterInfo[DATA_PRODUCT_PARAMETERS_
{{~}} {{~}}
}; };
# if DATA_PRODUCT_PARAMETERS_N > 0
# define DATA_PARAM_BYPASS 1 # define DATA_PARAM_BYPASS 1
# define DATA_PARAM_TOGGLED (1<<1) # define DATA_PARAM_TOGGLED (1<<1)
# define DATA_PARAM_INTEGER (1<<2) # define DATA_PARAM_INTEGER (1<<2)
@ -187,6 +189,9 @@ static struct {
}, },
{{~}} {{~}}
}; };
# endif
#endif #endif
{{?it.product.parameters.find(x => x.isLatency)}} {{?it.product.parameters.find(x => x.isLatency)}}

View File

@ -530,6 +530,8 @@ static void processParams(pluginInstance *p, struct Steinberg_Vst_ProcessData *d
data[1] = 1; data[1] = 1;
data[2] = (uint8_t)(127.0 * v); data[2] = (uint8_t)(127.0 * v);
break; break;
default:
continue;
} }
plugin_midi_msg_in(&p->p, midiInIndex[index], data); plugin_midi_msg_in(&p->p, midiInIndex[index], data);
continue; continue;
@ -773,9 +775,16 @@ static Steinberg_tresult controllerInitialize(void* thisInterface, struct Steinb
if (c->context != NULL) if (c->context != NULL)
return Steinberg_kResultFalse; return Steinberg_kResultFalse;
c->context = context; c->context = context;
#if DATA_PRODUCT_PARAMETERS_N + DATA_PRODUCT_BUSES_MIDI_INPUT_N > 0 #if DATA_PRODUCT_PARAMETERS_N > 0
for (int i = 0; i < DATA_PRODUCT_PARAMETERS_N + 3 * DATA_PRODUCT_BUSES_MIDI_INPUT_N; i++) for (int i = 0; i < DATA_PRODUCT_PARAMETERS_N; i++)
c->parameters[i] = parameterData[i].def; c->parameters[i] = parameterData[i].def;
#endif
#if DATA_PRODUCT_BUSES_MIDI_INPUT_N > 0
for (int i = DATA_PRODUCT_PARAMETERS_N; i < DATA_PRODUCT_PARAMETERS_N + 3 * DATA_PRODUCT_BUSES_MIDI_INPUT_N; i += 3) {
c->parameters[i] = 0.0;
c->parameters[i + 1] = 0.5;
c->parameters[i + 2] = 0.0;
}
#endif #endif
return Steinberg_kResultOk; return Steinberg_kResultOk;
} }
@ -1260,14 +1269,34 @@ static Steinberg_IPluginFactory3Vtbl factoryVtbl = {
}; };
static Steinberg_IPluginFactory3 factory = { &factoryVtbl }; static Steinberg_IPluginFactory3 factory = { &factoryVtbl };
#ifdef _WIN32
#define EXPORT __declspec(dllexport)
#else
#define EXPORT __attribute__((visibility("default")))
#endif
EXPORT
Steinberg_IPluginFactory * GetPluginFactory() { Steinberg_IPluginFactory * GetPluginFactory() {
return (Steinberg_IPluginFactory *)&factory; return (Steinberg_IPluginFactory *)&factory;
} }
char ModuleEntry (void *handle) { #ifndef _WIN32
# if defined(__APPLE__)
# define ENTRY bundleEntry
# define EXIT bundleExit
# else
# define ENTRY ModuleEntry
# define EXIT ModuleExit
# endif
EXPORT
char ENTRY(void *handle) {
return 1; return 1;
} }
char ModuleExit () { EXPORT
char EXIT() {
return 1; return 1;
} }
#endif