Permalink
Browse files

whitespace

  • Loading branch information...
1 parent a4e1649 commit 5a8d10a011cf4670347ff4b938b166b08b2dc3eb @probablycorey committed May 31, 2011
Showing with 23 additions and 23 deletions.
  1. +23 −23 bin/hammer
View
@@ -20,7 +20,7 @@ class Hammer
@should_run = false
@verbose = false
@device = "iphone"
-
+
def self.setup
opts = OptionParser.new do |opts|
opts.banner = "Description: Builds an iPhone app and optionaly will run it in the simulator"
@@ -33,45 +33,45 @@ class Hammer
opts.on("-c", "--configuration ARG", "Debug? Release?") do |v|
@args["-configuration"] = v
end
-
+
opts.on("-o", "--outputname ARG", "Name of the executable") do |v|
v.gsub!(/\.app$/, "") # .app is automatically added by xcode
@settings["CONFIGURATION_BUILD_DIR"]= "."
@settings["PRODUCT_NAME"] = v
end
-
+
opts.on("-h", "--headless", "Just runs the app from the command line, no simulator") do
@should_run_headless = true
end
-
+
opts.on("-r", "--run", "Run the app in the simulator") do
@should_run = true
end
- opts.on("-d", "--device ARG", "Choose what device to run on (iphone/ipad)") do |v|
+ opts.on("-d", "--device ARG", "Choose what device to run on (iphone/ipad)") do |v|
@device = v
end
- opts.on("-s", "--sdk ARG", "Choose he SDK. Use --showsdks to see options.") do |v|
+ opts.on("-s", "--sdk ARG", "Choose he SDK. Use --showsdks to see options.") do |v|
v = "iphonesimulator#{v}" if v =~ /^[\d\.]+/ # if only the version is given... assume user wants a simulator build
- @args["-sdk"] = v
+ @args["-sdk"] = v
end
-
- opts.on("-v", "--verbose", "blah blah blah.") do |v|
+
+ opts.on("-v", "--verbose", "blah blah blah.") do |v|
@verbose = v
end
-
+
opts.on("--showsdks", "Lists available SDKS.") do
output = `xcodebuild -showsdks`
sdks = output.scan(/-sdk (.*?$)/m)
puts "Availible sdks:"
sdks.each {|sdk| puts " #{sdk}"}
-
+
exit
end
end.parse!
-
+
# if no sdk given, default to the most recent simulator build
if !@args["-sdk"]
output = `xcodebuild -showsdks`
@@ -80,7 +80,7 @@ class Hammer
if @device !~ /pad/i # remove sdk version 3.2, it is ipad only
sdks.reject! {|a| a =~ /3.2$/}
end
-
+
@args["-sdk"] = sdks.find_all {|sdk| sdk =~ /iphonesimulator/}.sort.last
end
end
@@ -100,24 +100,24 @@ class Hammer
if @verbose or not successful
puts output
if not successful
- puts("** BUILD FAILED **")
+ puts("** BUILD FAILED **")
exit 1
end
end
# Take on the builds ENV
- output.scan(/^\s*setenv\s+(\w+)\s+(.*?)$/).each {|k,v| ENV[k] = v}
-
+ output.scan(/^\s*(\w+)=(.*?)$/).each {|k,v| ENV[k] = v}
+
return output
end
- def self.headless
+ def self.headless
return if not @should_run_headless
if ENV["PLATFORM_NAME"] !~ /simulator/
puts "Can only be run on the simulator not #{ENV["PLATFORM_NAME"]}"
exit 1
end
-
+
`/usr/bin/killall "iPhone Simulator" 2> /dev/null` #make sure the simulator is killed
# See http://developer.apple.com/technotes/tn2004/tn2124.html for an explanation of these environment variables.
@@ -128,12 +128,12 @@ class Hammer
FileUtils.rm_rf(ENV["CFFIXED_USER_HOME"]) if File.exists?(ENV["CFFIXED_USER_HOME"])
FileUtils.mkdir_p(ENV["CFFIXED_USER_HOME"] + "/Documents")
-
+
system("#{self.app_path}/#{ENV['EXECUTABLE_NAME']} -RegisterForSystemEvents")
-
+
exit 0
end
-
+
def self.run
return if not @should_run
`/usr/bin/killall "iPhone Simulator" 2> /dev/null` #make sure the simulator is killed
@@ -142,7 +142,7 @@ class Hammer
puts cmd
system cmd
end
-
+
def self.app_path
return "#{ENV['TARGET_BUILD_DIR']}/#{ENV['EXECUTABLE_FOLDER_PATH']}"
end
@@ -154,4 +154,4 @@ Hammer.build
Hammer.headless
-Hammer.run
+Hammer.run

0 comments on commit 5a8d10a

Please sign in to comment.