forked from adobe/places-monitor-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
220 lines (192 loc) · 8.74 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
# architectures
# source: https://en.wikipedia.org/wiki/List_of_iOS_devices#RAM,_Processor,_and_Highest_supported_iOS_release
# device architectures
ARCH_ARM64 = arm64
ARCH_ARMV7S = armv7s
# armv7 == 32-bit processor - used in iPhone 5 and iPhone 5c, which can run up to iOS 10.3.3...so we have to leave it in for now
ARCH_ARMV7 = armv7
# simulator architectures
ARCH_X86_64 = x86_64
# i386 == 32-bit simulator - cocoapods complains when this is missing so leaving it in
ARCH_I386 = i386
# platforms
SDK_IOS = iphoneos
SDK_IOS_SIMULATOR = iphonesimulator
# configurations
BUILD_IOS_TARGET_VERSION = IPHONEOS_DEPLOYMENT_TARGET=10.0
BUILDFLAGS_BITCODE = BITCODE_GENERATION_MODE=bitcode OTHER_CFLAGS='-fembed-bitcode -Wno-error=unused-command-line-argument'
BUILDFLAGS = GCC_TREAT_WARNINGS_AS_ERRORS=YES GCC_GENERATE_DEBUGGING_SYMBOLS=NO STRIP_INSTALLED_PRODUCT=YES STRIP_STYLE=ALL GCC_PREPROCESSOR_DEFINITIONS='$GCC_PREPROCESSOR_DEFINITIONS NDEBUG=1 NS_BLOCK_ASSERTIONS=1 COMPILEFORAPP'
CORE_LIB_NAME = lib$(EXTENSION_NAME)_iOS.a
DERIVED_DATA = -derivedDataPath
DESTINATION = -destination
ENABLE_COVERAGE = -enableCodeCoverage YES
EXTENSION_NAME = ACPPlacesMonitor
RELEASE = -configuration Release
SDK_VERSION = $(shell grep 'NSString\* const ACPPlacesMonitorExtensionVersion' $(ROOT_DIR)/ACPPlacesMonitor/ACPPlacesMonitorConstants.m | sed 's/.*NSString\* const ACPPlacesMonitorExtensionVersion.*=.*\@\"\(.*\)\".*/\1/')
TEST_DERIVED_DATA = $(DERIVED_DATA) '$(TEST_DERIVED_DATA_PATH)'
TEST_DESTINATION = $(DESTINATION) 'platform=iOS Simulator,name=iPhone 8'
XCODEBUILD = xcodebuild
XCODEBUILD_COMPATIBLE = $(shell [ $(XCODEBUILD_VERSION) -gt 7 ] && echo true)
XCODEBUILD_VERSION = $(shell xcodebuild -version | grep Xcode | sed 's/Xcode[[:space:]]*\([0-9]*\)\..*/\1/')
# directories
BIN_DIR = $(ROOT_DIR)/bin/iOS/
BUILD_DIR = Build/
BUILD_TEMP_DIR = $(BIN_DIR)build_temp/
DEV_BUILD_DIR = devbuild
DOC_DIR = $(ROOT_DIR)/doc
INCLUDE_DIR = $(ROOT_DIR)/code/src/include
LIBRARY_NAME = $(LIB_BASE_NAME)/
PRODUCTS_DIR = Products/
RELEASE_DIR_IPHONE = $(BUILD_DIR)$(PRODUCTS_DIR)Release-$(SDK_IOS)/
RELEASE_DIR_SIMULATOR = $(BUILD_DIR)$(PRODUCTS_DIR)Release-$(SDK_IOS_SIMULATOR)/
ROOT_DIR = .
# environments
WORKSPACE_NAME = $(EXTENSION_NAME).xcworkspace
PROJECT_FILE = $(EXTENSION_NAME).xcodeproj
BUILD_SCHEME = $(EXTENSION_NAME)_iOS
TEST_DERIVED_DATA_PATH = $(EXTENSION_NAME)/out
TEST = test
# files
DOCUMENTATION = documentation.html
LIB_BASE_NAME = lib$(EXTENSION_NAME)_iOS
LICENSE_FILE = LICENSE.md
LIPO_LIB_PHONE = $(BUILD_DIR)$(LIB_BASE_NAME)
RELEASE_NOTES = ReleaseNotes.txt
UNIT_TEST_REPORT = $(TEST_DERIVED_DATA_PATH)/build/reports/iosUnitTestReport
UNIT_TEST_REPORT_HTML = $(UNIT_TEST_REPORT).html
UNIT_TEST_REPORT_XML = $(UNIT_TEST_REPORT).xml
FUNCTIONAL_TEST_REPORT = $(TEST_DERIVED_DATA_PATH)/build/reports/FunctionalTests/iosFunctionalTestReport
FUNCTIONAL_TEST_REPORT_HTML = $(FUNCTIONAL_TEST_REPORT).html
FUNCTIONAL_TEST_REPORT_XML = $(FUNCTIONAL_TEST_REPORT).xml
# targets
check-xcode-version:
# check xcodebuild version (requires version 7 or greater)
@echo "build version: " $(XCODEBUILD_VERSION)
ifeq ($(XCODEBUILD_COMPATIBLE),true)
@echo "Running make with xcodebuild version:" $(XCODEBUILD_VERSION)
else
$(error Failed to run make, incompatible xcodebuild version (requires v7+))
endif
all: check-xcode-version clean arm64 armv7s armv7 x86_64 i386 lipo copy-files
all-no-clean: arm64 armv7s armv7 i386 x86_64 lipo copy-files
setup: update-pods
update: update-pods
build: clean build-shallow
test: unit-test
update-pods:
(pod repo update && pod update)
build-shallow: check-xcode-version x86_64
armv7:
@echo "######################################################################"
@echo "### Building: "$@
@echo "######################################################################"
$(XCODEBUILD) $(RELEASE) \
-workspace $(WORKSPACE_NAME) \
-scheme $(BUILD_SCHEME) \
-sdk $(SDK_IOS) \
-arch $(ARCH_ARMV7) \
-derivedDataPath $(BUILD_TEMP_DIR) \
$(BUILD_IOS_TARGET_VERSION) $(BUILDFLAGS_BITCODE) $(BUILDFLAGS)
mv $(BUILD_TEMP_DIR)$(RELEASE_DIR_IPHONE)$(LIB_BASE_NAME).a \
$(BUILD_TEMP_DIR)$(RELEASE_DIR_IPHONE)$(LIB_BASE_NAME)-$(ARCH_ARMV7).a
armv7s:
@echo "######################################################################"
@echo "### Building: "$@
@echo "######################################################################"
$(XCODEBUILD) $(RELEASE) \
-workspace $(WORKSPACE_NAME) \
-scheme $(BUILD_SCHEME) \
-sdk $(SDK_IOS) \
-arch $(ARCH_ARMV7S) \
-derivedDataPath $(BUILD_TEMP_DIR) \
$(BUILD_IOS_TARGET_VERSION) $(BUILDFLAGS_BITCODE) $(BUILDFLAGS)
mv $(BUILD_TEMP_DIR)$(RELEASE_DIR_IPHONE)$(LIB_BASE_NAME).a \
$(BUILD_TEMP_DIR)$(RELEASE_DIR_IPHONE)$(LIB_BASE_NAME)-$(ARCH_ARMV7S).a
arm64:
@echo "######################################################################"
@echo "### Building: "$@
@echo "######################################################################"
$(XCODEBUILD) $(RELEASE) \
-workspace $(WORKSPACE_NAME) \
-scheme $(BUILD_SCHEME) \
-sdk $(SDK_IOS) \
-arch $(ARCH_ARM64) \
-derivedDataPath $(BUILD_TEMP_DIR) \
$(BUILD_IOS_TARGET_VERSION) $(BUILDFLAGS_BITCODE) $(BUILDFLAGS)
mv $(BUILD_TEMP_DIR)$(RELEASE_DIR_IPHONE)$(LIB_BASE_NAME).a \
$(BUILD_TEMP_DIR)$(RELEASE_DIR_IPHONE)$(LIB_BASE_NAME)-$(ARCH_ARM64).a
i386:
@echo "######################################################################"
@echo "### Building: "$@
@echo "######################################################################"
$(XCODEBUILD) $(RELEASE) \
-workspace $(WORKSPACE_NAME) \
-scheme $(BUILD_SCHEME) \
-sdk $(SDK_IOS_SIMULATOR) \
-arch $(ARCH_I386) \
-derivedDataPath $(BUILD_TEMP_DIR) \
$(BUILD_IOS_TARGET_VERSION) $(BUILDFLAGS)
mv $(BUILD_TEMP_DIR)$(RELEASE_DIR_SIMULATOR)$(LIB_BASE_NAME).a \
$(BUILD_TEMP_DIR)$(RELEASE_DIR_SIMULATOR)$(LIB_BASE_NAME)-$(ARCH_I386).a
x86_64:
@echo "######################################################################"
@echo "### Building: "$@
@echo "######################################################################"
$(XCODEBUILD) $(RELEASE) \
-workspace $(WORKSPACE_NAME) \
-scheme $(BUILD_SCHEME) \
-sdk $(SDK_IOS_SIMULATOR) \
-arch $(ARCH_X86_64) \
-derivedDataPath $(BUILD_TEMP_DIR) \
$(BUILD_IOS_TARGET_VERSION) $(BUILDFLAGS)
mv $(BUILD_TEMP_DIR)$(RELEASE_DIR_SIMULATOR)$(LIB_BASE_NAME).a \
$(BUILD_TEMP_DIR)$(RELEASE_DIR_SIMULATOR)$(LIB_BASE_NAME)-$(ARCH_X86_64).a
lipo:
@echo "######################################################################"
@echo "### Running: "$@
@echo "######################################################################"
xcrun lipo -create \
$(BUILD_TEMP_DIR)$(RELEASE_DIR_IPHONE)$(LIB_BASE_NAME)-$(ARCH_ARMV7S).a \
$(BUILD_TEMP_DIR)$(RELEASE_DIR_IPHONE)$(LIB_BASE_NAME)-$(ARCH_ARMV7).a \
$(BUILD_TEMP_DIR)$(RELEASE_DIR_IPHONE)$(LIB_BASE_NAME)-$(ARCH_ARM64).a \
$(BUILD_TEMP_DIR)$(RELEASE_DIR_SIMULATOR)$(LIB_BASE_NAME)-$(ARCH_X86_64).a \
$(BUILD_TEMP_DIR)$(RELEASE_DIR_SIMULATOR)$(LIB_BASE_NAME)-$(ARCH_I386).a \
-output $(BIN_DIR)$(LIB_BASE_NAME).a
@echo "============================================================"
@echo "Universal binary created:"
@echo $(LIB_BASE_NAME).a
lipo -info $(BIN_DIR)$(LIB_BASE_NAME).a
@echo "============================================================"
unit-test:
@echo "######################################################################"
@echo "### Unit Testing iOS"
@echo "######################################################################"
$(XCODEBUILD) $(TEST) \
-workspace $(WORKSPACE_NAME) \
-scheme $(BUILD_SCHEME) \
$(TEST_DESTINATION) \
$(TEST_DERIVED_DATA) \
$(ENABLE_COVERAGE)
coverage:
@echo "######################################################################"
@echo "### Unit Test Coverage iOS"
@echo "######################################################################"
rm -rf $(TEST_DERIVED_DATA_PATH)/coverage
mkdir $(TEST_DERIVED_DATA_PATH)/coverage
# capture coverage from object files
lcov --capture --directory \
$(TEST_DERIVED_DATA_PATH)/Build/Intermediates.noindex/$(EXTENSION_NAME).build/Test-iphonesimulator/$(EXTENSION_NAME)_iOS.build/ \
--output-file $(TEST_DERIVED_DATA_PATH)/coverage/test.info
# remove non-source results
lcov --remove $(TEST_DERIVED_DATA_PATH)/coverage/test.info '*/code/unitTests/*' '*/tools/*' '*/v1/*' '*/usr/include/*' \
'/Applications/Xcode.app/*' '*/bourbon-core-cpp/*' '*/bourbon-ios-unit-tests/util/*' \
-o $(TEST_DERIVED_DATA_PATH)/coverage/all.info
# generate html report from results
genhtml $(TEST_DERIVED_DATA_PATH)/coverage/all.info \
--output-directory $(TEST_DERIVED_DATA_PATH)/reports/coverage
clean:
@echo "######################################################################"
@echo "### Cleaning..."
@echo "######################################################################"
-rm -rf $(BUILD_TEMP_DIR)
-rm -rf $(BIN_DIR)$(LIBRARY_NAME)