forked from ender672/rubyinstaller
/
ruby18.rake
151 lines (128 loc) · 4.86 KB
/
ruby18.rake
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
require 'rake'
require 'rake/clean'
namespace(:interpreter) do
namespace(:ruby18) do
package = RubyInstaller::Ruby18
directory package.target
directory package.build_target
directory package.install_target
CLEAN.include(package.target)
CLEAN.include(package.build_target)
CLEAN.include(package.install_target)
# Put files for the :download task
package.files.each do |f|
file_source = "#{package.url}/#{f}"
file_target = "downloads/#{f}"
download file_target => file_source
# depend on downloads directory
file file_target => "downloads"
# download task need these files as pre-requisites
task :download => file_target
end
task :checkout => "downloads" do
cd RubyInstaller::ROOT do
# If is there already a checkout, update instead of checkout"
if File.exist?(File.join(RubyInstaller::ROOT, package.checkout_target, '.svn'))
sh "svn update #{package.checkout_target}"
else
sh "svn co #{package.checkout} #{package.checkout_target}"
end
end
end
task :extract => [:extract_utils, package.target] do
# grab the files from the download task
files = Rake::Task['interpreter:ruby18:download'].prerequisites
# use the checkout copy instead of the packaged file
unless ENV['CHECKOUT']
files.each { |f|
extract(File.join(RubyInstaller::ROOT, f), package.target)
}
else
cp_r(package.checkout_target, File.join(RubyInstaller::ROOT, 'sandbox'), :verbose => true, :remove_destination => true)
end
end
ENV['CHECKOUT'] ? task(:extract => :checkout) : task(:extract => :download)
task :prepare => [package.build_target] do
cd RubyInstaller::ROOT do
cp_r(Dir.glob('resources/icons/*.ico'), package.build_target, :verbose => true)
end
# FIXME: Readline is not working, remove it for now.
cd package.target do
rm_f 'test/readline/test_readline.rb'
end
end
makefile = File.join(package.build_target, 'Makefile')
configurescript = File.join(package.target, 'configure')
file configurescript => [ package.target ] do
cd package.target do
msys_sh "autoconf"
end
end
file makefile => [ package.build_target, configurescript ] do
cd package.build_target do
msys_sh "../ruby_1_8/configure #{package.configure_options.join(' ')} --prefix=#{File.join(RubyInstaller::ROOT, package.install_target)}"
end
end
task :configure => makefile
task :compile => makefile do
cd package.build_target do
msys_sh "make"
end
end
task :install => [package.install_target] do
full_install_target = File.expand_path(File.join(RubyInstaller::ROOT, package.install_target))
# perform make install
cd package.build_target do
msys_sh "make install"
end
# verbatim copy the binaries listed in package.dependencies
package.dependencies.each do |dep|
Dir.glob("#{RubyInstaller::MinGW.target}/**/#{dep}").each do |path|
cp path, File.join(package.install_target, "bin")
end
end
# copy original scripts from ruby_1_8 to install_target
Dir.glob("#{package.target}/bin/*").each do |path|
cp path, File.join(package.install_target, "bin")
end
# remove path reference to sandbox (after install!!!)
rbconfig = File.join(package.install_target, 'lib/ruby/1.8/i386-mingw32/rbconfig.rb')
contents = File.read(rbconfig).gsub(/#{Regexp.escape(full_install_target)}/) { |match| "" }
File.open(rbconfig, 'w') { |f| f.write(contents) }
end
# makes the installed ruby the first in the path and use if for the tests!
task :check do
new_ruby = File.join(RubyInstaller::ROOT, package.install_target, "bin").gsub(File::SEPARATOR, File::ALT_SEPARATOR)
ENV['PATH'] = "#{new_ruby};#{ENV['PATH']}"
cd package.build_target do
msys_sh "make check"
end
end
task :manifest do
manifest = File.open(File.join(package.build_target, "manifest"), 'w')
cd package.install_target do
Dir.glob("**/*").each do |f|
manifest.puts(f) unless File.directory?(f)
end
end
manifest.close
end
task :irb do
cd File.join(package.install_target, 'bin') do
sh "irb"
end
end
end
end
if ENV['CHECKOUT']
task :download => ['interpreter:ruby18:checkout']
else
task :download => ['interpreter:ruby18:download']
end
task :extract => ['interpreter:ruby18:extract']
task :prepare => ['interpreter:ruby18:prepare']
task :configure => ['interpreter:ruby18:configure']
task :compile => ['interpreter:ruby18:compile']
task :install => ['interpreter:ruby18:install']
task :check => ['interpreter:ruby18:check']
task :irb => ['interpreter:ruby18:irb']