Skip to content
Newer
Older
100644 190 lines (157 sloc) 5.15 KB
4e75b7b @Caged Initial import
Caged authored Mar 1, 2008
1 # -*- mode:ruby; indent-tabs-mode:nil; coding:utf-8 -*-
2 # vim:ts=2:sw=2:expandtab:
3 require 'rubygems'
4 require 'rake'
5 require 'rake/clean'
6 require 'rake/testtask'
7 require 'pathname'
8
9 # Application own Settings
3f411c6 @Caged About to remove the webview in favor of a table which has true cocoa …
Caged authored Mar 2, 2008
10 APPNAME = "GitNub"
4e75b7b @Caged Initial import
Caged authored Mar 2, 2008
11 TARGET = "#{APPNAME}.app"
12 #APPVERSION = "rev#{`svn info`[/Revision: (\d+)/, 1]}"
13 APPVERSION = Time.now.strftime("%Y-%m-%d")
14 PUBLISH = 'yourname@yourhost:path'
15 DEFAULT_TARGET = APPNAME
16 DEFAULT_CONFIGURATION = 'Release'
17 RELEASE_CONFIGURATION = 'Release'
18
19 # Tasks
20 task :default => [:run]
21
1fd064f @kballard Error out in `rake run` if the open4 library cannot be found
kballard authored May 10, 2008
22 task :testdeps do
23 begin
24 require 'open4'
25 rescue LoadError
26 raise "You need to install the open4 gem before building GitNub"
27 end
28 end
29
a6ad7f3 @Caged Scrap big html view in favor of cocoa controls
Caged authored Mar 3, 2008
30 task :launch do
3f411c6 @Caged About to remove the webview in favor of a table which has true cocoa …
Caged authored Mar 2, 2008
31 sh %{open "build/Release/#{APPNAME}.app"}
32 end
33
4e75b7b @Caged Initial import
Caged authored Mar 2, 2008
34 desc "Build the default and run it."
1fd064f @kballard Error out in `rake run` if the open4 library cannot be found
kballard authored May 10, 2008
35 task :run => [:testdeps, :build] do
b667ee1 @kballard Make the run task launch GitNub directly, so errors show up in the te…
kballard authored May 14, 2008
36 sh %{"build/Release/#{APPNAME}.app/Contents/MacOS/#{APPNAME}"}
4e75b7b @Caged Initial import
Caged authored Mar 2, 2008
37 end
38
39 desc 'Build the default target using the default configuration'
40 task :build => "xcode:build:#{DEFAULT_TARGET}:#{DEFAULT_CONFIGURATION}"
41
42 desc 'Deep clean of everything'
43 task :clean do
fc4de4e @kballard Add OBJROOT=build/ and SYMROOT=build/ to all xcodebuild tasks besides…
kballard authored Mar 13, 2008
44 puts %x{ xcodebuild -alltargets clean OBJROOT=build/ SYMROOT=build/ }
4e75b7b @Caged Initial import
Caged authored Mar 2, 2008
45 end
46
ceed7d1 @kballard Add install (and related) tasks to the Rakefile
kballard authored May 14, 2008
47 desc 'Install GitNub.app and nub'
48 task :install => [:testdeps, :install_app, :install_nub]
49
50 desc 'Install GitNub.app in /Applications'
51 task :install_app => [:uninstall_app, "xcode:install:#{DEFAULT_TARGET}:#{RELEASE_CONFIGURATION}"]
52
53 desc 'Install nub in /usr/local/bin/'
54 task :install_nub do
55 exec("sudo", "cp", "nub", "/usr/local/bin/nub")
56 end
57
58 desc 'Uninstall /Applications/GitNub.app'
59 task :uninstall_app do
60 # this is necessary for install_app, because Xcode, for some braindead reason,
61 # chmods the installed product a-w, so I can't overwrite or rm it
62 if File.exists?("/Applications/GitNub.app")
63 system("chmod", "-R", "u+w", "/Applications/GitNub.app")
64 system("rm", "-rf", "/Applications/GitNub.app")
65 end
66 end
67
4e75b7b @Caged Initial import
Caged authored Mar 2, 2008
68 desc "Add files to Xcode project"
69 task :add do |t|
70 files = ARGV[1..-1]
71 project = %x{ xcodebuild -list }[/Information about project "([^"]+)":/, 1]
72 files << "#{project}.xcodeproj"
73 exec("rubycocoa", "add", *files)
74 end
75
76 desc "Create ruby skelton and add to Xcode project"
77 task :create do |t|
78 args = ARGV[1..-1]
79 if system("rubycocoa", "create", *args)
80 project = %x{ xcodebuild -list }[/Information about project "([^"]+)":/, 1]
81 exec("rubycocoa", "add", args.last + ".rb", "#{project}.xcodeproj")
82 end
83 end
84
85 desc "Update nib with ruby file"
86 task :update do |t|
87 args = ARGV[1..-1]
88 args.unshift("English.lproj/MainMenu.nib")
89 exec("rubycocoa", "update", *args)
90 end
91
92 desc "Package the application"
93 task :package => ["xcode:build:#{DEFAULT_TARGET}:#{RELEASE_CONFIGURATION}", "pkg"] do
94 name = "#{APPNAME}.#{APPVERSION}"
95 mkdir "image"
96 sh %{rubycocoa standaloneify "build/#{DEFAULT_CONFIGURATION}/#{APPNAME}.app" "image/#{APPNAME}.app"}
97 puts 'Creating Image...'
98 sh %{
99 hdiutil create -volname '#{name}' -srcfolder image '#{name}'.dmg
100 rm -rf image
101 mv '#{name}.dmg' pkg
102 }
103 end
104
105 directory 'pkg'
106
107 desc 'Make Localized nib from English.lproj and Lang.lproj/nib.strings'
108 rule(/.nib$/ => [proc {|tn| File.dirname(tn) + '/nib.strings' }]) do |t|
109 p t.name
110 lproj = File.dirname(t.name)
111 target = File.basename(t.name)
112 rm_rf t.name
113 sh %{
114 nibtool -d #{lproj}/nib.strings -w #{t.name} English.lproj/#{target}
115 }
116 end
117
118 # [Rubycocoa-devel 906] dynamically xcode rake tasks
119 # [Rubycocoa-devel 907]
120 #
121 def xcode_targets
122 out = %x{ xcodebuild -list }
123 out.scan(/.*Targets:\s+(.*)Build Configurations:.*/m)
124
125 targets = []
126 $1.each_line do |l|
127 l = l.strip.sub(' (Active)', '')
128 targets << l unless l.nil? or l.empty?
129 end
130 targets
131 end
132
133 def xcode_configurations
134 out = %x{ xcodebuild -list }
135 out.scan(/.*Build Configurations:\s+(.*)If no build configuration.*/m)
136
137 configurations = []
138 $1.each_line do |l|
139 l = l.strip.sub(' (Active)', '')
140 configurations << l unless l.nil? or l.empty?
141 end
142 configurations
143 end
144
145 namespace :xcode do
146 targets = xcode_targets
147 configs = xcode_configurations
148
ceed7d1 @kballard Add install (and related) tasks to the Rakefile
kballard authored May 14, 2008
149 %w{build clean install}.each do |action|
4e75b7b @Caged Initial import
Caged authored Mar 2, 2008
150 namespace "#{action}" do
151
152 targets.each do |target|
153 desc "#{action} #{target}"
154 task "#{target}" do |t|
ceed7d1 @kballard Add install (and related) tasks to the Rakefile
kballard authored May 14, 2008
155 puts %x{ xcodebuild -target '#{target}' #{action} OBJROOT=build/ SYMROOT=build/ DSTROOT=/ }
4e75b7b @Caged Initial import
Caged authored Mar 2, 2008
156 end
157
158 # alias the task above using a massaged name
159 massaged_target = target.downcase.gsub(/[\s*|\-]/, '_')
160 task "#{massaged_target}" => "xcode:#{action}:#{target}"
161
162
163 namespace "#{target}" do
164 configs.each do |config|
165 desc "#{action} #{target} #{config}"
166 task "#{config}" do |t|
ceed7d1 @kballard Add install (and related) tasks to the Rakefile
kballard authored May 14, 2008
167 puts %x{ xcodebuild -target '#{target}' -configuration '#{config}' #{action} SYMROOT=build/ OBJROOT=build/ DSTROOT=/ }
4e75b7b @Caged Initial import
Caged authored Mar 2, 2008
168 end
169 end
170 end
171
172 # namespace+task aliases of the above using massaged names
173 namespace "#{massaged_target}" do
174 configs.each { |conf| task "#{conf.downcase.gsub(/[\s*|\-]/, '_')}" => "xcode:#{action}:#{target}:#{conf}" }
175 end
176
177 end
178
179 end
180 end
181 end
182
183
184 if ["update", "add", "create"].include? ARGV[0]
185 # dupe rake
186 ARGV.map! {|a| a.sub(/^\+/, "-") }
187 Rake.application[ARGV[0].to_sym].invoke
188 exit # will not reach
189 end
Something went wrong with that request. Please try again.