-
Notifications
You must be signed in to change notification settings - Fork 21
/
Rakefile
196 lines (159 loc) · 5.29 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
# encoding: UTF-8
$:.unshift("lib")
require "bundler/setup"
require 'xcode_build'
require 'xcode_build/output_translator'
require 'xcode_build/tasks/build_task'
require 'pp'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
class InspectReporter < XcodeBuild::Reporter
def build_started(params)
pp({:build_started => params})
end
def build_step(params)
pp({:build_step => params})
end
def build_error_detected(params)
pp({:build_error_detected => params})
end
def build_env_variable_detected(key, value)
pp({:build_env_variable_detected => {key => value}})
end
def build_succeeded(build_or_archive)
pp({:build_succeeded => [build_or_archive]})
end
def build_failed(build_or_archive)
pp({:build_failed => [build_or_archive]})
end
def build_step_failed(params)
pp({:build_step_failed => params})
end
def clean_started(params)
pp({:clean_started => params})
end
def clean_step(params)
pp({:clean_step => params})
end
def clean_error_detected(params)
pp({:clean_error_detected => params})
end
def clean_succeeded
pp({:clean_succeeded => {}})
end
def clean_failed
pp({:clean_failed => {}})
end
def clean_step_failed(params)
pp({:clean_step_failed => params})
end
end
namespace :examples do
XcodeBuild::Tasks::BuildTask.new do |t|
t.scheme = 'ExampleProject'
t.invoke_from_within = "resources/ExampleProject"
t.formatter = XcodeBuild::Formatters::ProgressFormatter.new
t.after_build do |build|
end
end
XcodeBuild::Tasks::BuildTask.new(:failing) do |t|
t.scheme = 'FailsWithPostActionScript'
t.invoke_from_within = "resources/FailingExampleProject"
t.formatter = XcodeBuild::Formatters::ProgressFormatter.new
end
end
task :run_tests => :clean_example do
Dir.chdir("resources/ExampleProject") do
reporter = OutputFormatter.new
XcodeBuild.run("-target ExampleProjectTests -sdk iphonesimulator5.0 TEST_HOST=", XcodeBuild::OutputTranslator.new(reporter))
end
end
task :simulate_clean_fail do
Rake::Task["examples:xcode:build"].invoke
FileUtils.chmod(000, "resources/ExampleProject/build/Release-iphoneos/ExampleProject.app")
Rake::Task["examples:xcode:clean"].invoke
end
require "rubygems"
require "rubygems/package_task"
require "rdoc/task"
# This builds the actual gem. For details of what all these options
# mean, and other ones you can add, check the documentation here:
#
# http://rubygems.org/read/chapter/20
#
spec = Gem::Specification.new do |s|
# Change these as appropriate
s.name = "xcodebuild-rb"
s.version = "0.2.0"
s.summary = "Build Xcode projects using Rake"
s.author = "Luke Redpath"
s.email = "[email protected]"
s.homepage = "http://github.com/lukeredpath/xcodebuild-rb"
s.has_rdoc = false
s.extra_rdoc_files = %w(README.md CHANGES.md)
s.rdoc_options = %w(--main README.md)
# Add any extra files to include in the gem
s.files = %w(LICENSE README.md) + Dir.glob("{bin,spec,lib}/**/*")
s.executables = FileList["bin/**"].map { |f| File.basename(f) }
s.require_paths = ["lib"]
# If you want to depend on other gems, add them here, along with any
# relevant versions
s.add_dependency("state_machine", "~> 1.1.2")
# If your tests use any gems, include them here
s.add_development_dependency("rspec")
s.add_development_dependency("rake", "~> 0.9.2.2")
s.add_development_dependency("rdoc", "~> 3.12")
s.add_development_dependency("guard-rspec")
s.add_development_dependency("growl")
s.add_development_dependency("timecop")
end
# This task actually builds the gem. We also regenerate a static
# .gemspec file, which is useful if something (i.e. GitHub) will
# be automatically building a gem for this project. If you're not
# using GitHub, edit as appropriate.
#
# To publish your gem online, install the 'gemcutter' gem; Read more
# about that here: http://gemcutter.org/pages/gem_docs
Gem::PackageTask.new(spec) do |pkg|
pkg.gem_spec = spec
end
desc "Build the gemspec file #{spec.name}.gemspec"
task :gemspec do
file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
File.open(file, "w") {|f| f << spec.to_ruby }
end
# If you don't want to generate the .gemspec file, just remove this line. Reasons
# why you might want to generate a gemspec:
# - using bundler with a git source
# - building the gem without rake (i.e. gem build blah.gemspec)
# - maybe others?
task :package => :gemspec
# Generate documentation
RDoc::Task.new do |rd|
rd.main = "README.md"
rd.rdoc_files.include("README.md", "lib/**/*.rb")
rd.rdoc_dir = "rdoc"
end
desc 'Clear out RDoc and generated packages'
task :clean => [:clobber_rdoc, :clobber_package] do
rm "#{spec.name}.gemspec"
end
desc "Bundle the gems from the gemspec"
task :bundle => :gemspec do
system "bundle install"
end
desc 'Build and release to Rubygems.org'
task :release => :package do
gem_path = File.join('pkg', spec.file_name)
system "gem push #{gem_path}"
end
desc 'Build and install the gem'
task :install => :package do
gem_path = File.join('pkg', spec.file_name)
system("gem install #{gem_path}")
end
desc 'Open Travis CI for this project'
task :ci do
system "open http://travis-ci.org/#!/lukeredpath/xcodebuild-rb"
end