-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.common
180 lines (142 loc) · 5.46 KB
/
Makefile.common
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# ------------------------------------------------------------------------
# This file is supposed to be included from the main project Makefile.
# ------------------------------------------------------------------------
# Beginning of user configuration -------------------------------
# General build configuration -----------------------------------
## Specify path to overriden jucer file.
ifeq ('$(APP_CUSTOM_JUCER)', '')
APP_CUSTOM_JUCER=$(shell pwd)/apps/override.$(APP_NAME).jucer
endif
ifeq ('$(APP_DST_JUCER)', '')
APP_DST_JUCER=$(APP_NAME).jucer
endif
# Specify path to copy destination, if different from APP_BUILD_DIR. e.g. apps/vital/standalone
ifeq ('$(APP_COPY_DIR)', '')
APP_COPY_DIR=$(APP_BUILD_DIR)
endif
## Specify path to aap-juce. The default is the submodule path.
ifeq ('$(AAP_JUCE_DIR)', '')
AAP_JUCE_DIR=$(shell pwd)/aap-juce
endif
## Specify path to juce. The default is the submodule path.
ifeq ('$(JUCE_DIR)', '')
JUCE_DIR=$(shell pwd)/external/JUCE
endif
## Specify path to aap core. The default is the submodule path.
AAP_DIR=$(shell pwd)/external/aap-core
## If the build output is going to be too huge to keep, use this flag to delete.
MINIMIZE_INTERMEDIATES=0
## Specify arbitrary NDK version. No guarantee on that your version works.
NDK_VERSION=21.4.7075529
## Specify whatever gradle task you want to run.
GRADLE_TASK=$(shell printf '%b' "build bundle")
## dist directory to collect build artifacts
DIST_DIR=$(shell pwd)/dist
# End of user configuration. ------------------------------------
THISFILE=$(abspath $(lastword $(MAKEFILE_LIST)))
THISDIR=$(dir $(THISFILE))
ifeq ('$(ANDROID_SDK_ROOT)', '')
ANDROID_SDK_ROOT=~/Android/Sdk
endif
PROJUCER_BIN_LINUX=$(JUCE_DIR)/extras/Projucer/Builds/LinuxMakefile/build/Projucer
PROJUCER_BIN_DARWIN=$(JUCE_DIR)/extras/Projucer/Builds/MacOSX/build/Debug/Projucer.app/Contents/MacOS/Projucer
ANDROID_DIR=$(APP_BUILD_DIR)/Builds/Android
ifeq ($(shell uname), Linux)
PROJUCER_BIN=$(PROJUCER_BIN_LINUX)
else
ifeq ($(shell uname), Darwin)
PROJUCER_BIN=$(PROJUCER_BIN_DARWIN)
else
PROJUCER_BIN=___error___
endif
endif
.PHONY:
all: build
.PHONY:
build: prepare build-aap build-target-app
.PHONY:
prepare: $(PRE_BUILD_TASKS) build-projucer
.PHONY:
build-projucer: $(PROJUCER_BIN)
@echo "Projucer target: $(PROJUCER_BIN)"
$(PROJUCER_BIN_LINUX):
make -C $(JUCE_DIR)/extras/Projucer/Builds/LinuxMakefile
if [ $(MINIMIZE_INTERMEDIATES) ] ; then \
rm -rf $(JUCE_DIR)/extras/Projucer/Builds/LinuxMakefile/build/intermediate/ ; \
fi
$(PROJUCER_BIN_DARWIN):
xcodebuild -project $(JUCE_DIR)/extras/Projucer/Builds/MacOSX/Projucer.xcodeproj
if [ $(MINIMIZE_INTERMEDIATES) ] ; then \
rm -rf $(JUCE_DIR)/extras/Projucer/Builds/MacOSX/build/intermediate/ ; \
fi
.PHONY:
build-aap:
if [ ! -f $(AAP_DIR)/local.properties ] ; then \
if [ "`uname`" == "Darwin" ] ; then \
echo "sdk.dir=$(HOME)/Library/Android/sdk" > $(AAP_DIR)/local.properties ; \
else \
echo "sdk.dir=$(HOME)/Android/Sdk" > $(AAP_DIR)/local.properties ; \
fi ; \
fi
cd $(AAP_DIR) && ./gradlew publishToMavenLocal
.PHONY:
dist:
mkdir -p $(DIST_DIR)
cp $(APP_BUILD_DIR)/Builds/Android/app/build/outputs/apk/debug_/debug/*.apk $(DIST_DIR)/$(APP_NAME)-debug.apk
cp $(APP_BUILD_DIR)/Builds/Android/app/build/outputs/bundle/release_Release/app-release_-release.aab $(DIST_DIR)/$(APP_NAME)-release.aab
.PHONY:
build-target-app: patch-juce-sources copy-and-patch-app-sources projuce-app do-build-target-android
.PHONY:
patch-juce-sources: $(JUCE_DIR)/.stamp-juce
$(JUCE_DIR)/.stamp-juce:
echo "JUCE patches: $(JUCE_PATCHES)"
for patch in $(JUCE_PATCHES) ; do \
echo "JUCE patch: $${patch}" ; \
if [ '$${patch}' != '' ] ; then \
cd $(JUCE_DIR) && patch -i $${patch} -p $(JUCE_PATCH_DEPTH) -l ; \
fi ; \
done
touch $(JUCE_DIR)/.stamp-juce
.PHONY:
copy-and-patch-app-sources: $(APP_COPY_DIR)/.stamp
$(APP_COPY_DIR)/.stamp: \
$(APP_SRC_DIR)/** \
$(APP_CUSTOM_JUCER) \
$(AAP_JUCE_DIR)/projuce-app-template/*
$(AAP_JUCE_DIR)/copy-and-patch-app-sources.sh $(APP_NAME) $(APP_SRC_DIR) \
$(APP_COPY_DIR) $(PATCH_FILE) $(PATCH_DEPTH) $(APP_CUSTOM_JUCER) $(APP_BUILD_DIR)
if [ ! -e $(APP_COPY_DIR)/aap-modules ] ; then \
ln -s $(AAP_JUCE_DIR)/aap-modules $(APP_COPY_DIR)/aap-modules ; \
fi
if [ ! -e $(APP_COPY_DIR)/juce-modules ] ; then \
ln -s $(JUCE_DIR)/modules $(APP_COPY_DIR)/juce-modules ; \
fi
if [ ! -e $(APP_COPY_DIR)/aap-core ] ; then \
ln -s $(AAP_DIR) $(APP_COPY_DIR)/aap-core ; \
fi
.PHONY:
projuce-app: $(EXTERNAL_PRE_PROJUCE_TASKS) do-projuce-app $(EXTERNAL_POST_PROJUCE_TASKS)
.PHONY:
do-projuce-app:
echo "PROJUCER is at $(PROJUCER_BIN)"
cd $(APP_BUILD_DIR) && \
NDK_VERSION=$(NDK_VERSION) \
APPNAME=$(APP_NAME) \
PROJUCER=$(PROJUCER_BIN) \
AAP_METADATA_XML_SOURCE=$(AAP_METADATA_XML_SOURCE) \
ENABLE_MIDI_DEVICE_SERVICE=$(ENABLE_MIDI_DEVICE_SERVICE) \
$(AAP_JUCE_DIR)/projuce-app.sh $(APP_DST_JUCER)
.PHONY:
do-build-target-android:
# generate a debug key if it does not exist.
if [ ! -d $(HOME)/.android ] ; then \
mkdir -p $(HOME)/.android ; \
fi
if [ ! -f $(HOME)/.android/debug.keystore ] ; then \
keytool -genkey -v -keystore $(HOME)/.android/debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 37564 -noprompt -dname "CN=Android Debug,O=Android,C=US" ; \
fi
cd $(ANDROID_DIR) && ./gradlew $(GRADLE_TASK) && cd ../.. || exit 1
if [ $(MINIMIZE_INTERMEDIATES) ] ; then \
rm -rf $(ANDROID_DIR)/app/build/intermediates/ ; \
rm -rf $(ANDROID_DIR)/app/.cxx ; \
fi