forked from tangrams/tangram-es
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
314 lines (256 loc) · 7.37 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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
all: android osx ios
.PHONY: clean
.PHONY: clean-android
.PHONY: clean-osx
.PHONY: clean-xcode
.PHONY: clean-ios
.PHONY: clean-rpi
.PHONY: clean-linux
.PHONY: clean-benchmark
.PHONY: android
.PHONY: osx
.PHONY: xcode
.PHONY: ios
.PHONY: ios-sim
.PHONY: rpi
.PHONY: linux
.PHONY: benchmark
.PHONY: check-ndk
.PHONY: cmake-osx
.PHONY: cmake-xcode
.PHONY: cmake-android
.PHONY: cmake-ios
.PHONY: cmake-ios-sim
.PHONY: cmake-rpi
.PHONY: cmake-linux
.PHONY: install-android
ANDROID_BUILD_DIR = build/android
OSX_BUILD_DIR = build/osx
OSX_XCODE_BUILD_DIR = build/xcode
IOS_BUILD_DIR = build/ios
IOS_SIM_BUILD_DIR = build/ios-sim
RPI_BUILD_DIR = build/rpi
LINUX_BUILD_DIR = build/linux
TESTS_BUILD_DIR = build/tests
BENCH_BUILD_DIR = build/bench
TOOLCHAIN_DIR = toolchains
OSX_TARGET = tangram
IOS_TARGET = tangram
OSX_XCODE_PROJ = tangram.xcodeproj
IOS_XCODE_PROJ = tangram.xcodeproj
ifdef DEBUG
BUILD_TYPE = -DCMAKE_BUILD_TYPE=Debug
endif
ifdef RELEASE
BUILD_TYPE = -DCMAKE_BUILD_TYPE=Release
endif
ifdef ANDROID_ARCH
ANDROID_BUILD_DIR = build/android-${ANDROID_ARCH}
ifeq ($(ANDROID_ARCH), x86)
ANDROID_TOOLCHAIN = x86-clang3.6
endif
ifeq ($(ANDROID_ARCH), x86_64)
ANDROID_TOOLCHAIN = x86_64-clang3.6
ANDROID_API_LEVEL = android-21
endif
ifeq ($(ANDROID_ARCH), armeabi)
ANDROID_TOOLCHAIN = arm-linux-androideabi-clang3.6
endif
ifeq ($(ANDROID_ARCH), armeabi-v7a)
ANDROID_TOOLCHAIN = arm-linux-androideabi-clang3.6
endif
ifeq ($(ANDROID_ARCH), arm64-v8a)
ANDROID_TOOLCHAIN = aarch64-linux-android-clang3.6
ANDROID_API_LEVEL = android-21
endif
ifeq ($(ANDROID_ARCH), mips)
ANDROID_TOOLCHAIN = mipsel-linux-android-clang3.6
endif
ifeq ($(ANDROID_ARCH), mips64)
ANDROID_TOOLCHAIN = mips64el-linux-android-clang3.6
ANDROID_API_LEVEL = android-21
endif
else
ANDROID_ARCH = armeabi-v7a
ANDROID_TOOLCHAIN = arm-linux-androideabi-clang3.6
endif
#$(info ANDROID_ARCH is ${ANDROID_ARCH})
#$(info ANDROID_TOOLCHAIN is ${ANDROID_TOOLCHAIN})
#$(info ANDROID_BUILD_DIR is ${ANDROID_BUILD_DIR})
ifndef ANDROID_API_LEVEL
ANDROID_API_LEVEL = android-15
endif
ifndef TANGRAM_CMAKE_OPTIONS
TANGRAM_CMAKE_OPTIONS = \
-DBENCHMARK=0 \
-DUNIT_TESTS=0
endif
BENCH_CMAKE_PARAMS = \
-DBENCHMARK=1 \
-DAPPLICATION=0 \
-DCMAKE_BUILD_TYPE=Release
UNIT_TESTS_CMAKE_PARAMS = \
-DUNIT_TESTS=1 \
-DAPPLICATION=0 \
-DCMAKE_BUILD_TYPE=Debug
ANDROID_CMAKE_PARAMS = \
${BUILD_TYPE} \
${CMAKE_OPTIONS} \
-DPLATFORM_TARGET=android \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_DIR}/android.toolchain.cmake \
-DMAKE_BUILD_TOOL=$$ANDROID_NDK/prebuilt/darwin-x86_64/bin/make \
-DANDROID_ABI=${ANDROID_ARCH} \
-DANDROID_STL=c++_shared \
-DANDROID_TOOLCHAIN_NAME=${ANDROID_TOOLCHAIN} \
-DANDROID_NATIVE_API_LEVEL=${ANDROID_API_LEVEL} \
-DLIBRARY_OUTPUT_PATH_ROOT=../../android/tangram \
-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE
IOS_CMAKE_PARAMS = \
${BUILD_TYPE} \
${CMAKE_OPTIONS} \
-DPLATFORM_TARGET=ios \
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_DIR}/iOS.toolchain.cmake \
-G Xcode
DARWIN_XCODE_CMAKE_PARAMS = \
${BUILD_TYPE} \
${CMAKE_OPTIONS} \
-DPLATFORM_TARGET=darwin \
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="10.9" \
-G Xcode
DARWIN_CMAKE_PARAMS = \
${BUILD_TYPE} \
${CMAKE_OPTIONS} \
-DPLATFORM_TARGET=darwin \
-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE
RPI_CMAKE_PARAMS = \
${BUILD_TYPE} \
${CMAKE_OPTIONS} \
-DPLATFORM_TARGET=raspberrypi \
-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE
LINUX_CMAKE_PARAMS = \
${BUILD_TYPE} \
${CMAKE_OPTIONS} \
-DPLATFORM_TARGET=linux \
-DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE
clean: clean-android clean-osx clean-ios clean-rpi clean-tests clean-xcode clean-linux
clean-android:
@cd android/ && \
./gradlew clean
rm -rf ${ANDROID_BUILD_DIR}
rm -rf android/tangram/libs
clean-osx:
rm -rf ${OSX_BUILD_DIR}
clean-ios:
rm -rf ${IOS_BUILD_DIR}
clean-rpi:
rm -rf ${RPI_BUILD_DIR}
clean-linux:
rm -rf ${LINUX_BUILD_DIR}
clean-xcode:
rm -rf ${OSX_XCODE_BUILD_DIR}
clean-tests:
rm -rf ${TESTS_BUILD_DIR}
clean-benchmark:
rm -rf ${BENCH_BUILD_DIR}
android: android-demo-apk
@echo "run: 'adb install -r android/demo/build/outputs/apk/demo-debug.apk'"
android-tangram-apk:
@cd android/ && \
./gradlew tangram:assembleDebug
android-demo-apk: android-native-lib
@cd android/ && \
./gradlew demo:assembleDebug
android-native-lib: android/tangram/libs/${ANDROID_ARCH}/libtangram.so
android/tangram/libs/${ANDROID_ARCH}/libtangram.so: install-android
install-android: ${ANDROID_BUILD_DIR}/Makefile
@cd ${ANDROID_BUILD_DIR} && \
${MAKE} && \
${MAKE} install
${ANDROID_BUILD_DIR}/Makefile: check-ndk cmake-android
cmake-android:
@mkdir -p ${ANDROID_BUILD_DIR}
@cd ${ANDROID_BUILD_DIR} && \
cmake ../.. ${ANDROID_CMAKE_PARAMS}
osx: ${OSX_BUILD_DIR}/Makefile
@cd ${OSX_BUILD_DIR} && \
${MAKE}
${OSX_BUILD_DIR}/Makefile: cmake-osx
xcode: ${OSX_XCODE_BUILD_DIR}/${OSX_XCODE_PROJ}
xcodebuild -target ${OSX_TARGET} -project ${OSX_XCODE_BUILD_DIR}/${OSX_XCODE_PROJ}
${OSX_XCODE_BUILD_DIR}/${OSX_XCODE_PROJ}: cmake-xcode
cmake-xcode:
@mkdir -p ${OSX_XCODE_BUILD_DIR}
@cd ${OSX_XCODE_BUILD_DIR} && \
cmake ../.. ${DARWIN_XCODE_CMAKE_PARAMS}
cmake-osx:
@mkdir -p ${OSX_BUILD_DIR}
@cd ${OSX_BUILD_DIR} && \
cmake ../.. ${DARWIN_CMAKE_PARAMS}
ios: ${IOS_BUILD_DIR}/${IOS_XCODE_PROJ}
xcodebuild -target ${IOS_TARGET} -project ${IOS_BUILD_DIR}/${IOS_XCODE_PROJ}
${IOS_BUILD_DIR}/${IOS_XCODE_PROJ}: cmake-ios
cmake-ios:
@mkdir -p ${IOS_BUILD_DIR}
@cd ${IOS_BUILD_DIR} && \
cmake ../.. ${IOS_CMAKE_PARAMS}
ios-sim: ${IOS_SIM_BUILD_DIR}/${IOS_XCODE_PROJ}
xcodebuild -target ${IOS_TARGET} -project ${IOS_SIM_BUILD_DIR}/${IOS_XCODE_PROJ}
${IOS_SIM_BUILD_DIR}/${IOS_XCODE_PROJ}: cmake-ios-sim
cmake-ios-sim:
@mkdir -p ${IOS_SIM_BUILD_DIR}
@cd ${IOS_SIM_BUILD_DIR} && \
cmake ../.. ${IOS_CMAKE_PARAMS} -DIOS_PLATFORM=SIMULATOR
rpi: cmake-rpi
@cd ${RPI_BUILD_DIR} && \
${MAKE}
cmake-rpi:
@mkdir -p ${RPI_BUILD_DIR}
@cd ${RPI_BUILD_DIR} && \
cmake ../.. ${RPI_CMAKE_PARAMS}
linux: cmake-linux
cd ${LINUX_BUILD_DIR} && \
${MAKE}
cmake-linux:
mkdir -p ${LINUX_BUILD_DIR}
cd ${LINUX_BUILD_DIR} &&\
cmake ../.. ${LINUX_CMAKE_PARAMS}
tests: unit-tests
unit-tests:
@mkdir -p ${TESTS_BUILD_DIR}
@cd ${TESTS_BUILD_DIR} && \
cmake ../.. ${UNIT_TESTS_CMAKE_PARAMS} && \
${MAKE}
benchmark:
@mkdir -p ${BENCH_BUILD_DIR}
@cd ${BENCH_BUILD_DIR} && \
cmake ../../ ${BENCH_CMAKE_PARAMS} && \
${MAKE}
check-ndk:
ifndef ANDROID_NDK
$(error ANDROID_NDK is undefined)
endif
format:
@for file in `git diff --diff-filter=ACMRTUXB --name-only -- '*.cpp' '*.h'`; do \
if [[ -e $$file ]]; then clang-format -i $$file; fi \
done
@echo "format done on `git diff --diff-filter=ACMRTUXB --name-only -- '*.cpp' '*.h'`"
swig-bindings:
@mkdir -p generated
@swig -v -c++ -Icore/src -o android/tangram/jni/jniGenerated.cpp \
-outdir generated \
-package com.mapzen.tangram -java swig/tangram.i
@astyle --style=attach --indent=spaces=2 android/tangram/jni/jniGenerated.cpp
@astyle --style=java generated/*.java
@mv generated/*.java android/tangram/src/com/mapzen/tangram
### Android Helpers
android-install:
@adb install -r android/demo/build/outputs/apk/demo-debug.apk
android-debug:
@cd android/demo && \
cp -a ../tangram/libs . && \
mkdir -p jni && \
cp ../tangram/jni/*.mk jni && \
python2 $$ANDROID_NDK/ndk-gdb.py --verbose --start
android-debug-attach:
@cd android/demo && \
python2 $$ANDROID_NDK/ndk-gdb.py --verbose