-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
142 lines (113 loc) · 3.68 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
include Config/Makefile/shared.mk
APP_NAME=AbemaTutorial
TEST_SCHEMES = \
Extension \
UILogic \
UseCase
BUILD_DIR=$(PROJECT_ROOT)/build
RESULT_BUNDLE_PATH ?= $(BUILD_DIR)/xcresults/$(subst /,_,$@)_$(shell date +%Y%m%d%H%M%S).xcresult
BUNDLER_VERSION = $(shell tail -n 1 Gemfile.lock | tr -cd "[:digit:]\.")
BUNDLE_EXEC=bundle _$(BUNDLER_VERSION)_ exec
XCODE_OUTPUT_FORMATTER ?= $(XCBEAUTIFY)
PODS_ROOT ?= $(PROJECT_ROOT)/Pods
PODS_PROJECT ?= $(PODS_ROOT)/Pods.xcodeproj
PODS_BUILD_DIR ?= $(PODS_ROOT)/_Build
PODS_REPO_UPDATE_TIMESTAMP := ./Pods/.repo-update-timestamp
PODS_BUILD_TARGETS ?=
default: bootstrap
# Bootstrap
.PHONY: bootstrap
bootstrap: pod-build mockolo
# RubyGems
install-gems: vendor/bundle
vendor/bundle: Gemfile Gemfile.lock
scripts/install-bundler.sh
@touch vendor/bundle
# CocoaPods
.PHONY: pod-install
pod-install: install-gems xcodegen $(PODS_REPO_UPDATE_TIMESTAMP)
@xcodebuild -version > Pods/xcodebuild.version
$(BUNDLE_EXEC) pod install
$(MAKE) $(PODS_ROOT)/.gitignore
@# CocoaPodsがxcodeprojを変更してしまうので再生成する
$(MAKE) xcodegen
# 直接使用するファイルが存在するディレクトリをignoreしないためのgitignoreを生成
#
# xcconfigとxcfilelistから参照されているファイル名を検索する
# PODS_TARGET_SRCROOTは全てのPodsに定義されているので無視する
$(PODS_ROOT)/.gitignore: FORCE
@find Pods/Target\ Support\ Files -name '*.xcconfig' -or -name '*.xcfilelist' \
| xargs -I{} grep -v -E 'PODS_TARGET_SRCROOT =' {} \
| grep -o -E '\$$\{PODS_ROOT\}/.[a-zA-Z0-9 _-]+' \
| sort -u \
| PODS_ROOT= envsubst \
| xargs -I{} echo !{} \
> $@
# CocoaPodsでインストールしたPodを事前ビルドする
#
# Usage:
# make pod-build ... 全てのPodを再ビルド
# make pod-build PODS_BUILD_TARGETS="A B C" ... Pod A, B, Cとその依存Podを再ビルド
.PHONY: pod-build
pod-build: pod-build/iphoneos pod-build/iphonesimulator
.PHONY: pod-build
pod-build/%: pod-install
xcodebuild build \
-project $(PODS_PROJECT) \
-sdk $(notdir $@) \
$(if $(PODS_BUILD_TARGETS),$(addprefix -target ,$(PODS_BUILD_TARGETS)),-alltargets) \
-configuration Release \
ONLY_ACTIVE_ARCH=NO \
SYMROOT=$(PODS_BUILD_DIR) \
| $(MAKE) test-output-formatter
scripts/cocoapods/pod-checksum.rb --update $(PODS_BUILD_TARGETS)
$(PODS_REPO_UPDATE_TIMESTAMP): vendor/bundle Podfile Podfile.lock
$(BUNDLE_EXEC) pod repo update
@touch $(PODS_REPO_UPDATE_TIMESTAMP) >> /dev/null || true
# Tools
.PHONY: brew-install
brew-install:
$(BREW_PREFIX)/bin/brew install rbenv
mockolo: $(MOCKOLO)
ifeq ($(CI),)
$(MAKE) -C ./Targets/UseCaseInterface mockolo
$(MAKE) -C ./Targets/Domain mockolo
$(MAKE) -C ./Targets/UILogicInterface mockolo
else
@echo Skipping Mockolo on CI
endif
.PHONY: xcodegen
xcodegen: $(XCODEGEN)
BREW_PREFIX=$(BREW_PREFIX) \
$(XCODEGEN)
.PHONY: xcodegen-dump
xcodegen-dump: $(XCODEGEN)
@$(XCODEGEN) dump --type json
# Xcode build commands
.PHONY: build
build:
xcodebuild build \
-project $(APP_NAME).xcodeproj \
-scheme $(APP_NAME) \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 14' \
-resultBundlePath $(RESULT_BUNDLE_PATH) \
CODE_SIGNING_ALLOWED=NO \
COMPILER_INDEX_STORE_ENABLE=NO
.PHONY: test
test: $(addprefix test/,$(TEST_SCHEMES))
test/%: FORCE
xcodebuild test \
-project $(APP_NAME).xcodeproj \
-scheme $(notdir $@) \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 14' \
-resultBundlePath $(RESULT_BUNDLE_PATH) \
CODE_SIGNING_ALLOWED=NO \
COMPILER_INDEX_STORE_ENABLE=NO
# Utils
.PHONY: test-output-formatter
test-output-formatter: $(XCBEAUTIFY)
$(XCODE_OUTPUT_FORMATTER)
.PHONY: FORCE
FORCE: