diff --git a/CHANGELOG.md b/CHANGELOG.md index 20721cd5..14faa745 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,8 @@ - Added velocity mode to MIDI-Trig - Added MIDI multiplexing so multiple MIDI modules can use the same MIDI device on Windows - Made Module Browser layout more compact -- Add power meter -- Add icons to toolbar +- Added power meter +- Added icons to toolbar - [VCV Bridge](https://vcvrack.com/manual/Bridge.html) 0.6.1 - Replaced VST effect plugin with VST instrument plugin with audio inputs - Added MIDI support diff --git a/compile.mk b/compile.mk index fae30fb0..f9c12ac0 100644 --- a/compile.mk +++ b/compile.mk @@ -8,6 +8,9 @@ endif include $(RACK_DIR)/arch.mk +LD ?= ld +OBJCOPY ?= objcopy + FLAGS += -DVERSION=$(VERSION) # Generate dependency files alongside the object files FLAGS += -MMD -MP @@ -44,6 +47,7 @@ CXXFLAGS += $(FLAGS) # Derive object files from sources and place them before user-defined objects OBJECTS := $(patsubst %, build/%.o, $(SOURCES)) $(OBJECTS) +OBJECTS += $(patsubst %, build/%.bin.o, $(BINARIES)) DEPENDENCIES := $(patsubst %, build/%.d, $(SOURCES)) # Final targets @@ -53,23 +57,23 @@ $(TARGET): $(OBJECTS) -include $(DEPENDENCIES) -build/%.c.o: %.c | dep +build/%.c.o: %.c @mkdir -p $(@D) $(CC) $(CFLAGS) -c -o $@ $< -build/%.cpp.o: %.cpp | dep +build/%.cpp.o: %.cpp @mkdir -p $(@D) $(CXX) $(CXXFLAGS) -c -o $@ $< -build/%.cc.o: %.cc | dep +build/%.cc.o: %.cc @mkdir -p $(@D) $(CXX) $(CXXFLAGS) -c -o $@ $< -build/%.m.o: %.m | dep +build/%.m.o: %.m @mkdir -p $(@D) $(CC) $(CFLAGS) -c -o $@ $< -# Dummy target -dep: - -.PHONY: dep +build/%.bin.o: % + @mkdir -p $(@D) + $(LD) -r -b binary -o $@ $< + $(OBJCOPY) --rename-section .data=.rodata,alloc,load,readonly,data,contents $@ $@ diff --git a/include/util/common.hpp b/include/util/common.hpp index da46bcc2..13e19f75 100644 --- a/include/util/common.hpp +++ b/include/util/common.hpp @@ -55,6 +55,25 @@ Example: #define DEPRECATED __attribute__ ((deprecated)) +/** References binary files compiled into the program. +For example, to include a file "Test.dat" directly into your program binary, add + BINARIES += Test.dat +to your Makefile and declare + BINARY(Test_dat); +at the root of a .c or .cpp source file. Note that special characters are replaced with "_". Then use + BINARY_START(Test_dat) + BINARY_END(Test_dat) +to reference the data beginning and end as a void* array and + BINARY_SIZE(Test_dat) +to get its size in bytes. +*/ +#define BINARY(sym) extern char _binary_##sym##_start, _binary_##sym##_end, _binary_##sym##_size +#define BINARY_START(sym) ((void *) &_binary_##sym##_start) +#define BINARY_END(sym) ((void *) &_binary_##sym##_end) +// The symbol "_binary_##sym##_size" doesn't seem to be valid after a plugin is dynamically loaded, so simply take the difference between the two addresses. +#define BINARY_SIZE(sym) ((size_t) (&_binary_##sym##_end - &_binary_##sym##_start)) + + #include "util/math.hpp"