-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
147 lines (95 loc) · 3.48 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
RACK_DIR ?= ../..
FLAGS += -Isrc
CFLAGS +=
CXXFLAGS +=
LDFLAGS +=
SOURCES = $(shell find src -name "*.cpp")
DISTRIBUTABLES += LICENSE.txt presets svg
include $(RACK_DIR)/plugin.mk
# Above this line: Standard plugin build configuration
########################################################################
# Below this line: Special configuration and targets for Dale
########################################################################
#
# Build and run the tests
#
########################################################################
DHEUNIT_SRC = dheunit
DHEUNIT_INCLUDE_DIR = $(DHEUNIT_SRC)/dheunit
$(DHEUNIT_INCLUDE_DIR):
git submodule update --init --recursive
RACK_INCLUDES = -I$(RACK_DIR)/include -I$(RACK_DIR)/dep/include
TEST_INCLUDES = -Itest -I$(DHEUNIT_SRC)
TEST_CXXFLAGS = $(filter-out $(RACK_INCLUDES),$(CXXFLAGS)) $(TEST_INCLUDES)
TEST_SOURCES = $(shell find test -name "*.cpp")
TEST_OBJECTS := $(patsubst %, build/%.o, $(TEST_SOURCES))
-include $(TEST_OBJECTS:.o=.d)
$(TEST_OBJECTS): $(DHEUNIT_INCLUDE_DIR)
$(TEST_OBJECTS): CXXFLAGS := $(TEST_CXXFLAGS)
TEST_RUNNER = build/dheunit
$(TEST_RUNNER): $(TEST_OBJECTS)
@mkdir -p $(@D)
$(CXX) -o $@ $^
.PHONY: test vtest
test: $(TEST_RUNNER)
$<
vtest: $(TEST_RUNNER)
$< --verbose
########################################################################
#
# Stage the plugin and run Rack
#
########################################################################
PLUGIN_ZIP_NAME := $(SLUG)-$(VERSION)-mac.vcvplugin
DIST_PLUGIN_ZIP := dist/$(PLUGIN_ZIP_NAME)
STAGING_DIRNAME := .stage
STAGING_DIR := $(realpath .)/$(STAGING_DIRNAME)
STAGING_USER_DIRNAME := rack-user-dir
STAGING_USER_DIR := $(STAGING_DIR)/$(STAGING_USER_DIRNAME)
STAGING_PLUGIN_DIR := $(STAGING_USER_DIR)/plugins
STAGING_PLUGIN_ZIP := $(STAGING_PLUGIN_DIR)/$(PLUGIN_ZIP_NAME)
STAGING_PLUGIN_MANIFEST = $(STAGING_PLUGIN_DIR)/$(SLUG)/plugin.json
RACK_EXECUTABLE_PATH = $(RACK_APP)/Contents/MacOS/Rack
$(STAGING_DIR) $(STAGING_PLUGIN_DIR):
mkdir -p $@
stage: dist $(STAGING_PLUGIN_DIR)
cp $(DIST_PLUGIN_ZIP) $(STAGING_PLUGIN_DIR)
clean-stage:
rm -rf $(STAGING_DIRNAME)
run: stage
$(RACK_EXECUTABLE_PATH) -u $(STAGING_USER_DIR)
run-unhidden: stage-unhidden
$(RACK_EXECUTABLE_PATH) -u $(STAGING_USER_DIR)
stage-unhidden: stage
cd $(STAGING_PLUGIN_DIR) && tar xf $(PLUGIN_ZIP_NAME)
rm $(STAGING_PLUGIN_ZIP)
jq '.modules[].hidden=false' plugin.json > $(STAGING_PLUGIN_MANIFEST)
clean: clean-stage
.PHONY: run clean-stage
########################################################################
#
# Analyze and format the code
#
########################################################################
HEADERS = $(shell find src test -name "*.h")
.PHONY: format
format:
clang-format -i -style=file $(HEADERS) $(SOURCES) $(TEST_SOURCES)
COMPILATION_DB_PLUGIN_ENTRIES := $(patsubst %, build/%.json, $(SOURCES))
COMPILATION_DB_TEST_ENTRIES := $(patsubst %, build/%.json, $(TEST_SOURCES))
$(COMPILATION_DB_TEST_ENTRIES): CXXFLAGS := $(TEST_CXXFLAGS)
COMPILATION_DB_ENTRIES := $(COMPILATION_DB_PLUGIN_ENTRIES) $(COMPILATION_DB_TEST_ENTRIES)
COMPILATION_DB = compile_commands.json
$(COMPILATION_DB): $(COMPILATION_DB_ENTRIES)
sed -e '1s/^/[/' -e '$$s/,$$/]/' $^ | json_pp > $@
setup: $(COMPILATION_DB)
.PHONY: cleansetup
cleansetup:
rm -rf $(COMPILATION_DB) $(COMPILATION_DB_ENTRIES)
clean: cleansetup
build/%.json: %
@mkdir -p $(@D)
$(CXX) $(CXXFLAGS) -MJ $@ -c -o build/$^.o $^
.PHONY: tidy
tidy: $(COMPILATION_DB)
clang-tidy -p=build $(SOURCES) $(TEST_SOURCES)