root/lang/ruby/Amalgam/Rakefile @ 1086

Revision 835, 4.3 kB (checked in by cho45, 7 years ago)

lang/ruby/Amalgam/Rakefile,
lang/ruby/Amalgam/user-plugins/firefox_places.rb:

http とるように
publish 先の間違いを修正

Line 
1# -*- mode:ruby; indent-tabs-mode:nil; coding:utf-8 -*-
2# vim:ts=2:sw=2:expandtab:
3require 'rubygems'
4require 'rake'
5require 'rake/clean'
6require 'rake/testtask'
7require 'pathname'
8
9# Application own Settings
10APPNAME               = "Amalgam"
11TARGET                = "#{APPNAME}.app"
12#APPVERSION           = "rev#{`svn info`[/Revision: (\d+)/, 1]}"
13APPVERSION            = Time.now.strftime("%Y-%m-%d")
14PUBLISH               = 'yourname@yourhost:path'
15DEFAULT_TARGET        = APPNAME
16DEFAULT_CONFIGURATION = 'Release'
17RELEASE_CONFIGURATION = 'Release'
18
19# Tasks
20task :default => [:run]
21
22desc "Build the default and run it."
23task :run => [:build] do
24  sh %{open "build/Release/#{APPNAME}.app"}
25end
26
27desc 'Build the default target using the default configuration'
28task :build => "xcode:build:#{DEFAULT_TARGET}:#{DEFAULT_CONFIGURATION}"
29
30desc 'Deep clean of everything'
31task :clean do
32  puts %x{ xcodebuild -alltargets clean }
33end
34
35desc "Add files to Xcode project"
36task :add do |t|
37 files = ARGV[1..-1]
38 project = %x{ xcodebuild -list }[/Information about project "([^"]+)":/, 1]
39 files << "#{project}.xcodeproj"
40 exec("rubycocoa", "add", *files)
41end
42
43desc "Create ruby skelton and add to Xcode project"
44task :create do |t|
45 args = ARGV[1..-1]
46 if system("rubycocoa", "create", *args)
47   project = %x{ xcodebuild -list }[/Information about project "([^"]+)":/, 1]
48   exec("rubycocoa", "add", args.last + ".rb", "#{project}.xcodeproj")
49 end
50end
51
52desc "Update nib with ruby file"
53task :update do |t|
54 args = ARGV[1..-1]
55 args.unshift("English.lproj/MainMenu.nib")
56 exec("rubycocoa", "update", *args)
57end
58
59desc "Package the application"
60task :package => ["xcode:build:#{DEFAULT_TARGET}:#{RELEASE_CONFIGURATION}", "pkg"] do
61  name = "#{APPNAME}.#{APPVERSION}"
62  mkdir "image"
63  sh %{rubycocoa standaloneify "build/#{DEFAULT_CONFIGURATION}/#{APPNAME}.app" "image/#{APPNAME}.app"}
64  cp_r "user-plugins", "image"
65  puts 'Creating Image...'
66  sh %{
67  hdiutil create -volname '#{name}' -srcfolder image '#{name}'.dmg
68  rm -rf image
69  mv '#{name}.dmg' pkg
70  }
71end
72
73desc "Publish package to my site"
74task :publish => [:package] do
75  name = "#{APPNAME}.#{APPVERSION}"
76  sh %{scp "pkg/#{name}.dmg" c:www/lab.lowreal.net/public/test/amalgam/}
77end
78
79directory 'pkg'
80
81desc 'Make Localized nib from English.lproj and Lang.lproj/nib.strings'
82rule(/.nib$/ => [proc {|tn| File.dirname(tn) + '/nib.strings' }]) do |t|
83  p t.name
84  lproj = File.dirname(t.name)
85  target = File.basename(t.name)
86  rm_rf t.name
87  sh %{
88  nibtool -d #{lproj}/nib.strings -w #{t.name} English.lproj/#{target}
89  }
90end
91
92# [Rubycocoa-devel 906] dynamically xcode rake tasks
93# [Rubycocoa-devel 907]
94#
95def xcode_targets
96  out = %x{ xcodebuild -list }
97  out.scan(/.*Targets:\s+(.*)Build Configurations:.*/m)
98
99  targets = []
100  $1.each_line do |l|
101    l = l.strip.sub(' (Active)', '')
102    targets << l unless l.nil? or l.empty?
103  end
104  targets
105end
106
107def xcode_configurations
108  out = %x{ xcodebuild -list }
109  out.scan(/.*Build Configurations:\s+(.*)If no build configuration.*/m)
110
111  configurations = []
112  $1.each_line do |l|
113    l = l.strip.sub(' (Active)', '')
114    configurations << l unless l.nil? or l.empty?
115  end
116  configurations
117end
118
119namespace :xcode do
120 targets = xcode_targets
121 configs = xcode_configurations
122
123 %w{build clean}.each do |action|
124   namespace "#{action}" do
125
126     targets.each do |target|
127       desc "#{action} #{target}"
128       task "#{target}" do |t|
129         puts %x{ xcodebuild -target '#{target}' #{action} }
130       end
131
132       # alias the task above using a massaged name
133       massaged_target = target.downcase.gsub(/[\s*|\-]/, '_')
134       task "#{massaged_target}" => "xcode:#{action}:#{target}"
135
136
137       namespace "#{target}" do
138         configs.each do |config|
139           desc "#{action} #{target} #{config}"
140           task "#{config}" do |t|
141             puts %x{ xcodebuild -target '#{target}' -configuration '#{config}' #{action} }
142           end
143         end
144       end
145
146       # namespace+task aliases of the above using massaged names
147       namespace "#{massaged_target}" do
148         configs.each { |conf| task "#{conf.downcase.gsub(/[\s*|\-]/, '_')}" => "xcode:#{action}:#{target}:#{conf}" }
149       end
150
151     end
152
153   end
154 end
155end
156
157
158if ["update", "add", "create"].include? ARGV[0]
159  # dupe rake
160  ARGV.map! {|a| a.sub(/^\+/, "-") }
161  Rake.application[ARGV[0].to_sym].invoke
162  exit # will not reach
163end
Note: See TracBrowser for help on using the browser.