-
Notifications
You must be signed in to change notification settings - Fork 63
/
Makefile
417 lines (359 loc) · 17.2 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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
MAKEFILE_DIR = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
MANIFEST_FILE = $(MAKEFILE_DIR)/Manifest.yml
UTILS_DIR = $(MAKEFILE_DIR)/utils
UTIL_MANIFEST_GET_BIN = $(UTILS_DIR)/manifest_get/manifest_get.sh
UTIL_MANIFEST_GET = $(UTILS_DIR)/manifest_get
UTIL_MAVEN_FORMAT = $(UTILS_DIR)/maven_format
UTIL_MAVEN_FORMAT_REQ = $(UTIL_MAVEN_FORMAT)/requirements.txt
UTIL_MAVEN_FORMAT_CORE_BIN = $(UTIL_MAVEN_FORMAT)/maven_format_core.py
UTIL_MAVEN_PUBLISH = $(UTILS_DIR)/maven_publish
UTIL_MAVEN_PUBLISH_REQ = $(UTIL_MAVEN_PUBLISH)/requirements.txt
UTIL_MAVEN_PUBLISH_CORE_BIN = $(UTIL_MAVEN_PUBLISH)/maven_publish_core.py
UTIL_COCOAPOD_FORMAT = $(UTILS_DIR)/cocoapod_format
UTIL_COCOAPOD_FORMAT_REQ = $(UTIL_COCOAPOD_FORMAT)/requirements.txt
UTIL_COCOAPOD_FORMAT_BRIDGE_BIN = $(UTIL_COCOAPOD_FORMAT)/cocoapod_format_bridge.py
UTIL_COCOAPOD_FORMAT_CORE_BIN = $(UTIL_COCOAPOD_FORMAT)/cocoapod_format_core.py
UTIL_COCOAPOD_PUBLISH = $(UTILS_DIR)/cocoapod_publish
UTIL_COCOAPOD_PUBLISH_REQ = $(UTIL_COCOAPOD_PUBLISH)/requirements.txt
UTIL_COCOAPOD_PUBLISH_BRIDGE_BIN = $(UTIL_COCOAPOD_PUBLISH)/cocoapod_publish_bridge.py
UTIL_COCOAPOD_PUBLISH_CORE_BIN = $(UTIL_COCOAPOD_PUBLISH)/cocoapod_publish_core.py
UTIL_BINTRAY_FORMAT = $(UTILS_DIR)/bintray_format
UTIL_BINTRAY_FORMAT_REQ = $(UTIL_BINTRAY_FORMAT)/requirements.txt
UTIL_BINTRAY_PUBLISH = $(UTILS_DIR)/bintray_publish
UTIL_BINTRAY_PUBLISH_REQ = $(UTIL_BINTRAY_PUBLISH)/requirements.txt
UTIL_BINTRAY_PUBLISH_ANDROID_BIN = $(UTIL_BINTRAY_PUBLISH)/bintray_publish_android.py
BUILD_DIR = $(MAKEFILE_DIR)/build
PIP ?= pip3
MANIFEST_GET_FUNC=$(or $(shell $(UTIL_MANIFEST_GET_BIN) $(1)),$(error "Can't get <$(1)> from Manifest.yml"))
DEV_VERSION := 0.0.42-dev
VERSION := $(or $(GOMOBILE_IPFS_VERSION),$(DEV_VERSION))
ANDROID_GROUP_ID := $(shell echo $(call MANIFEST_GET_FUNC,global.group_id) | tr . /)
ANDROID_CORE_ARTIFACT_ID := $(call MANIFEST_GET_FUNC,go_core.android.artifact_id)
ANDROID_APP_FILENAME := $(call MANIFEST_GET_FUNC,android_demo_app.filename)
ANDROID_MINIMUM_VERSION := $(call MANIFEST_GET_FUNC,android.min_sdk_version)
IOS_CORE_PACKAGE := $(call MANIFEST_GET_FUNC,go_core.ios.package)
IOS_APP_FILENAME := $(call MANIFEST_GET_FUNC,ios_demo_app.filename)
GO_DIR = $(MAKEFILE_DIR)/go
GO_SRC = $(shell find $(GO_DIR) -name \*.go)
GO_MOD_FILES = $(GO_DIR)/go.mod $(GO_DIR)/go.sum
CORE_PACKAGE = github.com/ipfs-shipyard/gomobile-ipfs/go/bind/core
EXT_PACKAGE ?=
GOMOBILE_OPT ?=
GOMOBILE_TARGET ?=
GOMOBILE_ANDROID_TARGET ?= android
GOMOBILE_IOS_TARGET ?= ios
ANDROID_DIR = $(MAKEFILE_DIR)/android
ANDROID_SRC = $(shell git ls-files $(ANDROID_DIR) | grep -v '.gitignore')
ANDROID_BUILD_DIR = $(BUILD_DIR)/android
ANDROID_BUILD_DIR_INT = $(ANDROID_BUILD_DIR)/intermediates
ANDROID_BUILD_DIR_INT_CORE = $(ANDROID_BUILD_DIR_INT)/core
ANDROID_GOMOBILE_CACHE="$(ANDROID_BUILD_DIR_INT_CORE)/.gomobile-cache"
ANDROID_CORE = $(ANDROID_BUILD_DIR_INT_CORE)/core.aar
ANDROID_BUILD_DIR_MAV = $(ANDROID_BUILD_DIR)/maven
ANDROID_BUILD_DIR_MAV_CORE = $(ANDROID_BUILD_DIR_MAV)/$(ANDROID_GROUP_ID)/$(ANDROID_CORE_ARTIFACT_ID)/$(VERSION)
ANDROID_OUTPUT_APK = $(ANDROID_DIR)/app/build/outputs/apk/release/app-release.apk
ANDROID_BUILD_DIR_APP = $(ANDROID_BUILD_DIR)/app/$(VERSION)
ANDROID_BUILD_DIR_APP_APK = $(ANDROID_BUILD_DIR_APP)/$(ANDROID_APP_FILENAME)-$(VERSION).apk
IOS_DIR = $(MAKEFILE_DIR)/ios
IOS_SRC = $(shell git ls-files $(IOS_DIR) | grep -v '.gitignore')
IOS_BUILD_DIR = $(BUILD_DIR)/ios
IOS_BUILD_DIR_INT = $(IOS_BUILD_DIR)/intermediates
IOS_BUILD_DIR_INT_CORE = $(IOS_BUILD_DIR_INT)/core
IOS_GOMOBILE_CACHE="$(IOS_BUILD_DIR_INT_CORE)/.gomobile-cache"
IOS_CORE = $(IOS_BUILD_DIR_INT_CORE)/Core.xcframework
IOS_BUILD_DIR_CCP = $(IOS_BUILD_DIR)/cocoapods
IOS_BUILD_DIR_CCP_CORE = $(IOS_BUILD_DIR_CCP)/$(IOS_CORE_PACKAGE)/$(VERSION)
IOS_WORKSPACE = $(IOS_DIR)/Example.xcworkspace
IOS_APP_PLIST = $(IOS_WORKSPACE)/release_export.plist
IOS_BUILD_DIR_APP = $(IOS_BUILD_DIR)/app/$(VERSION)
IOS_BUILD_DIR_APP_IPA = $(IOS_BUILD_DIR_APP)/$(IOS_APP_FILENAME)-$(VERSION).ipa
IOS_BUILD_DIR_INT_APP = $(IOS_BUILD_DIR_INT)/app
IOS_BUILD_DIR_INT_APP_IPA = $(IOS_BUILD_DIR_INT_APP)/ipa
IOS_BUILD_DIR_INT_APP_IPA_OUTPUT = $(IOS_BUILD_DIR_INT_APP_IPA)/Example.ipa
IOS_BUILD_DIR_INT_APP_ARCHIVE = $(IOS_BUILD_DIR_INT_APP)/archive
IOS_BUILD_DIR_INT_APP_ARCHIVE_OUTPUT = $(IOS_BUILD_DIR_INT_APP_ARCHIVE)/app-release.xcarchive
DOC_DIR = $(MAKEFILE_DIR)/docs
ANDROID_DOC_DIR = $(DOC_DIR)/android
IOS_DOC_DIR = $(DOC_DIR)/ios
.PHONY: help build_core build_core.android build_core.ios build_demo build_demo.android build_demo.ios clean clean.android clean.ios docgen docgen.android docgen.ios fail_on_dev publish publish_bridge publish_bridge.android publish_bridge.ios publish_core publish_core.android publish_core.ios publish_demo publish_demo.android publish_demo.ios re re.android re.ios test test_bridge test_bridge.android test_bridge.ios test_core
help:
@echo 'Commands:'
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null \
| awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' \
| sort \
| egrep -v -e '^[^[:alnum:]]' -e '^$@$$' \
| grep -v / \
| sed 's/^/ $(HELP_MSG_PREFIX)make /'
# Build rules
build_core: build_core.android build_core.ios
build_core.android: $(ANDROID_BUILD_DIR_MAV_CORE)
$(ANDROID_BUILD_DIR_MAV_CORE): $(ANDROID_CORE) $(MANIFEST_FILE)
@echo '------------------------------------'
@echo ' Android Core: Maven formatting '
@echo '------------------------------------'
if [ "$$($(PIP) freeze | grep -f $(UTIL_MAVEN_FORMAT_REQ) | wc -l)" != "$$(wc -l < $(UTIL_MAVEN_FORMAT_REQ))" ]; then \
$(PIP) install -r $(UTIL_MAVEN_FORMAT_REQ); echo; \
fi
$(UTIL_MAVEN_FORMAT_CORE_BIN) && touch $(ANDROID_BUILD_DIR_MAV_CORE)
@echo 'Done!'
$(ANDROID_CORE): $(ANDROID_BUILD_DIR_INT_CORE) $(GO_SRC) $(GO_MOD_FILES)
@echo '------------------------------------'
@echo ' Android Core: Gomobile binding '
@echo '------------------------------------'
cd $(GO_DIR) && go mod download
cd $(GO_DIR) && go run golang.org/x/mobile/cmd/gomobile init
mkdir -p $(ANDROID_GOMOBILE_CACHE) android/libs
GO111MODULE=on cd $(GO_DIR) && go run golang.org/x/mobile/cmd/gomobile bind \
-o $(ANDROID_CORE) \
-v $(GOMOBILE_OPT) \
-cache $(ANDROID_GOMOBILE_CACHE) \
-target=$(GOMOBILE_ANDROID_TARGET)$(GOMOBILE_TARGET) \
-androidapi $(ANDROID_MINIMUM_VERSION) \
$(CORE_PACKAGE) $(EXT_PACKAGE)
touch $@
cd $(GO_DIR) && go mod tidy
@echo 'Done!'
$(ANDROID_BUILD_DIR_INT_CORE):
mkdir -p $(ANDROID_BUILD_DIR_INT_CORE)
build_core.ios: $(IOS_BUILD_DIR_CCP_CORE)
$(IOS_BUILD_DIR_CCP_CORE): $(IOS_CORE) $(MANIFEST_FILE)
@echo '------------------------------------'
@echo ' iOS Core: CocoaPod formatting '
@echo '------------------------------------'
if [ "$$($(PIP) freeze | grep -f $(UTIL_COCOAPOD_FORMAT_REQ) | wc -l)" != "$$(wc -l < $(UTIL_COCOAPOD_FORMAT_REQ))" ]; then \
$(PIP) install -r $(UTIL_COCOAPOD_FORMAT_REQ); echo; \
fi
$(UTIL_COCOAPOD_FORMAT_CORE_BIN) && touch $(IOS_BUILD_DIR_CCP_CORE)
@echo 'Done!'
# From https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile#hdr-Build_a_library_for_Android_and_iOS
# To generate a fat XCFramework that supports iOS, macOS, and macCatalyst for all supportec architectures (amd64 and arm64),
# specify -target ios,macos,maccatalyst
# we need to use `nowatchdog` tags, see https://github.com/libp2p/go-libp2p-connmgr/issues/98
$(IOS_CORE): $(IOS_BUILD_DIR_INT_CORE) $(GO_SRC) $(GO_MOD_FILES)
@echo '------------------------------------'
@echo ' iOS Core: Gomobile binding '
@echo '------------------------------------'
cd $(GO_DIR) && go mod download
cd $(GO_DIR) && go install golang.org/x/mobile/cmd/gobind
cd $(GO_DIR) && go run golang.org/x/mobile/cmd/gomobile init
mkdir -p $(IOS_GOMOBILE_CACHE) ios/Frameworks
cd $(GO_DIR) && go run golang.org/x/mobile/cmd/gomobile bind \
-o $(IOS_CORE) \
-tags 'nowatchdog' \
$(GOMOBILE_OPT) \
-cache $(IOS_GOMOBILE_CACHE) \
-target=$(GOMOBILE_IOS_TARGET)$(GOMOBILE_TARGET) \
$(CORE_PACKAGE) $(EXT_PACKAGE)
touch $@
cd $(GO_DIR) && go mod tidy
@echo 'Done!'
$(IOS_BUILD_DIR_INT_CORE):
@mkdir -p $(IOS_BUILD_DIR_INT_CORE)
build_demo: build_demo.android build_demo.ios
build_demo.android: $(ANDROID_BUILD_DIR_APP_APK)
$(ANDROID_BUILD_DIR_APP_APK): $(ANDROID_BUILD_DIR_APP) $(ANDROID_OUTPUT_APK) $(MANIFEST)
@echo '------------------------------------'
@echo ' Android Demo: apk path creation '
@echo '------------------------------------'
cp $(ANDROID_OUTPUT_APK) $(ANDROID_BUILD_DIR_APP_APK)
@echo 'Built .apk available in: $(ANDROID_BUILD_DIR_APP)'
@echo 'Done!'
$(ANDROID_OUTPUT_APK): $(ANDROID_SRC) $(MANIFEST) $(ANDROID_BUILD_DIR_MAV_CORE)
@echo '------------------------------------'
@echo ' Android Demo: Gradle building '
@echo '------------------------------------'
cd $(ANDROID_DIR) && ./gradlew app:build
touch $(ANDROID_OUTPUT_APK)
@echo 'Done!'
$(ANDROID_BUILD_DIR_APP):
@mkdir -p $(ANDROID_BUILD_DIR_APP)
build_demo.ios: $(IOS_BUILD_DIR_APP_IPA)
$(IOS_BUILD_DIR_APP_IPA): $(IOS_BUILD_DIR_INT_APP_IPA_OUTPUT) $(MANIFEST)
@echo '------------------------------------'
@echo ' iOS Demo: Bintray formatting '
@echo '------------------------------------'
if [ "$$($(PIP) freeze | grep -f $(UTIL_BINTRAY_FORMAT_REQ) | wc -l)" != "$$(wc -l < $(UTIL_BINTRAY_FORMAT_REQ))" ]; then \
$(PIP) install -r $(UTIL_BINTRAY_FORMAT_REQ); echo; \
fi
#TODO
@echo 'Done!'
$(IOS_BUILD_DIR_INT_APP_IPA_OUTPUT): $(IOS_BUILD_DIR_INT_APP_IPA) $(IOS_BUILD_DIR_INT_APP_ARCHIVE_OUTPUT)
@echo '------------------------------------'
@echo ' iOS Demo: XCode building ipa '
@echo '------------------------------------'
xcodebuild -exportArchive \
-archivePath $(IOS_BUILD_DIR_INT_APP_ARCHIVE_OUTPUT) \
-exportOptionsPlist $(IOS_APP_PLIST) \
-exportPath $(IOS_BUILD_DIR_INT_APP_IPA)
touch $(IOS_BUILD_DIR_INT_APP_IPA_OUTPUT)
@echo 'Done!'
$(IOS_BUILD_DIR_INT_APP_IPA):
mkdir -p $(IOS_BUILD_DIR_INT_APP_IPA)
$(IOS_BUILD_DIR_INT_APP_ARCHIVE_OUTPUT): $(IOS_BUILD_DIR_INT_APP_ARCHIVE) $(IOS_CORE) $(IOS_SRC)
@echo '------------------------------------'
@echo ' iOS Demo: XCode building archive '
@echo '------------------------------------'
xcodebuild archive \
-workspace $(IOS_WORKSPACE) \
-scheme Example \
-configuration Release \
-sdk iphoneos \
-archivePath $(IOS_BUILD_DIR_INT_APP_ARCHIVE_OUTPUT)
touch $(IOS_BUILD_DIR_INT_APP_ARCHIVE_OUTPUT)
@echo 'Done!'
$(IOS_BUILD_DIR_INT_APP_ARCHIVE):
@mkdir -p $(IOS_BUILD_DIR_INT_APP_ARCHIVE)
# Publish rules
publish: publish_core publish_bridge publish_demo
publish.ios: publish_core.ios publish_bridge.ios
publish_core: publish_core.android publish_core.ios
publish_core.android: fail_on_dev build_core.android
@echo '------------------------------------'
@echo ' Android Core: Maven publishing '
@echo '------------------------------------'
if [ "$$($(PIP) freeze | grep -f $(UTIL_MAVEN_PUBLISH_REQ) | wc -l)" != "$$(wc -l < $(UTIL_MAVEN_PUBLISH_REQ))" ]; then \
$(PIP) install -r $(UTIL_MAVEN_PUBLISH_REQ); echo; \
fi
$(UTIL_MAVEN_PUBLISH_CORE_BIN)
@echo 'Done!'
publish_core.ios: fail_on_dev build_core.ios
@echo '------------------------------------'
@echo ' iOS Core: CocoaPod publishing '
@echo '------------------------------------'
if [ "$$($(PIP) freeze | grep -f $(UTIL_COCOAPOD_PUBLISH_REQ) | wc -l)" != "$$(wc -l < $(UTIL_COCOAPOD_PUBLISH_REQ))" ]; then \
$(PIP) install -r $(UTIL_COCOAPOD_PUBLISH_REQ); echo; \
fi
$(UTIL_COCOAPOD_PUBLISH_CORE_BIN)
@echo 'Done!'
publish_bridge: publish_bridge.android publish_bridge.ios
publish_bridge.android: fail_on_dev build_core.android
@echo '------------------------------------'
@echo ' Android Bridge: Maven publishing '
@echo '------------------------------------'
@cd $(ANDROID_DIR) && ./gradlew bridge:bintrayUpload
@echo 'Done!'
publish_bridge.ios: fail_on_dev build_core.ios
@echo '------------------------------------'
@echo ' iOS Bridge: CocoaPod publishing '
@echo '------------------------------------'
if [ "$$($(PIP) freeze | grep -f $(UTIL_COCOAPOD_FORMAT_REQ) -f $(UTIL_COCOAPOD_PUBLISH_REQ) | wc -l)" != "$$(cat $(UTIL_COCOAPOD_FORMAT_REQ) $(UTIL_COCOAPOD_PUBLISH_REQ) | sort | uniq | wc -l )" ]; then \
$(PIP) install -r $(UTIL_COCOAPOD_FORMAT_REQ) -r $(UTIL_COCOAPOD_PUBLISH_REQ); echo; \
fi
$(UTIL_COCOAPOD_FORMAT_BRIDGE_BIN) && $(UTIL_COCOAPOD_PUBLISH_BRIDGE_BIN)
@echo 'Done!'
build_bridge.ios: fail_on_dev build_core.ios
@echo '------------------------------------'
@echo ' iOS Bridge: CocoaPod build '
@echo '------------------------------------'
if [ "$$($(PIP) freeze | grep -f $(UTIL_COCOAPOD_FORMAT_REQ) -f $(UTIL_COCOAPOD_PUBLISH_REQ) | wc -l)" != "$$(cat $(UTIL_COCOAPOD_FORMAT_REQ) $(UTIL_COCOAPOD_PUBLISH_REQ) | sort | uniq | wc -l )" ]; then \
$(PIP) install -r $(UTIL_COCOAPOD_FORMAT_REQ) -r $(UTIL_COCOAPOD_PUBLISH_REQ); echo; \
fi
$(UTIL_COCOAPOD_FORMAT_BRIDGE_BIN)
@echo 'Done!'
publish_demo: publish_demo.android publish_demo.ios
publish_demo.android: fail_on_dev build_demo.android
@echo '------------------------------------'
@echo ' Android Demo: Bintray publishing '
@echo '------------------------------------'
if [ "$$($(PIP) freeze | grep -f $(UTIL_BINTRAY_PUBLISH_REQ) | wc -l)" != "$$(wc -l < $(UTIL_BINTRAY_PUBLISH_REQ))" ]; then \
$(PIP) install -r $(UTIL_BINTRAY_PUBLISH_REQ); echo; \
fi
$(UTIL_BINTRAY_PUBLISH_ANDROID_BIN)
@echo 'Done!'
publish_demo.ios: fail_on_dev build_demo.ios
@echo '------------------------------------'
@echo ' iOS Demo: Bintray publishing '
@echo '------------------------------------'
@if [ "$$($(PIP) freeze | grep -f $(UTIL_BINTRAY_PUBLISH_REQ) | wc -l)" != "$$(wc -l < $(UTIL_BINTRAY_PUBLISH_REQ))" ]; then \
echo 'Installing pip dependencies:'; $(PIP) install -r $(UTIL_BINTRAY_PUBLISH_REQ); echo; \
fi
#TODO
@echo 'Done!'
# Doc generation rules
docgen: docgen.android docgen.ios
docgen.android: $(ANDROID_DOC_DIR) build_core.android
@echo '------------------------------------'
@echo ' Android Bridge: Doc generation '
@echo '------------------------------------'
cd $(ANDROID_DIR) && ./gradlew bridge:javadoc
cp -rf $(ANDROID_DIR)/bridge/javadoc/* $(ANDROID_DOC_DIR)
@echo 'Done!'
$(ANDROID_DOC_DIR):
@mkdir -p $(ANDROID_DOC_DIR)
docgen.ios: $(IOS_DOC_DIR) build_core.ios
@echo '------------------------------------'
@echo ' iOS Bridge: Doc generation '
@echo '------------------------------------'
cd $(IOS_DIR)/Bridge && \
jazzy -o $(IOS_DOC_DIR) \
--readme $(IOS_DIR)/../README.md \
--module 'GomobileIPFS' \
--title 'Gomobile-IPFS - iOS Bridge' \
--github_url 'https://github.com/ipfs-shipyard/gomobile-ipfs' \
--github-file-prefix 'https://github.com/ipfs-shipyard/gomobile-ipfs/tree/master/ios/Bridge'
@echo 'Done!'
$(IOS_DOC_DIR):
mkdir -p $(IOS_DOC_DIR)
# Test rules
test: test_core test_bridge
test_bridge: test_bridge.android test_bridge.ios
test_bridge.android: build_core.android
@echo '------------------------------------'
@echo ' Android Bridge: running test '
@echo '------------------------------------'
cd $(ANDROID_DIR) && ./gradlew bridge:test && \
EMULATOR=$$(emulator -avd -list-avds | tail -n1); \
if [ -z "$$EMULATOR" ]; then \
>&2 echo "No emulator found to run the test"; \
exit 1; \
fi; \
emulator -avd $$EMULATOR -no-boot-anim -no-window -no-snapshot-save -gpu swiftshader_indirect -noaudio & EMULATOR_PID=$$!; \
adb wait-for-device shell 'while [[ -z $$(getprop sys.boot_completed) ]]; do sleep 1; done;'; \
(cd $(ANDROID_DIR) && ./gradlew bridge:connectedAndroidTest) || \
(kill $$EMULATOR_PID; exit 1) && \
(kill $$EMULATOR_PID; echo 'Done!')
test_bridge.ios: build_core.ios
@echo '------------------------------------'
@echo ' iOS Bridge: running test '
@echo '------------------------------------'
DESTINATION=$$(xcodebuild -showdestinations -project $(IOS_DIR)/Bridge/GomobileIPFS.xcodeproj -scheme GomobileIPFS | awk '/Ineligible destinations for/ {exit} {print}' | grep 'platform:iOS Simulator' | awk -F 'id:' '{print $$2}' | cut -d',' -f1 | tail -n1); \
if [ -z "$$DESTINATION" ]; then \
>&2 echo "No compatible simulator found to run the test"; \
exit 1; \
fi; \
xcodebuild test -project $(IOS_DIR)/Bridge/GomobileIPFS.xcodeproj -scheme GomobileIPFS -sdk iphonesimulator -destination "platform=iOS Simulator,id=$$DESTINATION"
@echo 'Done!'
test_core:
@echo '------------------------------------'
@echo ' Go Core: running test '
@echo '------------------------------------'
cd $(GO_DIR) && go test -v ./...
@echo 'Done!'
# Misc rules
fail_on_dev:
if [ "$(VERSION)" == "$(DEV_VERSION)" ]; then \
>&2 echo "Can't publish a dev version: GOMOBILE_IPFS_VERSION env variable not set"; \
exit 1; \
fi
# Clean rules
clean: clean.android clean.ios
clean.android:
@echo '------------------------------------'
@echo ' Android Core: removing build dir '
@echo '------------------------------------'
rm -rf $(ANDROID_BUILD_DIR)
# gomobile cache
ifneq (, $(wildcard $(ANDROID_GOMOBILE_CACHE)))
chmod -R u+wx $(ANDROID_GOMOBILE_CACHE) && rm -rf $(ANDROID_GOMOBILE_CACHE)
endif
@echo 'Done!'
clean.ios:
@echo '------------------------------------'
@echo ' iOS Core: removing build dir '
@echo '------------------------------------'
rm -rf $(IOS_BUILD_DIR)
# gomobile cache
ifneq (, $(wildcard $(IOS_GOMOBILE_CACHE)))
chmod -R u+wx $(IOS_GOMOBILE_CACHE) && rm -rf $(IOS_GOMOBILE_CACHE)
endif
@echo 'Done!'