This repository has been archived by the owner on Mar 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathRakefile
291 lines (238 loc) · 9.25 KB
/
Rakefile
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
CONFIGURATION = "Release"
BUILD_SDK_VERSION = ENV['BUILD_SDK_VERSION'] || "8.1"
SIMULATOR_VERSIONS = ENV['SIMULATOR_VERSIONS'] || "8.1"
SIMULATOR_DEVICES = ENV['SIMULATOR_DEVICES'] || "iPhone 5s"
BUILD_DIR = File.join(File.dirname(__FILE__), "build")
require 'tmpdir'
def build_dir(effective_platform_name)
File.join(BUILD_DIR, CONFIGURATION + effective_platform_name)
end
def system_or_exit(cmd, env_overrides = {}, stdout = nil)
puts "Executing #{cmd}"
cmd += " >#{stdout}" if stdout
old_env = {}
env_overrides.each do |key, value|
old_env[key] = ENV[key]
ENV[key] = value
end
system(cmd) or begin
puts "******** Build failed ********"
exit(1)
end
env_overrides.each do |key, value|
ENV[key] = old_env[key]
end
end
def output_file(target)
output_dir = if ENV['IS_CI_BOX']
ENV['CC_BUILD_ARTIFACTS']
else
build_dir = File.join(File.dirname(__FILE__), "build")
Dir.mkdir(build_dir) unless File.exists?(build_dir)
build_dir
end
output_file = File.join(output_dir, "#{target}.output")
puts "Output: #{output_file}"
output_file
end
def build_and_test_scheme(scheme)
sdk = 'iphonesimulator' + BUILD_SDK_VERSION
devices = SIMULATOR_DEVICES.split(",")
versions = SIMULATOR_VERSIONS.split(",")
system_or_exit(
%Q[xcodebuild -workspace PivotalCoreKit.xcworkspace \
-scheme #{scheme} \
-sdk #{sdk} \
build]
)
devices.each do |device|
versions.each do |version|
system_or_exit(
%Q[xcodebuild -workspace PivotalCoreKit.xcworkspace \
-scheme #{scheme} \
-sdk #{sdk} \
-destination platform='iOS Simulator',name='#{device},OS=#{version}' \
test]
)
end
end
end
def build_target(target, project: project, output_file: output_file)
command = %Q[xcodebuild -project #{project}.xcodeproj \
-target #{target} \
-configuration #{CONFIGURATION} \
build \
SYMROOT=#{BUILD_DIR}]
system_or_exit(command, {}, output_file)
end
task :default => [:trim_whitespace, "all:spec"]
task :travis => ["foundation:clean", "uikit:clean", "core_location:clean", "foundation:spec", "uikit:spec", "core_location:spec"]
task :trim_whitespace do
system_or_exit(%Q[git status --short | awk '{if ($1 != "D" && $1 != "R") print $2}' | grep -e '.*\.[mh]$' | xargs sed -i '' -e 's/ / /g;s/ *$//g;'])
end
namespace :foundation do
project = "Foundation/Foundation"
namespace :build do
namespace :core do
task :osx do
output_file = output_file("foundation:build:core:osx")
build_target("Foundation+PivotalCore", project: project, output_file: output_file)
end
task :ios do
output_file = output_file("foundation:build:core:ios")
build_target("Foundation+PivotalCore-StaticLib", project: project, output_file: output_file)
end
end
task :core => ["core:osx", "core:ios"]
namespace :spec_helper do
task :osx do
output_file = output_file("foundation:build:spec_helper:osx")
build_target("Foundation+PivotalSpecHelper", project: project, output_file: output_file)
end
task :ios do
output_file = output_file("foundation:build:spec_helper:ios")
build_target("Foundation+PivotalSpecHelper-StaticLib", project: project, output_file: output_file)
end
end
task :spec_helper => ["spec_helper:osx", "spec_helper:ios"]
namespace :spec_helper_framework do
task :ios do
output_file = output_file("foundation:build:spec_helper_framework:ios")
build_target("Foundation+PivotalSpecHelper-iOS", project: project, output_file: output_file)
end
end
task :spec_helper_framework => ["spec_helper_framework:ios"]
end
namespace :spec do
task :osx => ["build:core:osx", "build:spec_helper:osx"] do
output_file = output_file("foundation:spec:osx")
build_target("FoundationSpec", project: project, output_file: output_file)
build_dir = build_dir("")
env_vars = {
"CEDAR_REPORTER_CLASS" => "CDRColorizedReporter",
"CFFIXED_USER_HOME" => Dir.tmpdir,
"DYLD_FRAMEWORK_PATH" => build_dir
}
system_or_exit("cd #{build_dir}; ./FoundationSpec", env_vars)
end
task :ios do
build_and_test_scheme("Foundation-StaticLibSpec")
end
end
task :build => ["foundation:build:core", "foundation:build:spec_helper"]
task :spec => ["foundation:spec:osx", "foundation:spec:ios"]
task :clean do
<<<<<<< HEAD
system_or_exit(%Q[xcodebuild -project #{project}.xcodeproj -alltargets -configuration #{CONFIGURATION} clean SYMROOT=#{BUILD_DIR}], {}, output_file("foundation:clean"))
=======
system_or_exit(%Q[xcodebuild -project #{project_name}.xcodeproj -alltargets -configuration #{CONFIGURATION} clean SYMROOT=#{BUILD_DIR}], {}, output_file("foundation:clean"))
>>>>>>> Updates Rakefile for WatchKit test helpers
end
end
task :foundation => ["foundation:build", "foundation:spec"]
namespace :uikit do
project = "UIKit/UIKit"
namespace :build do
namespace :core do
task :ios do
output_file = output_file("uikit:build:core:ios")
build_target("UIKit+PivotalCore-StaticLib", project: project, output_file: output_file)
end
end
task :core => ["core:ios"]
namespace :spec_helper do
task :ios do
output_file = output_file("uikit:build:spec_helper:ios")
build_target("UIKit+PivotalSpecHelper-StaticLib", project: project, output_file: output_file)
end
task :ios_stubs do
output_file = output_file("uikit:build:spec_helper:ios_stubs")
build_target("UIKit+PivotalSpecHelperStubs-StaticLib", project: project, output_file: output_file)
end
end
task :spec_helper => ["spec_helper:ios", "spec_helper:ios_stubs"]
namespace :spec_helper_framework do
task :ios do
output_file = output_file("uikit:build:spec_helper_framework:ios")
build_target("UIKit+PivotalSpecHelper-iOS", project: project, output_file: output_file)
end
task :ios_stubs do
output_file = output_file("uikit:build:spec_helper_framework:ios_stubs")
build_project("UIKit+PivotalSpecHelperStubs-iOS", project: project, output_file: output_file)
end
end
task :spec_helper_framework => ["spec_helper_framework:ios", "spec_helper_framework:ios_stubs"]
end
namespace :spec do
task :ios do
build_and_test_scheme("UIKit-StaticLibSpec")
end
end
task :build => ["build:core"]
task :spec => ["spec:ios"]
task :clean do
system_or_exit(%Q[xcodebuild -project #{project}.xcodeproj -alltargets -configuration #{CONFIGURATION} clean SYMROOT=#{BUILD_DIR}], {}, output_file("uikit:clean"))
end
end
task :uikit => ["uikit:build", "uikit:spec"]
namespace :core_location do
project = "CoreLocation/CoreLocation"
namespace :build do
namespace :spec_helper do
task :osx do
output_file = output_file("core_location:build:spec_helper:osx")
build_target("CoreLocation+PivotalSpecHelper", project: project, output_file: output_file)
end
task :ios do
output_file = output_file("core_location:build:spec_helper:ios")
build_target("CoreLocation+PivotalSpecHelper-StaticLib", project: project, output_file: output_file)
end
end
task :spec_helper => ["spec_helper:osx", "spec_helper:ios"]
end
namespace :spec do
task :osx => ["build:spec_helper:osx"] do
output_file = output_file("core_location:spec:osx")
build_target("CoreLocationSpec", project: project, output_file: output_file)
build_dir = build_dir("")
env_vars = {
"DYLD_FRAMEWORK_PATH" => build_dir,
"CEDAR_REPORTER_CLASS" => "CDRColorizedReporter"
}
system_or_exit("cd #{build_dir}; ./CoreLocationSpec", env_vars)
end
task :ios do
build_and_test_scheme("CoreLocation-StaticLibSpec")
end
end
task :build => ["build:spec_helper"]
task :spec => ["spec:osx", "spec:ios"]
task :clean do
system_or_exit(%Q[xcodebuild -project #{project}.xcodeproj -alltargets -configuration #{CONFIGURATION} clean SYMROOT=#{BUILD_DIR}], {}, output_file("core_location:clean"))
end
end
task :core_location => ["core_location:build", "core_location:spec"]
namespace :watchkit do
project_name = "WatchKit/WatchKit"
namespace :build do
task :ios do
system_or_exit(%Q[xcodebuild -project #{project_name}.xcodeproj -scheme WatchKit -sdk iphonesimulator -configuration #{CONFIGURATION} build], {}, output_file("watchkit:build:ios"))
end
end
namespace :spec do
require 'tmpdir'
task :ios do
`osascript -e 'tell application "iPhone Simulator" to quit'`
system_or_exit(%Q[xcodebuild -project #{project_name}.xcodeproj -scheme WatchKit -sdk iphonesimulator build test], {}, output_file("watchkit:spec:ios"))
`osascript -e 'tell application "iPhone Simulator" to quit'`
end
end
task :spec => ["spec:ios"]
task :build => ["build:ios"]
end
task :watchkit => ["watchkit:build", "watchkit:spec"]
namespace :all do
task :build => ["foundation:build", "uikit:build", "core_location:build", "watchkit:build"]
task :spec => ["foundation:spec", "uikit:spec", "core_location:spec", "watchkit:spec"]
task :clean => ["foundation:clean", "uikit:clean", "core_location:clean"]
end