forked from kickstarter/ios-oss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
127 lines (103 loc) · 3.56 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
XCODEBUILD := xcodebuild
BUILD_FLAGS = -scheme $(SCHEME) -destination $(DESTINATION)
SCHEME ?= $(TARGET)-$(PLATFORM)
TARGET ?= Kickstarter-Framework
PLATFORM ?= iOS
OS ?= 10.2
RELEASE ?= beta
BRANCH ?= master
DIST_BRANCH = $(RELEASE)-dist
ifeq ($(PLATFORM),iOS)
DESTINATION ?= 'platform=iOS Simulator,name=iPhone 7,OS=10.2'
endif
XCPRETTY :=
ifneq ($(CIRCLE_ARTIFACTS),)
XCPRETTY += | tee $${CIRCLE_ARTIFACTS}/xcode_raw_$(SCHEME).log
endif
ifneq ($(shell type -p xcpretty),)
XCPRETTY += | xcpretty -c && exit $${PIPESTATUS[0]}
endif
build: dependencies
$(XCODEBUILD) $(BUILD_FLAGS) $(XCPRETTY)
test-all:
PLATFORM=iOS "$(MAKE)" test
PLATFORM=iOS TARGET=Library "$(MAKE)" test
test: bootstrap
$(XCODEBUILD) test $(BUILD_FLAGS) $(XCPRETTY)
clean:
$(XCODEBUILD) clean $(BUILD_FLAGS) $(XCPRETTY)
dependencies: submodules configs secrets opentok
bootstrap: hooks dependencies
brew update || brew update
brew unlink swiftlint || true
brew install swiftlint
brew link --overwrite swiftlint
submodules:
git submodule sync --recursive || true
git submodule update --init --recursive || true
configs = $(basename $(wildcard Kickstarter-iOS/Configs/*.example))
$(configs):
cp [email protected] $@
configs: $(configs)
hooks = $(addprefix .git/,$(wildcard hooks/*))
$(hooks):
@test -d .git/hooks && ln -fnsv $(patsubst .git/%,$(PWD)/%,$@) $@ \
|| echo "skipping git hook installation: .git/hooks does not exist" >&2 1>/dev/null
hooks: $(hooks)
deploy:
@echo "Deploying private/$(BRANCH) to $(RELEASE)..."
@git fetch oss
@git fetch private
@if test -n "`git rev-list private/$(BRANCH)..oss/$(BRANCH)`"; \
then \
echo "There are commits in oss/$(BRANCH) that are not in private/$(BRANCH). Please sync the remotes before deploying."; \
exit 1; \
fi
@if test "$(RELEASE)" != "beta" && test "$(RELEASE)" != "itunes"; \
then \
echo "RELEASE must be 'beta' or 'itunes'."; \
exit 1; \
fi
@if test "$(RELEASE)" = "itunes" && test "$(BRANCH)" != "master"; \
then \
echo "BRANCH must be 'master' for iTunes releases."; \
exit 1; \
fi
@git branch -f $(DIST_BRANCH) private/$(BRANCH)
@git push -f private $(DIST_BRANCH)
@git branch -d $(DIST_BRANCH)
@echo "Deploy has been kicked off to CircleCI!"
lint:
swiftlint lint --reporter json --strict
strings:
cat Frameworks/ios-ksapi/Frameworks/native-secrets/ios/Secrets.swift bin/strings.swift \
| xcrun -sdk macosx swift -
secrets:
-@rm -rf Frameworks/ios-ksapi/Frameworks/native-secrets
-@git clone https://github.com/kickstarter/native-secrets Frameworks/ios-ksapi/Frameworks/native-secrets 2>/dev/null || echo '(Skipping secrets.)'
if [ ! -d Frameworks/ios-ksapi/Frameworks/native-secrets ]; \
then \
mkdir -p Frameworks/ios-ksapi/Frameworks/native-secrets/ios \
&& cp -n Configs/Secrets.swift.example Frameworks/ios-ksapi/Frameworks/native-secrets/ios/Secrets.swift \
|| true; \
fi
OPENTOK_VERSION = 2.10.0
VERSION_FILE = Frameworks/OpenTok/version
CURRENT_OPENTOK_VERSION = $(shell cat $(VERSION_FILE))
ifeq ($(CURRENT_OPENTOK_VERSION),)
CURRENT_OPENTOK_VERSION = first
endif
opentok:
@if [ $(OPENTOK_VERSION) != $(CURRENT_OPENTOK_VERSION) ]; \
then \
echo "Downloading OpenTok v$(OPENTOK_VERSION)"; \
mkdir -p Frameworks/OpenTok; \
curl -s -N -L https://tokbox.com/downloads/opentok-ios-sdk-$(OPENTOK_VERSION) \
| tar -xz --strip 1 --directory Frameworks/OpenTok OpenTok-iOS-$(OPENTOK_VERSION)/OpenTok.framework \
|| true; \
fi
@if [ -e Frameworks/OpenTok/OpenTok.framework ]; \
then \
echo "$(OPENTOK_VERSION)" > $(VERSION_FILE); \
fi
.PHONY: test-all test clean dependencies submodules deploy lint secrets strings opentok