22
33PLATFORM=" platform=iOS Simulator,name=iPhone 7"
44SDK=" iphonesimulator"
5+ DERIVED_DATA_PATH=" ~/ASDKDerivedData"
56
67
78# It is pitch black.
89set -e
9- function trap_handler() {
10+ function trap_handler {
1011 echo -e " \n\nOh no! You walked directly into the slavering fangs of a lurking grue!"
1112 echo " **** You have died ****"
1213 exit 255
1314}
1415trap trap_handler INT TERM EXIT
1516
17+ # Derived data handling
18+ [ -d DERIVED_DATA_PATH ] || mkdir DERIVED_DATA_PATH
19+ function clean_derived_data {
20+ eval find $DERIVED_DATA_PATH -mindepth 1 -delete
21+ }
22+
23+ # Build example
24+ function build_example {
25+ example=" $1 "
26+
27+ clean_derived_data
28+
29+ if [ -f " ${example} /Podfile" ]; then
30+ echo " Using CocoaPods"
31+ if [ -f " ${example} /Podfile.lock" ]; then
32+ rm " $example /Podfile.lock"
33+ fi
34+ rm -rf " $example /Pods"
35+ pod install --project-directory=$example
36+
37+ set -o pipefail && xcodebuild \
38+ -workspace " ${example} /Sample.xcworkspace" \
39+ -scheme Sample \
40+ -sdk " $SDK " \
41+ -destination " $PLATFORM " \
42+ -derivedDataPath " $DERIVED_DATA_PATH " \
43+ build | xcpretty $FORMATTER
44+ elif [ -f " ${example} /Cartfile" ]; then
45+ echo " Using Carthage"
46+ local_repo=` pwd`
47+ current_branch=` git rev-parse --abbrev-ref HEAD`
48+ cd $example
49+
50+ echo " git \" file://${local_repo} \" \" ${current_branch} \" " > " Cartfile"
51+ carthage update --platform iOS
52+
53+ set -o pipefail && xcodebuild \
54+ -project " Sample.xcodeproj" \
55+ -scheme Sample \
56+ -sdk " $SDK " \
57+ -destination " $PLATFORM " \
58+ build | xcpretty $FORMATTER
59+
60+ cd ../..
61+ fi
62+ }
1663
1764MODE=" $1 "
1865
@@ -56,44 +103,7 @@ if [ "$MODE" = "examples" ]; then
56103 for example in examples/* /; do
57104 echo " Building (examples) $example ."
58105
59- rm -rf ~ /ModuleCache
60- rm -rf ~ /Build
61- rm -rf ~ /Info.plist
62- rm -rf ~ /Logs
63-
64- if [ -f " ${example} /Podfile" ]; then
65- echo " Using CocoaPods"
66- if [ -f " ${example} /Podfile.lock" ]; then
67- rm " $example /Podfile.lock"
68- fi
69- rm -rf " $example /Pods"
70- pod install --project-directory=$example
71-
72- set -o pipefail && xcodebuild \
73- -workspace " ${example} /Sample.xcworkspace" \
74- -scheme Sample \
75- -sdk " $SDK " \
76- -destination " $PLATFORM " \
77- -derivedDataPath ~ / \
78- clean build | xcpretty $FORMATTER
79- elif [ -f " ${example} /Cartfile" ]; then
80- echo " Using Carthage"
81- local_repo=` pwd`
82- current_branch=` git rev-parse --abbrev-ref HEAD`
83- cd $example
84-
85- echo " git \" file://${local_repo} \" \" ${current_branch} \" " > " Cartfile"
86- carthage update --platform iOS
87-
88- set -o pipefail && xcodebuild \
89- -project " Sample.xcodeproj" \
90- -scheme Sample \
91- -sdk " $SDK " \
92- -destination " $PLATFORM " \
93- build | xcpretty $FORMATTER
94-
95- cd ../..
96- fi
106+ build_example $example
97107 done
98108 trap - EXIT
99109 exit 0
@@ -107,39 +117,7 @@ if [ "$MODE" = "examples-pt1" ]; then
107117 for example in $(( find ./ examples - type d - maxdepth 1 \( ! - iname ".* " \)) | head -6 | head); do
108118 echo " Building (examples-pt1) $example ."
109119
110- if [ -f " ${example} /Podfile" ]; then
111- echo " Using CocoaPods"
112- if [ -f " ${example} /Podfile.lock" ]; then
113- rm " $example /Podfile.lock"
114- fi
115- rm -rf " $example /Pods"
116- pod install --project-directory=$example
117-
118- set -o pipefail && xcodebuild \
119- -workspace " ${example} /Sample.xcworkspace" \
120- -scheme Sample \
121- -sdk " $SDK " \
122- -destination " $PLATFORM " \
123- -derivedDataPath ~ / \
124- build | xcpretty $FORMATTER
125- elif [ -f " ${example} /Cartfile" ]; then
126- echo " Using Carthage"
127- local_repo=` pwd`
128- current_branch=` git rev-parse --abbrev-ref HEAD`
129- cd $example
130-
131- echo " git \" file://${local_repo} \" \" ${current_branch} \" " > " Cartfile"
132- carthage update --platform iOS
133-
134- set -o pipefail && xcodebuild \
135- -project " Sample.xcodeproj" \
136- -scheme Sample \
137- -sdk " $SDK " \
138- -destination " $PLATFORM " \
139- build | xcpretty $FORMATTER
140-
141- cd ../..
142- fi
120+ build_example $example
143121 done
144122 trap - EXIT
145123 exit 0
@@ -153,39 +131,7 @@ if [ "$MODE" = "examples-pt2" ]; then
153131 for example in $(( find ./ examples - type d - maxdepth 1 \( ! - iname ".* " \)) | head -12 | tail -6 | head); do
154132 echo " Building $example (examples-pt2)."
155133
156- if [ -f " ${example} /Podfile" ]; then
157- echo " Using CocoaPods"
158- if [ -f " ${example} /Podfile.lock" ]; then
159- rm " $example /Podfile.lock"
160- fi
161- rm -rf " $example /Pods"
162- pod install --project-directory=$example
163-
164- set -o pipefail && xcodebuild \
165- -workspace " ${example} /Sample.xcworkspace" \
166- -scheme Sample \
167- -sdk " $SDK " \
168- -destination " $PLATFORM " \
169- -derivedDataPath ~ / \
170- build | xcpretty $FORMATTER
171- elif [ -f " ${example} /Cartfile" ]; then
172- echo " Using Carthage"
173- local_repo=` pwd`
174- current_branch=` git rev-parse --abbrev-ref HEAD`
175- cd $example
176-
177- echo " git \" file://${local_repo} \" \" ${current_branch} \" " > " Cartfile"
178- carthage update --platform iOS
179-
180- set -o pipefail && xcodebuild \
181- -project " Sample.xcodeproj" \
182- -scheme Sample \
183- -sdk " $SDK " \
184- -destination " $PLATFORM " \
185- build | xcpretty $FORMATTER
186-
187- cd ../..
188- fi
134+ build_example $example
189135 done
190136 trap - EXIT
191137 exit 0
@@ -199,39 +145,7 @@ if [ "$MODE" = "examples-pt3" ]; then
199145 for example in $(( find ./ examples - type d - maxdepth 1 \( ! - iname ".* " \)) | head -7 | head); do
200146 echo " Building $example (examples-pt3)."
201147
202- if [ -f " ${example} /Podfile" ]; then
203- echo " Using CocoaPods"
204- if [ -f " ${example} /Podfile.lock" ]; then
205- rm " $example /Podfile.lock"
206- fi
207- rm -rf " $example /Pods"
208- pod install --project-directory=$example
209-
210- set -o pipefail && xcodebuild \
211- -workspace " ${example} /Sample.xcworkspace" \
212- -scheme Sample \
213- -sdk " $SDK " \
214- -destination " $PLATFORM " \
215- -derivedDataPath ~ / \
216- build | xcpretty $FORMATTER
217- elif [ -f " ${example} /Cartfile" ]; then
218- echo " Using Carthage"
219- local_repo=` pwd`
220- current_branch=` git rev-parse --abbrev-ref HEAD`
221- cd $example
222-
223- echo " git \" file://${local_repo} \" \" ${current_branch} \" " > " Cartfile"
224- carthage update --platform iOS
225-
226- set -o pipefail && xcodebuild \
227- -project " Sample.xcodeproj" \
228- -scheme Sample \
229- -sdk " $SDK " \
230- -destination " $PLATFORM " \
231- build | xcpretty $FORMATTER
232-
233- cd ../..
234- fi
148+ build_example $example
235149 done
236150 trap - EXIT
237151 exit 0
@@ -245,44 +159,23 @@ if [ "$MODE" = "examples-extra" ]; then
245159 for example in $(( find ./ examples_extra - type d - maxdepth 1 \( ! - iname ".* " \)) | head -7 | head); do
246160 echo " Building $example (examples-extra)."
247161
248- if [ -f " ${example} /Podfile" ]; then
249- echo " Using CocoaPods"
250- if [ -f " ${example} /Podfile.lock" ]; then
251- rm " $example /Podfile.lock"
252- fi
253- rm -rf " $example /Pods"
254- pod install --project-directory=$example
255-
256- set -o pipefail && xcodebuild \
257- -workspace " ${example} /Sample.xcworkspace" \
258- -scheme Sample \
259- -sdk " $SDK " \
260- -destination " $PLATFORM " \
261- -derivedDataPath ~ / \
262- build | xcpretty $FORMATTER
263- elif [ -f " ${example} /Cartfile" ]; then
264- echo " Using Carthage"
265- local_repo=` pwd`
266- current_branch=` git rev-parse --abbrev-ref HEAD`
267- cd $example
268-
269- echo " git \" file://${local_repo} \" \" ${current_branch} \" " > " Cartfile"
270- carthage update --platform iOS
271-
272- set -o pipefail && xcodebuild \
273- -project " Sample.xcodeproj" \
274- -scheme Sample \
275- -sdk " $SDK " \
276- -destination " $PLATFORM " \
277- build | xcpretty $FORMATTER
278-
279- cd ../..
280- fi
162+ build_example $example
281163 done
282164 trap - EXIT
283165 exit 0
284166fi
285167
168+ # Support building a specific example: sh build.sh example examples/ASDKLayoutTransition
169+ if [ " $MODE " = " example" ]; then
170+ echo " Verifying that all AsyncDisplayKit examples compile."
171+ # Update cocoapods repo
172+ pod repo update master
173+
174+ build_example $2
175+ trap - EXIT
176+ exit 0
177+ fi
178+
286179if [ " $MODE " = " life-without-cocoapods" ]; then
287180 echo " Verifying that AsyncDisplayKit functions as a static library."
288181
0 commit comments