-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
67 lines (54 loc) · 2.02 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
PROJECT_NAME = "SingleTrack"
SPECS_TARGET_NAME = "Specs"
PROJECT_ROOT = File.dirname(__FILE__)
BUILD_DIR = File.join(PROJECT_ROOT, "build")
def configuration_build_dir
File.join(BUILD_DIR, build_configuration)
end
def system_or_exit(cmd, stdout = nil)
puts "Executing #{cmd}"
cmd += " >#{stdout}" if stdout
system(cmd) or raise "******** Build failed ********"
end
def output_file(target)
output_dir = if ENV['IS_CI_BOX']
ENV['CC_BUILD_ARTIFACTS']
else
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_configuration
production_build? ? "ProductionRelease" : "Release"
end
def production_build?
ENV["PRODUCTION"]
end
task default: [:trim_whitespace, :specs]
task :cruise do
Rake::Task[:clean].invoke
Rake::Task[:specs].invoke
Rake::Task["afn:specs"].invoke
end
task all: :cruise
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
task :clean do
system_or_exit(%Q[xcodebuild -project #{PROJECT_NAME}.xcodeproj -alltargets -configuration #{build_configuration} clean SYMROOT=#{BUILD_DIR}], output_file("clean"))
end
task :build_specs do
system_or_exit(%Q[xcodebuild -workspace #{PROJECT_NAME}.xcworkspace -scheme #{SPECS_TARGET_NAME} -configuration #{build_configuration} build CONFIGURATION_BUILD_DIR=#{configuration_build_dir} SYMROOT=#{BUILD_DIR}], output_file("specs"))
end
task :build_all do
system_or_exit(%Q[xcodebuild -project #{PROJECT_NAME}.xcodeproj -alltargets -configuration #{build_configuration} build CONFIGURATION_BUILD_DIR=#{configuration_build_dir} SYMROOT=#{BUILD_DIR}], output_file("build_all"))
end
task specs: :build_specs do
build_dir = configuration_build_dir
ENV["DYLD_FRAMEWORK_PATH"] = build_dir
ENV["CEDAR_REPORTER_CLASS"] = "CDRColorizedReporter"
system_or_exit(File.join(build_dir, SPECS_TARGET_NAME))
end