0
+# -*- mode:ruby; indent-tabs-mode:nil; coding:utf-8 -*-
0
+# vim:ts=2:sw=2:expandtab:
0
+require 'rake/testtask'
0
+# Application own Settings
0
+APPNAME = "«PROJECTNAME»"
0
+TARGET = "#{APPNAME}.app"
0
+#APPVERSION = "rev#{`svn info`[/Revision: (\d+)/, 1]}"
0
+APPVERSION = Time.now.strftime("%Y-%m-%d")
0
+PUBLISH = 'yourname@yourhost:path'
0
+DEFAULT_TARGET = APPNAME
0
+DEFAULT_CONFIGURATION = 'Release'
0
+RELEASE_CONFIGURATION = 'Release'
0
+task :default => [:run]
0
+desc "Build the default and run it."
0
+task :run => [:build] do
0
+ sh %{open "build/Release/#{APPNAME}.app"}
0
+desc 'Build the default target using the default configuration'
0
+task :build => "xcode:build:#{DEFAULT_TARGET}:#{DEFAULT_CONFIGURATION}"
0
+desc 'Deep clean of everything'
0
+ puts %x{ xcodebuild -alltargets clean }
0
+desc "Add files to Xcode project"
0
+ project = %x{ xcodebuild -list }[/Information about project "([^"]+)":/, 1]
0
+ files << "#{project}.xcodeproj"
0
+ exec("rubycocoa", "add", *files)
0
+desc "Create ruby skelton and add to Xcode project"
0
+ if system("rubycocoa", "create", *args)
0
+ project = %x{ xcodebuild -list }[/Information about project "([^"]+)":/, 1]
0
+ exec("rubycocoa", "add", args.last + ".rb", "#{project}.xcodeproj")
0
+desc "Update nib with ruby file"
0
+ args.unshift("English.lproj/MainMenu.nib")
0
+ exec("rubycocoa", "update", *args)
0
+desc "Package the application"
0
+task :package => ["xcode:build:#{DEFAULT_TARGET}:#{RELEASE_CONFIGURATION}", "pkg"] do
0
+ name = "#{APPNAME}.#{APPVERSION}"
0
+ sh %{rubycocoa standaloneify "build/#{DEFAULT_CONFIGURATION}/#{APPNAME}.app" "image/#{APPNAME}.app"}
0
+ puts 'Creating Image...'
0
+ hdiutil create -volname '#{name}' -srcfolder image '#{name}'.dmg
0
+desc 'Make Localized nib from English.lproj and Lang.lproj/nib.strings'
0
+rule(/.nib$/ => [proc {|tn| File.dirname(tn) + '/nib.strings' }]) do |t|
0
+ lproj = File.dirname(t.name)
0
+ target = File.basename(t.name)
0
+ nibtool -d #{lproj}/nib.strings -w #{t.name} English.lproj/#{target}
0
+# [Rubycocoa-devel 906] dynamically xcode rake tasks
0
+# [Rubycocoa-devel 907]
0
+ out = %x{ xcodebuild -list }
0
+ out.scan(/.*Targets:\s+(.*)Build Configurations:.*/m)
0
+ l = l.strip.sub(' (Active)', '')
0
+ targets << l unless l.nil? or l.empty?
0
+def xcode_configurations
0
+ out = %x{ xcodebuild -list }
0
+ out.scan(/.*Build Configurations:\s+(.*)If no build configuration.*/m)
0
+ l = l.strip.sub(' (Active)', '')
0
+ configurations << l unless l.nil? or l.empty?
0
+ targets = xcode_targets
0
+ configs = xcode_configurations
0
+ %w{build clean}.each do |action|
0
+ namespace "#{action}" do
0
+ targets.each do |target|
0
+ desc "#{action} #{target}"
0
+ task "#{target}" do |t|
0
+ puts %x{ xcodebuild -target '#{target}' #{action} }
0
+ # alias the task above using a massaged name
0
+ massaged_target = target.downcase.gsub(/[\s*|\-]/, '_')
0
+ task "#{massaged_target}" => "xcode:#{action}:#{target}"
0
+ namespace "#{target}" do
0
+ configs.each do |config|
0
+ desc "#{action} #{target} #{config}"
0
+ task "#{config}" do |t|
0
+ puts %x{ xcodebuild -target '#{target}' -configuration '#{config}' #{action} }
0
+ # namespace+task aliases of the above using massaged names
0
+ namespace "#{massaged_target}" do
0
+ configs.each { |conf| task "#{conf.downcase.gsub(/[\s*|\-]/, '_')}" => "xcode:#{action}:#{target}:#{conf}" }
0
+if ["update", "add", "create"].include? ARGV[0]
0
+ ARGV.map! {|a| a.sub(/^\+/, "-") }
0
+ Rake.application[ARGV[0].to_sym].invoke