/
Makefile
447 lines (404 loc) · 12.3 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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
export PWD := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
export PATH := $(PWD)/node_modules/.bin:$(PATH)
react-native := $(PWD)/node_modules/.bin/react-native
pod := pod
bundle := bundle
name ?= berty
platform ?= ios
device ?= iPhone 11
target ?= debug
config ?= development
entry-file ?= index.js
build-dir ?= $(PWD)/build
dest ?= $(build-dir)/$(platform)-$(target)/$(config)
.DEFAULT_GOAL := run
export ENVFILE ?= $(shell \
[ -f "$$PWD/.env.$(config)" ] && echo $$PWD/.env.$(config) || echo $$PWD/.env)
.PHONY: config
config: $(ENVFILE)
@echo $(ENVFILE)
$(ENVFILE):
$(error "config file $@.$(config) does not exist")
.PHONY: \
deps \
deps.ios \
deps.android \
deps.web \
deps.darwin \
deps: $(PWD)/node_modules config
deps.ios: export PWD := $(PWD)
deps.ios: deps $(PWD)/ios/Pods/Manifest.lock /tmp/envfile
$(PWD)/ios/Pods/Manifest.lock: $(PWD)/ios/Podfile $(PWD)/package.json
([ ! -z "$(shell which pod)" ] \
&& [[ "$$(pod --version)" > "1.7." ]]) \
|| sudo gem install cocoapods
cd $(PWD)/ios && $(pod) install
$(PWD)/ios/Podfile: $(PWD)/node_modules
.PHONY: /tmp/envfile
/tmp/envfile: $(ENVFILE)
cat $< > $@
deps.android: export PWD := $(PWD)
deps.android: deps $(PWD)/node_modules/react-native/react.gradle.orig $(if $(filter $(config), development), $(HOME)/.android/debug.keystore)
$(PWD)/node_modules/react-native/react.gradle.orig: $(PWD)/patch/react.gradle.patch
@echo "patching file $(patsubst %.orig, %, $@)"
@patch -f $(patsubst %.orig, %, $@) $< 1>/dev/null || true
deps.web: deps
deps.darwin: deps
.PHONY: start
start: port ?= 8081
start: host ?= 127.0.0.1
start: deps
kill $$(lsof -t -i :$(port)) || true
cd $(PWD) && $(react-native) start \
--port=$(port) \
--host=$(host) \
& \
.PHONY: run
run: export PWD := $(PWD)
run: deps $(if $(filter $(target), debug), start)
$(if $(filter $(platform), android), \
$(if $(filter $(config), development), ANDROID_SDK_ROOT=$$HOME/.android clisim -af))
cd $(PWD) && $(react-native) run-$(platform) \
--no-packager \
$(if $(filter $(platform), android), --variant=$(target)) \
$(if $(filter $(platform), android), --deviceId='$(device)') \
$(if $(filter $(platform), android), \
$(if $(filter-out $(target), store), --appIdSuffix=$(target))) \
$(if $(filter $(platform), ios), --configuration=$(if $(filter $(config), development),Debug,Release)) \
$(if $(filter $(platform), ios), --scheme=$(target)) \
$(if $(filter $(platform), ios), --simulator='$(device)') \
.PHONY: bundle
bundle: deps.$(platform)
cd $(PWD) && $(react-native) bundle \
--entry-file=$(entry) \
--platform=$(platform) \
--bundle-output=$(dest)/main.jsbundle \
--asset-dest=$(dest) \
.PHONY: \
release.ios \
release.ios.debug \
release.ios.staff \
release.ios.yolo \
release.ios.store \
release.android \
release.android.debug \
release.android.staff \
release.android.yolo \
release.android.store \
release.web \
release.web.debug \
release.web.staff \
release.web.yolo \
release.web.store \
release.darwin \
release.darwin.debug \
release.darwin.staff \
release.darwin.yolo \
release.darwin.store \
release.ios.debug: target := debug
release.ios.debug: method := development
release.ios.debug: profile := Development
release.ios.debug: team-id := WMBQ84HN4T
release.ios.debug: release.ios
release.ios.staff: target := staff
release.ios.staff: method := ad-hoc
release.ios.staff: profile := AdHoc
release.ios.staff: team-id := WMBQ84HN4T
release.ios.staff: release.ios
release.ios.yolo: target := yolo
release.ios.yolo: method := enterprise
release.ios.yolo: profile := InHouse
release.ios.yolo: team-id := GR5463T564
release.ios.yolo: release.ios
release.ios.store: target := store
release.ios.store: method := app-store
release.ios.store: profile := AppStore
release.ios.store: team-id := WMBQ84HN4T
release.ios.store: release.ios
release.ios: platform := ios
release.ios: bundle-id = chat.berty.ios.$(target)
release.ios: version = $(shell git describe --tags --always | cut -d - -f 1,2 | tr - .| tail -c +2)
release.ios: keychain-name ?= berty_keychain
release.ios: keychain-password ?= berty_pass
release.ios: git-url ?= git@github.com:berty/berty-ios-certs
release.ios: export FL_BUILDLOG_PATH = $(dest)
release.ios: export GYM_CLEAN = false
release.ios: export GYM_OPTION_METHOD = $(method)
release.ios: export GYM_OPTION_APP_ID = $(bundle-id)
release.ios: export GYM_OPTION_PROVISIONING_PROFILE = "match $(profile) $(bundle-id)"
release.ios: export GYM_OUTPUT_NAME = $(shell echo $(name) | caser --pascal)
release.ios: export GYM_OUTPUT_DIRECTORY = $(dest)
release.ios: export GYM_WORKSPACE = $(PWD)/ios/$(shell echo $(name) | caser --pascal).xcworkspace
release.ios: export GYM_SCHEME = $(target)
release.ios: export GYM_SKIP_PROFILE_DETECTION = true
release.ios: export GYM_INCLUDE_SYMBOLS = false
release.ios: deps.ios
$(if $(profile),, $(error "profile variable not defined"))
$(if $(method),, $(error "method variable not defined"))
# fetch app store profile
cd $(PWD) \
&& $(bundle) exec fastlane run match \
type:$(shell echo $(method) | sed 's/-//g') \
app_identifier:$(bundle-id) \
readonly:true \
team_id:$(team-id) \
$(if $(git-url), git_url:$(git-url)) \
&& time $(bundle) exec fastlane $(platform) build --verbose
release.android.debug:
release.android.staff:
release.android.yolo:
release.android.store:
release.android:
release.web.debug:
release.web.staff:
release.web.yolo:
release.web.store:
release.web:
release.darwin.debug:
release.darwin.staff:
release.darwin.yolo:
release.darwin.store:
release.darwin:
.PHONY: log
log:
cd $(PWD) && $(react-native) log-$(platform)
# HELPERS
.PHONY: \
config.development \
config.production \
config.development: config := development
config.production: config := production
.PHONY: \
start.android \
start.ios \
start.web \
start.darwin \
start.ios: platform := ios
start.ios: start
start.android: platform := android
start.android: start
start.web: platform := web
start.web: start
start.darwin: platform := darwin
start.darwin: start
.PHONY: \
log.android \
log.ios \
log.web \
log.darwin \
log.ios: platform := ios
log.ios: log
log.android: platform := android
log.android: log
log.web: platform := web
log.web: log
log.darwin: platform := darwin
log.darwin: log
.PHONY: \
bundle.android \
bundle.android.debug \
bundle.android.staff \
bundle.android.yolo \
bundle.android.store \
bundle.ios \
bundle.ios.debug \
bundle.ios.staff \
bundle.ios.yolo \
bundle.ios.store \
bundle.web \
bundle.web.debug \
bundle.web.staff \
bundle.web.yolo \
bundle.web.store \
bundle.darwin \
bundle.darwin.staff \
bundle.darwin.yolo \
bundle.darwin.store \
bundle.ios.debug: config := development
bundle.ios.debug: target := debug
bundle.ios.debug: bundle.ios
bundle.ios.staff: config := production
bundle.ios.staff: target := staff
bundle.ios.staff: bundle.ios
bundle.ios.yolo: config := production
bundle.ios.yolo: target := yolo
bundle.ios.yolo: bundle.ios
bundle.ios.store: config := production
bundle.ios.store: target := store
bundle.ios.store: bundle.ios
bundle.ios: platform := ios
bundle.ios: bundle
bundle.android.debug: config := development
bundle.android.debug: target := debug
bundle.android.debug: bundle.android
bundle.android.staff: config := production
bundle.android.staff: target := staff
bundle.android.staff: bundle.android
bundle.android.yolo: config := production
bundle.android.yolo: target := yolo
bundle.android.yolo: bundle.android
bundle.android.store: config := production
bundle.android.store: target := store
bundle.android.store: bundle.android
bundle.android: platform := android
bundle.android: bundle
bundle.web.debug: config := development
bundle.web.debug: target := debug
bundle.web.debug: bundle.web
bundle.web.staff: config := production
bundle.web.staff: target := staff
bundle.web.staff: bundle.web
bundle.web.yolo: config := production
bundle.web.yolo: target := yolo
bundle.web.yolo: bundle.web
bundle.web.store: config := production
bundle.web.store: target := store
bundle.web.store: bundle.web
bundle.web: platform := web
bundle.web: bundle
bundle.darwin.debug: config := development
bundle.darwin.debug: target := debug
bundle.darwin.debug: bundle.darwin
bundle.darwin.staff: config := production
bundle.darwin.staff: target := staff
bundle.darwin.staff: bundle.darwin
bundle.darwin.yolo: config := production
bundle.darwin.yolo: target := yolo
bundle.darwin.yolo: bundle.darwin
bundle.darwin.store: config := production
bundle.darwin.store: target := store
bundle.darwin.store: bundle.darwin
bundle.darwin: platform := darwin
bundle.darwin: bundle
.PHONY: \
run.ios \
run.ios.debug \
run.ios.staff \
run.ios.yolo \
run.ios.store \
run.android \
run.android.debug \
run.android.staff \
run.android.yolo \
run.android.store \
run.web \
run.web.debug \
run.web.staff \
run.web.yolo \
run.web.store \
run.darwin \
run.darwin.staff \
run.darwin.yolo \
run.darwin.store \
run.ios.debug: config := development
run.ios.debug: target := debug
run.ios.debug: run.ios
run.ios.staff: config := production
run.ios.staff: target := staff
run.ios.staff: run.ios
run.ios.yolo: config := production
run.ios.yolo: target := yolo
run.ios.yolo: run.ios
run.ios.store: config := production
run.ios.store: target := store
run.ios.store: run.ios
run.ios: platform := ios
run.ios: deps.ios run
run.android.debug: config := development
run.android.debug: target := debug
run.android.debug: run.android
run.android.staff: config := production
run.android.staff: target := staff
run.android.staff: run.android
run.android.yolo: config := production
run.android.yolo: target := yolo
run.android.yolo: run.android
run.android.store: config := production
run.android.store: target := store
run.android.store: run.android
run.android: platform := android
run.android: device := $(shell which adb >/dev/null && (adb adb devices | tail +2 | head -1 | cut -f 1) || echo "missing-adb-binary")
run.android: deps.android run
run.web.debug: config := development
run.web.debug: target := debug
run.web.debug: run.web
run.web.staff: config := production
run.web.staff: target := staff
run.web.staff: run.web
run.web.yolo: config := production
run.web.yolo: target := yolo
run.web.yolo: run.web
run.web.store: config := production
run.web.store: target := store
run.web.store: run.web
run.web: platform := web
run.web: deps.web run
run.darwin.debug: config := development
run.darwin.debug: target := debug
run.darwin.debug: run.darwin
run.darwin.staff: config := production
run.darwin.staff: target := staff
run.darwin.staff: run.darwin
run.darwin.yolo: config := production
run.darwin.yolo: target := yolo
run.darwin.yolo: run.darwin
run.darwin.store: config := production
run.darwin.store: target := store
run.darwin.store: run.darwin
run.darwin: platform := darwin
run.darwin: deps.darwin run
.IGNORE \
.PHONY: \
clean.ios \
clean.android \
clean.web \
clean.darwin \
clean \
clean.ios: platform := ios
clean.ios: export PWD := $(PWD)
clean.ios:
touch $(PWD)/ios/Podfile
clean.android: export PWD := $(PWD)
clean.android: platform := android
clean.android:
cd $(PWD)/android; \
./gradlew clean; \
rm -rf .gradle; \
clean.web: platform := web
clean.web:
clean.darwin: platform := darwin
clean.darwin:
clean:
.IGNORE \
.PHONY: \
fclean.ios \
fclean.android \
fclean.web \
fclean.darwin \
fclean \
fclean.ios: platform := ios
fclean.ios: export PWD := $(PWD)
fclean.ios:
cd $(PWD)/ios; \
rm -rf build; \
xcodebuild clean; \
rm -rf $(HOME)/Library/Developer/Xcode/DerivedData; \
rm -rf Pods; rm -rf ~/Library/Caches/CocoaPods
fclean.android: platform := android
fclean.android: clean.android
cd $(PWD)/android; \
rm -rf app/build; \
rm -rf $$HOME/.gradle/caches;
fclean.web: platform := web
fclean.web:
fclean.darwin: platform := darwin
fclean.darwin:
fclean: fclean.ios fclean.android fclean.darwin fclean.web
# FIXME(@n0izn0iz): this make rule doesn't work out of the box for me:
# the problem is here https://github.com/berty/berty/pull/1447/files#diff-7231a913a8b27c628fe4fa6137140148R16
# - if we keep using bazel-managed dependencies the label should be @npm//:node_modules/etc..
# - if we don't: we should call lerna bootstrap or some other form of npm install
# in this make rule or as a dependency of it
bazel.android.install:
$(MAKE) -C $(abspath $(PWD)/../react-native-chat-sdk) bazel.build.sdk.android
bazel mobile-install --sandbox_debug --fat_apk_cpu=x86_64,x86,armeabi-v7a //android/app/src/main:app