public
Description: Different input source for each application on Leopard
Homepage: http://limechat.net/inputswitcher/
Clone URL: git://github.com/psychs/inputswitcher.git
Click here to lend your support to: inputswitcher and make a donation at www.pledgie.com !
inputswitcher / Rakefile
100644 122 lines (96 sloc) 2.653 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
require 'pathname'
require 'fileutils'
 
APP_SHORT_NAME = 'InputSwitcher'
APP_NAME = APP_SHORT_NAME + '.app'
BUNDLE_NAME = 'InputSwitcherClient.bundle'
 
ROOT_PATH = Pathname.new(__FILE__).dirname
APP_PATH = Pathname.new(__FILE__).dirname + 'app'
BUNDLE_PATH = Pathname.new(__FILE__).dirname + 'bundle'
 
TMP_PATH = Pathname.new("/tmp/#{APP_SHORT_NAME}_build_image")
TMP_SOURCE_PATH = Pathname.new("/tmp/#{APP_SHORT_NAME}_source")
SOURCE_ZIP_PATH = TMP_SOURCE_PATH + "source.zip"
DESKTOP_PATH = Pathname.new('~/Desktop').expand_path
BUILT_APP_PATH = APP_PATH + 'build/Release' + APP_NAME
BUILT_BUNDLE_PATH = BUNDLE_PATH + 'build/Release' + BUNDLE_NAME
 
task :default => [:package_source, :package]
 
task :build => [:build_app, :build_bundle] do |t|
end
 
task :build_app => :clean_app do |t|
  sh "cd app; xcodebuild -configuration Release"
end
 
task :build_bundle => :clean_bundle do |t|
  sh "cd bundle; xcodebuild -configuration Release"
end
 
task :package_source => :clean do |t|
SOURCE_ZIP_PATH.rmtree
TMP_SOURCE_PATH.mkpath
TMP_PATH.rmtree
TMP_PATH.mkpath
ROOT_PATH.cptree(TMP_PATH)
 
rmglob(TMP_PATH + '**/.DS_Store')
 
Dir.chdir(TMP_PATH) do
sh "zip -qr #{SOURCE_ZIP_PATH} *"
end
 
TMP_PATH.rmtree
end
 
task :package => :build do |t|
ZIP_PATH = DESKTOP_PATH + "#{APP_SHORT_NAME}_#{app_version}.zip"
ZIP_PATH.rmtree
TMP_PATH.rmtree
TMP_PATH.mkpath
BUILT_APP_PATH.cptree(TMP_PATH)
BUILT_BUNDLE_PATH.cptree(TMP_PATH)
SOURCE_ZIP_PATH.cptree(TMP_PATH)
SOURCE_ZIP_PATH.cptree(TMP_PATH)
 
Dir.glob(ROOT_PATH.to_s + '/*.txt').each do |file|
   Pathname.new(file).cptree(TMP_PATH)
end
 
rmglob(TMP_PATH + '**/.DS_Store')
 
Dir.chdir(TMP_PATH) do
sh "zip -qr #{ZIP_PATH} *"
end
 
TMP_PATH.rmtree
end
 
task :clean => [:clean_app, :clean_bundle] do |t|
end
 
task :clean_app do |t|
  sh "cd app; rm -rf build check"
end
 
task :clean_bundle do |t|
  sh "cd bundle; rm -rf build check"
end
 
task :check => :clean do |t|
  sh "cd app; scan-build -o ./check --view xcodebuild -configuration Debug"
  sh "cd bundle; scan-build -o ./check --view xcodebuild -configuration Debug"
end
 
 
module Util
def app_version
file = APP_PATH + 'Info.plist'
file.open do |f|
next_line = false
while s = f.gets
if next_line
next_line = false
if s =~ /<string>(.+)<\/string>/
return $1
end
elsif s =~ /<key>CFBundleVersion<\/key>/
next_line = true
end
end
end
nil
end
 
def rmglob(path)
FileUtils.rm_rf(Dir.glob(path.to_s))
end
end
include Util
 
class Pathname
  def rmtree
    FileUtils.rm_rf(to_s)
  end
  
  def cptree(to)
    FileUtils.cp_r(to_s, to.to_s)
  end
end