-
-
Notifications
You must be signed in to change notification settings - Fork 871
/
Rakefile
373 lines (340 loc) · 12.1 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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
#
# Copyright (c) 2015-present, Parse, LLC.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
#
require_relative 'Vendor/xctoolchain/Scripts/xctask/build_task'
SCRIPT_PATH = File.expand_path(File.dirname(__FILE__))
starters_path = File.join(SCRIPT_PATH, 'ParseStarterProject')
ios_simulator = 'platform="iOS Simulator",name="iPhone 14"'
tvos_simulator = 'platform="tvOS Simulator",name="Apple TV"'
watchos_simulator = 'platform="watchOS Simulator",name="Apple Watch Series 8 (45mm)"'
build_action = [XCTask::BuildAction::CLEAN, XCTask::BuildAction::BUILD];
module Constants
require 'plist'
PARSE_CONSTANT_PATH = File.join(SCRIPT_PATH, 'Parse', 'Parse', 'Source/PFConstants.h')
PLISTS = [
File.join(SCRIPT_PATH, 'Parse', 'Parse', 'Resources', 'Parse-iOS.Info.plist'),
File.join(SCRIPT_PATH, 'Parse', 'Parse', 'Resources', 'Parse-OSX.Info.plist'),
File.join(SCRIPT_PATH, 'Parse', 'Parse', 'Resources', 'Parse-watchOS.Info.plist'),
File.join(SCRIPT_PATH, 'Parse', 'Parse', 'Resources', 'Parse-tvOS.Info.plist'),
File.join(SCRIPT_PATH, 'ParseLiveQuery', 'ParseLiveQuery', 'Resources', 'Info.plist'),
File.join(SCRIPT_PATH, 'ParseLiveQuery', 'ParseLiveQuery-tvOS', 'Info.plist'),
File.join(SCRIPT_PATH, 'ParseLiveQuery', 'ParseLiveQuery-watchOS', 'Info.plist'),
File.join(SCRIPT_PATH, 'ParseStarterProject', 'iOS', 'ParseStarterProject', 'Resources', 'Info.plist'),
File.join(SCRIPT_PATH, 'ParseStarterProject', 'iOS', 'ParseStarterProject-Swift', 'Resources', 'Info.plist'),
File.join(SCRIPT_PATH, 'ParseStarterProject', 'OSX', 'ParseOSXStarterProject', 'Resources', 'Info.plist'),
File.join(SCRIPT_PATH, 'ParseStarterProject', 'OSX', 'ParseOSXStarterProject-Swift', 'Resources', 'Info.plist'),
File.join(SCRIPT_PATH, 'ParseStarterProject', 'tvOS', 'ParseStarterProject-Swift', 'ParseStarter', 'Info.plist'),
File.join(SCRIPT_PATH, 'ParseStarterProject', 'watchOS', 'ParseStarterProject-Swift', 'ParseStarter', 'Info.plist'),
File.join(SCRIPT_PATH, 'ParseStarterProject', 'watchOS', 'ParseStarterProject-Swift', 'ParseStarter Extension', 'Info.plist'),
File.join(SCRIPT_PATH, 'ParseStarterProject', 'watchOS', 'ParseStarterProject-Swift', 'Resources', 'Info.plist'),
]
def self.current_version
constants_file = File.open(PARSE_CONSTANT_PATH, 'r').read
matches = constants_file.match(/(.*PARSE_VERSION\s*@")(.*)(")/)
matches[2] # Return the second match, which is the version itself
end
def self.update_version(version)
constants_file = File.open(PARSE_CONSTANT_PATH, 'r+')
constants = constants_file.read
constants.gsub!(/(.*PARSE_VERSION\s*@")(.*)(")/, "\\1#{version}\\3")
constants_file.seek(0)
constants_file.write(constants)
PLISTS.each do |plist|
update_info_plist_version(plist, version)
end
end
def self.update_info_plist_version(plist_path, version)
info_plist = Plist.parse_xml(plist_path)
info_plist['CFBundleShortVersionString'] = version
info_plist['CFBundleVersion'] = version
File.open(plist_path, 'w') { |f| f.write(info_plist.to_plist) }
end
end
namespace :package do
task :set_version, [:version] do |_, args|
version = args[:version] || Constants.current_version
Constants.update_version(version)
end
end
namespace :build do
namespace :ios_starters do
task :all do
Rake::Task['build:ios_starters:objc'].invoke
Rake::Task['build:ios_starters:swift'].invoke
end
task :objc do
project = 'ParseStarterProject'
ios_starters_path = File.join(starters_path, 'iOS', project)
task = XCTask::BuildTask.new do |t|
t.directory = ios_starters_path
t.project = "#{project}.xcodeproj"
t.scheme = project
t.configuration = 'Debug'
t.sdk = 'iphonesimulator'
t.destinations = [ios_simulator]
t.actions = build_action
t.formatter = XCTask::BuildFormatter::XCPRETTY
end
unless task.execute
puts 'iOS Starter Project Failed!'
exit(1)
end
end
task :swift do
project = 'ParseStarterProject-Swift'
ios_starters_path = File.join(starters_path, 'iOS', project)
task = XCTask::BuildTask.new do |t|
t.directory = ios_starters_path
t.project = "#{project}.xcodeproj"
t.scheme = project
t.configuration = 'Debug'
t.sdk = 'iphonesimulator'
t.destinations = [ios_simulator]
t.actions = build_action
t.formatter = XCTask::BuildFormatter::XCPRETTY
end
unless task.execute
puts 'iOS Starter Project Failed!'
exit(1)
end
end
end
namespace :macos_starters do
task :all do
Rake::Task['build:macos_starters:objc'].invoke
Rake::Task['build:macos_starters:swift'].invoke
end
task :objc do
macos_starter_folder = File.join(starters_path, 'OSX', 'ParseOSXStarterProject')
task = XCTask::BuildTask.new do |t|
t.directory = macos_starter_folder
t.project = 'ParseOSXStarterProject.xcodeproj'
t.scheme = 'ParseOSXStarterProject'
t.configuration = 'Debug'
t.sdk = 'macosx'
t.actions = build_action
t.formatter = XCTask::BuildFormatter::XCPRETTY
end
unless task.execute
puts 'macOS Starter Project Failed!'
exit(1)
end
end
task :swift do
macos_starter_folder = File.join(starters_path, 'OSX', 'ParseOSXStarterProject-Swift')
task = XCTask::BuildTask.new do |t|
t.directory = macos_starter_folder
t.project = 'ParseOSXStarterProject-Swift.xcodeproj'
t.scheme = 'ParseOSXStarterProject-Swift'
t.configuration = 'Debug'
t.sdk = 'macosx'
t.actions = build_action
t.formatter = XCTask::BuildFormatter::XCPRETTY
end
unless task.execute
puts 'macOS Starter Project Failed!'
exit(1)
end
end
end
namespace :tvos_starters do
task :all do
# TODO: tvos objc starter
# Rake::Task['build:tvos_starters:objc'].invoke
Rake::Task['build:tvos_starters:swift'].invoke
end
task :swift do
tvos_starter_folder = File.join(starters_path, 'tvOS', 'ParseStarterProject-Swift')
task = XCTask::BuildTask.new do |t|
t.directory = tvos_starter_folder
t.project = 'ParseStarter-Swift.xcodeproj'
t.scheme = 'ParseStarter'
t.configuration = 'Debug'
t.destinations = [tvos_simulator]
t.actions = build_action
t.formatter = XCTask::BuildFormatter::XCPRETTY
end
unless task.execute
puts 'tvOS Starter Project Failed!'
exit(1)
end
end
end
namespace :watchos_starters do
task :all do
# TODO: watchos objc starter
# Rake::Task['build:watchos_starters:objc'].invoke
Rake::Task['build:watchos_starters:swift'].invoke
end
task :swift do
watchos_starter_folder = File.join(starters_path, 'watchOS', 'ParseStarterProject-Swift')
task = XCTask::BuildTask.new do |t|
t.directory = watchos_starter_folder
t.project = 'ParseStarter-Swift.xcodeproj'
t.scheme = 'ParseStarter'
t.configuration = 'Debug'
t.destinations = [watchos_simulator]
t.actions = build_action
t.formatter = XCTask::BuildFormatter::XCPRETTY
end
unless task.execute
puts 'watchOS Starter Project Failed!'
exit(1)
end
end
end
namespace :live_query_starters do
task :all do
Rake::Task['build:live_query_starters:objc'].invoke
Rake::Task['build:live_query_starters:swift'].invoke
end
task :objc do
live_query_starter_folder = File.join(SCRIPT_PATH, 'ParseLiveQuery', 'Examples')
task = XCTask::BuildTask.new do |t|
t.directory = live_query_starter_folder
t.project = 'LiveQueryDemo-ObjC.xcodeproj'
t.scheme = 'LiveQueryDemo-ObjC'
t.configuration = 'Debug'
t.sdk = 'macosx'
t.actions = build_action
t.formatter = XCTask::BuildFormatter::XCPRETTY
end
unless task.execute
puts 'Live Query ObjC Starter Project Failed!'
exit(1)
end
end
task :swift do
live_query_starter_folder = File.join(SCRIPT_PATH, 'ParseLiveQuery', 'Examples')
task = XCTask::BuildTask.new do |t|
t.directory = live_query_starter_folder
t.project = 'LiveQueryDemo.xcodeproj'
t.scheme = 'LiveQueryDemo'
t.configuration = 'Debug'
t.sdk = 'macosx'
t.actions = build_action
t.formatter = XCTask::BuildFormatter::XCPRETTY
end
unless task.execute
puts 'Live Query Swift Starter Project Failed!'
exit(1)
end
end
end
desc 'Build all starters'
task :starters do
Rake::Task['build:tvos_starters:all'].invoke
Rake::Task['build:watchos_starters:all'].invoke
Rake::Task['build:ios_starters:all'].invoke
Rake::Task['build:macos_starters:all'].invoke
Rake::Task['build:live_query_starters:all'].invoke
end
end
namespace :test do
desc 'Run iOS Tests'
task :ios do |_, args|
task = XCTask::BuildTask.new do |t|
t.directory = SCRIPT_PATH
t.workspace = 'Parse.xcworkspace'
t.scheme = 'Parse-iOS'
t.sdk = 'iphonesimulator'
t.destinations = [ios_simulator]
t.configuration = 'Debug -enableCodeCoverage YES'
t.actions = [XCTask::BuildAction::TEST]
t.formatter = XCTask::BuildFormatter::XCPRETTY
end
unless task.execute
puts 'iOS Tests Failed!'
exit(1)
end
end
desc 'Run macOS Tests'
task :macos do |_, args|
task = XCTask::BuildTask.new do |t|
t.directory = SCRIPT_PATH
t.workspace = 'Parse.xcworkspace'
t.scheme = 'Parse-macOS'
t.sdk = 'macosx'
t.configuration = 'Debug -enableCodeCoverage YES'
t.actions = [XCTask::BuildAction::TEST]
t.formatter = XCTask::BuildFormatter::XCPRETTY
end
unless task.execute
puts 'macOS Tests Failed!'
exit(1)
end
end
namespace :parse_live_query do
task :all do
Rake::Task['test:parse_live_query:ios'].invoke
Rake::Task['test:parse_live_query:tvos'].invoke
Rake::Task['test:parse_live_query:watchos'].invoke
Rake::Task['test:parse_live_query:osx'].invoke
end
task :ios do
task = XCTask::BuildTask.new do |t|
t.directory = SCRIPT_PATH
t.workspace = 'Parse.xcworkspace'
t.scheme = 'ParseLiveQuery-iOS'
t.sdk = 'iphonesimulator'
t.destinations = [ios_simulator]
t.configuration = 'Debug'
t.actions = build_action
t.formatter = XCTask::BuildFormatter::XCPRETTY
end
unless task.execute
puts 'Failed to build ParseLiveQuery'
exit(1)
end
end
task :tvos do
task = XCTask::BuildTask.new do |t|
t.directory = SCRIPT_PATH
t.workspace = 'Parse.xcworkspace'
t.scheme = 'ParseLiveQuery-tvOS'
t.destinations = [tvos_simulator]
t.configuration = 'Debug'
t.actions = build_action
t.formatter = XCTask::BuildFormatter::XCPRETTY
end
unless task.execute
puts 'Failed to build ParseLiveQuery-tvOS.'
exit(1)
end
end
task :watchos do
task = XCTask::BuildTask.new do |t|
t.directory = SCRIPT_PATH
t.workspace = 'Parse.xcworkspace'
t.scheme = 'ParseLiveQuery-watchOS'
t.destinations = [watchos_simulator]
t.configuration = 'Debug'
t.actions = build_action
t.formatter = XCTask::BuildFormatter::XCPRETTY
end
unless task.execute
puts 'Failed to build ParseLiveQuery-watchOS.'
exit(1)
end
end
task :osx do
task = XCTask::BuildTask.new do |t|
t.directory = SCRIPT_PATH
t.workspace = 'Parse.xcworkspace'
t.scheme = 'ParseLiveQuery-OSX'
t.configuration = 'Debug'
t.actions = build_action
t.formatter = XCTask::BuildFormatter::XCPRETTY
end
unless task.execute
puts 'Failed to build ParseLiveQuery-OSX.'
exit(1)
end
end
end
end