forked from KKBOX/CompassApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
123 lines (109 loc) · 4.98 KB
/
Rakefile
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
require 'rawr'
require 'app_bundler'
require 'exe_bundler'
require 'yaml'
module Rawr
class AppBundler
# monkey patch again, option mac_do_not_generate_plist not work
def generate_info_plist
return
end
end
end
namespace :rawr do
namespace :bundle do
task :create_packages_dir do
@packages_dir = File.join(File.dirname(__FILE__), 'packages')
Dir.mkdir( @packages_dir ) unless File.exists?( @packages_dir )
end
task :write_version_info do
@revision ||= (%x{git log | head -c 17 | tail -c 10}).strip
@compile_time ||= Time.now.strftime('%Y%m%d%H%M')
@update_url = open('update_url').readline.strip if File.exists?("update_url")
@update_url ||= ''
File.open "src/compile_version.rb", 'w' do |file|
file << <<-INFO_ENDL
module CompileVersion
REVISION = '#{@revision}'
COMPILE_TIME = '#{@compile_time}'
UPDATE_URL = '#{@update_url}'
end
INFO_ENDL
end
end
task(:app).clear_prerequisites.clear_actions
desc "Bundles the jar from rawr:jar into a native Mac OS X application (.app)"
task :app => ["rawr:bundle:create_packages_dir", "rawr:bundle:write_version_info", "rawr:jar", CONFIG.osx_output_dir ] do
Rawr::AppBundler.new.deploy CONFIG
Dir.chdir File.dirname(__FILE__)
%x{mkdir -p #{CONFIG.osx_output_dir}/#{CONFIG.project_name}.app/Contents/Resources/swt}
%x{cp -R lib/swt/swt_osx* #{CONFIG.osx_output_dir}/#{CONFIG.project_name}.app/Contents/Resources/swt}
%w{ruby images applescript javascripts}.each do | copy_dir |
%x{cp -R lib/#{copy_dir} #{CONFIG.osx_output_dir}/#{CONFIG.project_name}.app/Contents/Resources }
end
Dir.chdir CONFIG.osx_output_dir
%x{mv #{CONFIG.project_name}.app compass.app;}
@osx_bundle_file="compass.app.osx.#{@compile_time}-#{@revision}.zip"
%x{zip -9 -r #{@packages_dir}/#{@osx_bundle_file} compass.app}
%x{mkdir #{@packages_dir}/osx; cp -R compass.app #{@packages_dir}/osx}
end
task(:exe).clear_prerequisites.clear_actions
desc "Bundles the jar from rawr:jar into a native Windows application (.exe)"
task :exe => ["rawr:bundle:create_packages_dir", "rawr:bundle:write_version_info", "rawr:jar", CONFIG.windows_output_dir ] do
Dir.chdir File.dirname(__FILE__)
%x{mkdir -p package/windows/package/windows} # path for launch4j link fle
Rawr::ExeBundler.new.deploy CONFIG
%x{mkdir -p #{CONFIG.windows_output_dir}/lib/swt}
%x{cp -R lib/swt/swt_win* #{CONFIG.windows_output_dir}/lib/swt}
%w{ruby images javascripts}.each do | copy_dir |
%x{cp -R lib/#{copy_dir} #{CONFIG.windows_output_dir}/lib }
end
%x{mv package/windows/package/windows/*.exe package/windows}
%x{rm -rf package/windows/package}
Dir.chdir 'package'
%x{rm -rf compass.app windows/*.xml; mv windows compass.app}
@windows_bundle_file="compass.app.windows.#{@compile_time}-#{@revision}.zip"
%x{zip -9 -r #{@packages_dir}/#{@windows_bundle_file} compass.app}
%x{mkdir #{@packages_dir}/windows; cp -R compass.app #{@packages_dir}/windows}
end
desc "Bundles the jar from rawr:jar into a Linux script"
task :linux => ["rawr:bundle:create_packages_dir", "rawr:bundle:write_version_info", "rawr:jar" ] do
Dir.chdir File.dirname(__FILE__)
%x{mkdir -p package/jar/lib/swt}
%x{cp -R lib/swt/swt_linux* package/jar/lib/swt}
%w{ruby images javascripts}.each do | copy_dir |
%x{cp -R lib/#{copy_dir} package/jar/lib }
end
%x{mv package/jar package/compass.app}
File.open('package/compass.app/run.sh','w') do |f|
f.write("#!/usr/bin/env bash\ncd $(dirname $0)\njava -client -jar compass-app.jar")
end
%x{chmod +x package/compass.app/run.sh}
Dir.chdir 'package'
@linux_bundle_file="compass.app.linux.#{@compile_time}-#{@revision}.zip"
%x{zip -9 -r #{@packages_dir}/#{@linux_bundle_file} compass.app}
%x{mkdir #{@packages_dir}/linux; cp -R compass.app #{@packages_dir}/linux}
end
desc "Bundles Linux, OSX and Window package"
task :all do
Dir.chdir File.dirname(__FILE__)
%x{rm -rf package/* packages/*}
Rake::Task['rawr:bundle:app'].invoke
Rake::Task.tasks.each{|t| t.reenable}
Dir.chdir File.dirname(__FILE__)
%x{rm -rf package/*}
Rake::Task['rawr:bundle:exe'].invoke
Rake::Task.tasks.each{|t| t.reenable}
Dir.chdir File.dirname(__FILE__)
%x{rm -rf package/*}
Rake::Task['rawr:bundle:linux'].invoke
url_base=File.dirname(@update_url)
info={ "linux" => { "compile_version"=> @compile_time, "url"=> File.join(url_base, @linux_bundle_file) },
"osx" => { "compile_version"=> @compile_time, "url"=> File.join(url_base, @osx_bundle_file) },
"windows" => { "compile_version"=> @compile_time, "url"=> File.join(url_base, @windows_bundle_file)} }
open( File.join(@packages_dir,'update.yml'),'w' ) do |f|
f.write info.to_yaml
end
end
end
end