public
Fork of Caged/gitnub
Description: A Gitk-like application written in RubyCocoa that looks like it belongs on a Mac. See the wiki for downloads and screenshots.
Homepage: http://alternateidea.com
Clone URL: git://github.com/kballard/gitnub.git
Caged (author)
Mon Jun 23 10:58:38 -0700 2008
commit  8f40c3e677bcf5a58caabf209f321284d812fb0a
tree    78cf8577726d87ecbf6cf10c1f47d23f3a007499
parent  29509556e1e453c690b693c2a0ffc77d458c4d08
gitnub / Rakefile
100644 190 lines (157 sloc) 5.269 kb
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
# -*- mode:ruby; indent-tabs-mode:nil; coding:utf-8 -*-
# vim:ts=2:sw=2:expandtab:
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/testtask'
require 'pathname'
 
# Application own Settings
APPNAME = "GitNub"
TARGET = "#{APPNAME}.app"
#APPVERSION = "rev#{`svn info`[/Revision: (\d+)/, 1]}"
APPVERSION = Time.now.strftime("%Y-%m-%d")
PUBLISH = 'yourname@yourhost:path'
DEFAULT_TARGET = APPNAME
DEFAULT_CONFIGURATION = 'Release'
RELEASE_CONFIGURATION = 'Release'
 
# Tasks
task :default => [:run]
 
task :testdeps do
  begin
    require 'open4'
  rescue LoadError
    raise "You need to install the open4 gem before building GitNub"
  end
end
 
task :launch do
  sh %{open "build/Release/#{APPNAME}.app"}
end
 
desc "Build the default and run it."
task :run => [:testdeps, :build] do
  sh %{"build/Release/#{APPNAME}.app/Contents/MacOS/#{APPNAME}"}
end
 
desc 'Build the default target using the default configuration'
task :build => "xcode:build:#{DEFAULT_TARGET}:#{DEFAULT_CONFIGURATION}"
 
desc 'Deep clean of everything'
task :clean do
  puts %x{ xcodebuild -alltargets clean OBJROOT=build/ SYMROOT=build/ }
end
 
desc 'Install GitNub.app and nub'
task :install => [:testdeps, :install_app, :install_nub]
 
desc 'Install GitNub.app in /Applications'
task :install_app => [:uninstall_app, "xcode:install:#{DEFAULT_TARGET}:#{RELEASE_CONFIGURATION}"]
 
desc 'Install nub in /usr/local/bin/'
task :install_nub do
  exec("sudo", "cp", "nub", "/usr/local/bin/nub")
end
 
desc 'Uninstall /Applications/GitNub.app'
task :uninstall_app do
  # this is necessary for install_app, because Xcode, for some braindead reason,
  # chmods the installed product a-w, so I can't overwrite or rm it
  if File.exists?("/Applications/GitNub.app")
    system("chmod", "-R", "u+w", "/Applications/GitNub.app")
    system("rm", "-rf", "/Applications/GitNub.app")
  end
end
 
desc "Add files to Xcode project"
task :add do |t|
 files = ARGV[1..-1]
 project = %x{ xcodebuild -list }[/Information about project "([^"]+)":/, 1]
files << "#{project}.xcodeproj"
 exec("rubycocoa", "add", *files)
end
 
desc "Create ruby skelton and add to Xcode project"
task :create do |t|
 args = ARGV[1..-1]
 if system("rubycocoa", "create", *args)
   project = %x{ xcodebuild -list }[/Information about project "([^"]+)":/, 1]
exec("rubycocoa", "add", args.last + ".rb", "#{project}.xcodeproj")
 end
end
 
desc "Update nib with ruby file"
task :update do |t|
 args = ARGV[1..-1]
 args.unshift("English.lproj/MainMenu.nib")
 exec("rubycocoa", "update", *args)
end
 
desc "Package the application"
task :package => ["xcode:build:#{DEFAULT_TARGET}:#{RELEASE_CONFIGURATION}", "pkg"] do
  name = "#{APPNAME}.#{APPVERSION}"
  mkdir "image"
  sh %{rubycocoa standaloneify "build/#{DEFAULT_CONFIGURATION}/#{APPNAME}.app" "image/#{APPNAME}.app"}
  puts 'Creating Image...'
  sh %{
hdiutil create -volname '#{name}' -srcfolder image '#{name}'.dmg
rm -rf image
mv '#{name}.dmg' pkg
}
end
 
directory 'pkg'
 
desc 'Make Localized nib from English.lproj and Lang.lproj/nib.strings'
rule(/.nib$/ => [proc {|tn| File.dirname(tn) + '/nib.strings' }]) do |t|
  p t.name
  lproj = File.dirname(t.name)
  target = File.basename(t.name)
  rm_rf t.name
  sh %{
nibtool -d #{lproj}/nib.strings -w #{t.name} English.lproj/#{target}
}
end
 
# [Rubycocoa-devel 906] dynamically xcode rake tasks
# [Rubycocoa-devel 907]
#
def xcode_targets
  out = %x{ xcodebuild -list }
  out.scan(/.*Targets:\s+(.*)Build Configurations:.*/m)
 
  targets = []
  $1.each_line do |l|
    l = l.strip.sub(' (Active)', '')
    targets << l unless l.nil? or l.empty?
  end
  targets
end
 
def xcode_configurations
  out = %x{ xcodebuild -list }
  out.scan(/.*Build Configurations:\s+(.*)If no build configuration.*/m)
 
  configurations = []
  $1.each_line do |l|
    l = l.strip.sub(' (Active)', '')
    configurations << l unless l.nil? or l.empty?
  end
  configurations
end
 
namespace :xcode do
 targets = xcode_targets
 configs = xcode_configurations
 
 %w{build clean install}.each do |action|
   namespace "#{action}" do
 
     targets.each do |target|
       desc "#{action} #{target}"
       task "#{target}" do |t|
         puts %x{ xcodebuild -target '#{target}' #{action} OBJROOT=build/ SYMROOT=build/ DSTROOT=/ }
       end
 
       # alias the task above using a massaged name
       massaged_target = target.downcase.gsub(/[\s*|\-]/, '_')
       task "#{massaged_target}" => "xcode:#{action}:#{target}"
 
 
       namespace "#{target}" do
         configs.each do |config|
           desc "#{action} #{target} #{config}"
           task "#{config}" do |t|
             puts %x{ xcodebuild -target '#{target}' -configuration '#{config}' #{action} SYMROOT=build/ OBJROOT=build/ DSTROOT=/ }
           end
         end
       end
 
       # namespace+task aliases of the above using massaged names
       namespace "#{massaged_target}" do
         configs.each { |conf| task "#{conf.downcase.gsub(/[\s*|\-]/, '_')}" => "xcode:#{action}:#{target}:#{conf}" }
       end
 
     end
 
   end
 end
end
 
 
if ["update", "add", "create"].include? ARGV[0]
  # dupe rake
  ARGV.map! {|a| a.sub(/^\+/, "-") }
  Rake.application[ARGV[0].to_sym].invoke
  exit # will not reach
end