-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile.shared
More file actions
151 lines (122 loc) · 3.95 KB
/
Makefile.shared
File metadata and controls
151 lines (122 loc) · 3.95 KB
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
# ⚠️ This is a shared makefile for WebTrit projects
# Do not modify this file inside individual projects
# Source: https://github.com/WebTrit/webtrit_phone_tools/...
phone_project_path ?= .
# ===========================
# Build config
# ===========================
BUILD_CONFIG_FILE := $(phone_project_path)/build.config
ifeq ($(wildcard $(BUILD_CONFIG_FILE)),)
VERSION := 0.0.0
else
VERSION := $(shell grep '^VERSION=' $(BUILD_CONFIG_FILE) | cut -d '=' -f2)
endif
ifeq ($(strip $(VERSION)),)
VERSION_STAGE := legacy
else ifeq ($(VERSION),0.0.0)
VERSION_STAGE := legacy
else ifeq ($(shell printf "0.0.1\n$(VERSION)" | sort -C -V && echo yes || echo no),no)
VERSION_STAGE := legacy
else ifeq ($(shell printf "0.0.2\n$(VERSION)" | sort -C -V && echo yes || echo no),no)
VERSION_STAGE := v0.0.1
else
VERSION_STAGE := v0.0.2+
endif
# ===========================
# Dart defines path
# ===========================
DART_DEFINE_PATH ?= $(phone_project_path)/dart_define.json
# ===========================
# Flavor compute macros
# ===========================
define compute-deeplink-flavor
$(eval DEEPLINK_DOMAIN := $(shell jq -r '.WEBTRIT_APP_LINK_DOMAIN // ""' $(DART_DEFINE_PATH)))
$(if $(strip $(DEEPLINK_DOMAIN)),\
$(eval DEEPLINK_FLAVOR := deeplinks),\
$(eval DEEPLINK_FLAVOR := deeplinksDisabled))
endef
define compute-sms-flavor
$(eval CALL_TRIGGER_SMS := $(shell jq -r '.WEBTRIT_CALL_TRIGGER_MECHANISM_SMS // "false"' $(DART_DEFINE_PATH)))
$(if $(strip $(filter true,$(CALL_TRIGGER_SMS))),\
$(eval SMS_FLAVOR := smsReceiver),\
$(eval SMS_FLAVOR := smsReceiverDisabled))
endef
# ===========================
# Compute FLAVOR_ARG
# ===========================
define compute-flavor-arg
ifeq ($(VERSION_STAGE),legacy)
FLAVOR_ARG :=
else ifeq ($(VERSION_STAGE),v0.0.1)
$(call compute-deeplink-flavor)
FLAVOR_ARG := --flavor $(DEEPLINK_FLAVOR)
else ifeq ($(VERSION_STAGE),v0.0.2+)
$(call compute-deeplink-flavor)
$(call compute-sms-flavor)
FLAVOR_ARG := --flavor $(DEEPLINK_FLAVOR)$(SMS_FLAVOR)
endif
endef
$(eval $(call compute-flavor-arg))
# ===========================
# Common Flutter CLI flags
# ===========================
FLUTTER_COMMAND_PREFIX := cd $(phone_project_path) && flutter
DART_DEFINE_FILE_ARG := --dart-define-from-file=$(DART_DEFINE_PATH)
COMMON_FLAGS := $(DART_DEFINE_FILE_ARG)
COMMON_BUILD_FLAGS := $(COMMON_FLAGS) --no-tree-shake-icons
BUILD_NAME_ARG := $(if $(build_name),--build-name=$(build_name))
BUILD_NUMBER_ARG := $(if $(build_number),--build-number=$(build_number))
RELEASE_ARG := $(if $(release),--release)
NO_CODESIGN_ARG := $(if $(no_codesign),--no-codesign)
CONFIG_ONLY_ARG := $(if $(config_only),--config-only)
OPTIONAL_BUILD_ARGS := \
$(BUILD_NAME_ARG) \
$(BUILD_NUMBER_ARG) \
$(RELEASE_ARG) \
$(NO_CODESIGN_ARG) \
$(CONFIG_ONLY_ARG)
# ===========================
# Build command macro
# ===========================
define FLUTTER_BUILD_COMMAND
$(FLUTTER_COMMAND_PREFIX) build $(1) \
$(COMMON_BUILD_FLAGS) \
$(if $(filter ios ios-config-only,$(1)),,$(FLAVOR_ARG)) \
$(OPTIONAL_BUILD_ARGS) \
$(2)
endef
# ===========================
# Run command macro
# ===========================
define FLUTTER_RUN_COMMAND
$(FLUTTER_COMMAND_PREFIX) run \
$(COMMON_FLAGS) \
$(if $(filter ios,$(1)),,$(FLAVOR_ARG)) \
$(2)
endef
# ===========================
# Build targets
# ===========================
define build-target
build-$(1):
$(call FLUTTER_BUILD_COMMAND,$(1),$(2))
endef
$(eval $(call build-target,apk,))
$(eval $(call build-target,appbundle,))
$(eval $(call build-target,ios,))
build:
$(call FLUTTER_BUILD_COMMAND,$(BUILD_PLATFORM),)
build-ios-config-only:
$(FLUTTER_COMMAND_PREFIX) build ios \
$(COMMON_BUILD_FLAGS) \
$(OPTIONAL_BUILD_ARGS) \
--config-only
# ===========================
# Run targets
# ===========================
run:
$(call FLUTTER_RUN_COMMAND,$(BUILD_PLATFORM),)
run-ios:
$(call FLUTTER_RUN_COMMAND,ios,)
run-apk:
$(call FLUTTER_RUN_COMMAND,apk,)