forked from vertiginous/pik
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
188 lines (136 loc) · 4.8 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
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
# -*- ruby -*-
require 'rubygems'
require 'rbconfig'
require 'uuid'
require 'hoe'
$LOAD_PATH.unshift('lib')
require 'pik'
EXE_VERSION = {
'version' => {
'file_version_number' => "#{Pik::VERSION}.0",
'comments' => 'The Ruby version manager for Windows',
'product_name' => 'Pik',
'file_description' => 'Pik Runner',
'original_filename' => 'pik_runner.exe'
}
}
ENV['SPEC_OPTS']= '-O spec/spec.opts'
lib = FileList["lib/**/*.rb"]
file 'tools/pik_runner.exy', :needs => ['tools/pik_runner'] + lib do
Dir.chdir 'tools' do
sh('ruby -rexerb/mkexy pik_runner pik.bat -v')
end
exy = YAML.load(File.read('tools/pik_runner.exy'))
zlib1 = {
'file' => File.join(RbConfig::CONFIG['bindir'], 'zlib1.dll'),
'type' => 'extension-library'
}
exy['file']['zlib1.dll'] = zlib1
exy['resource'] = EXE_VERSION
File.open('tools/pik_runner.exy', 'w+'){ |f| f.puts YAML.dump(exy) }
end
file 'tools/pik_runner.exe', :needs => ['tools/pik_runner.exy'] do
Dir.chdir 'tools' do
sh('ruby -S exerb pik_runner.exy')
sh('upx -9 pik_runner.exe') unless ENV['QUICK']
end
end
task :build, :needs => 'tools/pik_runner.exe'
task :install, :needs => :build do
sh('ruby bin/pik_install C:\\bin')
end
task :clobber_exe do
rm_rf 'tools/pik_runner.exe'
end
task :clobber_exy, :needs => :clobber_exe do
rm_rf 'tools/pik_runner.exy'
end
task :rebuild, :needs => [:clobber_exy, :build]
task :reinstall, :needs => [:clobber_exy, :install]
task :package => :rebuild
Hoe.plugin :git
Hoe.spec('pik') do
developer('Gordon Thiesfeld', '[email protected]')
self.need_tar = false
self.readme_file = 'README.rdoc'
self.post_install_message =<<-PIM
----------------------------------------------------------------------------
* If you're upgrading from a version <= 0.1.1, you'll want to delete the pik.bat file
from all of your ruby versions. Gem uninstall should do the trick.
* Install pik to a location that's in your path, but someplace other than your ruby\\bin dir
If you're upgrading from a more recent version, pik_install will overwrite the older files as needed.
>path
PATH=C:\\tools\\;C:\\ruby\\186-p368-mingw32\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS
>pik_install C:\\tools
* If this is a first-time install, add all the versions of ruby that you want to use with pik
>pik add
Adding: 186: ruby 1.8.6 (2009-03-31 patchlevel 368) [i386-mingw32]
Located at: c:/ruby/186-p368-mingw32/bin
>pik add C:\\ruby\\IronRuby-091\\bin
Adding: 091: IronRuby 0.9.1.0 on .NET 2.0.0.0
Located at: C:/ruby/IronRuby-091/bin
>pik add C:\\ruby\\jruby-1.4.0RC1\\bin
Adding: 140: jruby 1.4.0RC1 (ruby 1.8.7 patchlevel 174) (2009-09-30 80c263b) (Java HotSpot(TM) Client VM 1.6.0_14) [x86-java]
Located at: C:/ruby/jruby-1.4.0RC1/bin
----------------------------------------------------------------------------
PIM
end
require 'cucumber'
require 'cucumber/rake/task'
@dir = Pathname(File.dirname(__FILE__))
@test_versions = {
'JRuby' => ['1.5.1'],
'IronRuby' => ['0.9.2'],
'Ruby' => [
'1.9.1-p378-1',
'1.8.6-p398-2',
'1.8.7-p249-1'
]
}
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features -f html -o ../pik_cucumber.html -f progress"
end
desc "generate a guid"
task :guid do
puts
puts UUID.new.generate.upcase
end
require 'nokogiri'
directory 'pkg'
@package = 'pik'
@wix_file = "lib/installer/#{@package}.wxs"
@wxs = Nokogiri::XML(File.open(@wix_file))
@product = @wxs.at_css("Product")
msi_file = "pkg/#{@package}-#{Pik::VERSION}.msi"
file msi_file, :needs => 'tools/pik_runner.exe'
task :installer, :needs => [msi_file, :light]
task :build_env do
ENV['PATH'] = "#{ENV['ProgramFiles(x86)']}\\Windows Installer XML v3.5\\bin;#{ENV['PATH']}"
end
task :candle, :needs => [:build_env] do
chdir 'lib/installer/' do
wxs_files = ["MyInstallDirDialog.wxs",'WixUI_MyInstallDir.wxs' , "#{@package}.wxs"].join(' ')
# wxs_files = ["#{@package}.wxs"].join(' ')
sh("candle -nologo #{wxs_files}")
end
end
task :light, :needs => :candle do
chdir 'lib/installer/' do
wixobj_files = ["MyInstallDirDialog.wixobj", 'WixUI_MyInstallDir.wixobj', "#{@package}.wixobj"].join(' ')
# wixobj_files = ["#{@package}.wixobj"].join(' ')
sh("light -nologo -ext WixUtilExtension -ext WixUIExtension #{wixobj_files} -o ../../#{msi_file}")
end
end
def version_string
@version.gsub(".","")
end
task :upgrade do
@product["Version"] = Pik::VERSION
upgrade_max = @product.at_css("UpgradeVersion[Property = 'OLDAPPFOUND']")
upgrade_max["Maximum"] = Pik::VERSION
upgrade_min = @product.at_css("UpgradeVersion[Property = 'NEWAPPFOUND']")
upgrade_min["Minimum"] = Pik::VERSION
@product["Id"] = UUID.new.generate
File.open(@wix_file, 'w+'){|f| f.puts @wxs }
end
# vim: syntax=Ruby