forked from kubo/ruby-oci8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkpkg-win32.rb
163 lines (144 loc) · 4.65 KB
/
mkpkg-win32.rb
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
require 'fileutils'
$ruby_oci8_version = open('lib/oci8/version.rb').readlines.collect do |line|
(line =~ /VERSION = "([^"]*)"/) && $1
end.compact[0]
case ARGV[0]
when '32'
$platform = 'x86'
$ruby_base_dirs = []
$ruby_base_dirs =
[
'c:\ruby\ruby-1.9.1-p430-i386-mingw32',
'c:\ruby\ruby-2.0.0-p0-i386-mingw32',
'c:\ruby\ruby-2.1.3-i386-mingw32',
'c:\ruby\ruby-2.2.1-i386-mingw32',
'c:\ruby\ruby-2.3.0-i386-mingw32',
'c:\ruby\rubyinstaller-2.4.1-1-x86',
'c:\ruby\rubyinstaller-2.5.0-1-x86',
'c:\ruby\rubyinstaller-2.6.0-1-x86',
]
$oracle_path = 'c:\oracle\instantclient_12_1-win32'
$devkit_tdm_setup = 'c:\ruby\devkit-tdm-32\devkitvars.bat'
$devkit_mingw64_setup = 'c:\ruby\devkit-mingw64-32\devkitvars.bat'
$ridk_setup = 'ridk enable'
$build_ruby_dirs =
[
['c:\ruby\ruby-1.9.1-p430-i386-mingw32', $devkit_tdm_setup],
['c:\ruby\ruby-2.0.0-p0-i386-mingw32', $devkit_mingw64_setup],
['c:\ruby\ruby-2.1.3-i386-mingw32', $devkit_mingw64_setup],
['c:\ruby\ruby-2.2.1-i386-mingw32', $devkit_mingw64_setup],
['c:\ruby\ruby-2.3.0-i386-mingw32', $devkit_mingw64_setup],
['c:\ruby\rubyinstaller-2.4.1-1-x86', $ridk_setup],
['c:\ruby\rubyinstaller-2.5.0-1-x86', $ridk_setup],
['c:\ruby\rubyinstaller-2.6.0-1-x86', $ridk_setup],
]
$cygwin_dir = 'c:\cygwin'
when '64'
$platform = 'x64'
$ruby_base_dirs =
[
# RubyInstaller <URL:http://rubyinstaller.org>
'c:\ruby\ruby-2.0.0-p0-x64-mingw32',
'c:\ruby\ruby-2.1.3-x64-mingw32',
'c:\ruby\ruby-2.2.1-x64-mingw32',
'c:\ruby\ruby-2.3.0-x64-mingw32',
'c:\ruby\rubyinstaller-2.4.1-1-x64',
'c:\ruby\rubyinstaller-2.5.0-1-x64',
'c:\ruby\rubyinstaller-2.6.0-1-x64',
]
$oracle_path = 'c:\oracle\instantclient_12_1-win64'
$devkit_mingw64_setup = 'c:\ruby\devkit-mingw64-64\devkitvars.bat'
$ridk_setup = 'ridk enable'
$build_ruby_dirs =
[
['c:\ruby\ruby-2.0.0-p0-x64-mingw32', $devkit_mingw64_setup],
['c:\ruby\ruby-2.1.3-x64-mingw32', $devkit_mingw64_setup],
['c:\ruby\ruby-2.2.1-x64-mingw32', $devkit_mingw64_setup],
['c:\ruby\ruby-2.3.0-x64-mingw32', $devkit_mingw64_setup],
['c:\ruby\rubyinstaller-2.4.1-1-x64', $ridk_setup],
['c:\ruby\rubyinstaller-2.5.0-1-x64', $ridk_setup],
['c:\ruby\rubyinstaller-2.6.0-1-x64', $ridk_setup],
]
$cygwin_dir = 'c:\cygwin64'
when 'all'
FileUtils.cp_r('.', 'c:\build\ruby-oci8-build-64')
FileUtils.cp_r('.', 'c:\build\ruby-oci8-build-32')
Dir.chdir('c:\build\ruby-oci8-build-64') do
system('ruby mkpkg-win32.rb 64')
end
Dir.chdir('c:\build\ruby-oci8-build-32') do
system('ruby mkpkg-win32.rb 32')
end
else
puts "#{ARGV[0]} (32|64)"
exit 0
end
$gem_package = "ruby-oci8-#{$ruby_oci8_version}-#{$platform}-mingw32.gem"
ENV['PATH'] = $oracle_path + ';' + ENV['PATH']
def prepend_path(basedir, others = [])
orig_env = ENV['PATH']
begin
ENV['PATH'] = basedir + '\bin;' + others.collect{|p| p + ';'}.join('') + orig_env
yield
ensure
ENV['PATH'] = orig_env
end
end
def ruby_oci8_gem_is_installed?
open("|gem list -d ruby-oci8", 'r') do |f|
while line = f.gets
if line =~ /ruby-oci8/
return true
end
end
end
false
end
def run_cmd(cmd, raise_on_error = true)
system(cmd)
raise $?.to_s if raise_on_error && $?.to_i != 0
end
def make_gem
Dir.glob('ext/oci8/oci8lib_*.so') do |file|
File.delete file
end
$build_ruby_dirs.each do |ruby, dev_setup|
prepend_path(ruby) do
run_cmd("#{dev_setup} && ruby setup.rb config -- --with-runtime-check && ruby setup.rb setup")
end
end
ruby_for_gem_build = $build_ruby_dirs[0][0]
prepend_path(ruby_for_gem_build) do
run_cmd("gem build ruby-oci8.gemspec -- current")
end
end
def install_and_test
$ruby_base_dirs.each do |base_dir|
prepend_path(base_dir) do
puts "=================================================="
puts " #{base_dir}"
puts "=================================================="
STDOUT.flush
if ruby_oci8_gem_is_installed?
run_cmd("gem uninstall ruby-oci8 --all")
if ruby_oci8_gem_is_installed?
raise "ruby-oci8 gem in #{base_dir} could not be uninstalled."
end
end
run_cmd("gem install ./#{$gem_package} --local")
run_cmd("ruby -I. test/test_all.rb", false)
end
end
end
def test_on_cygwin
prepend_path($cygwin_dir) do
run_cmd("ruby setup.rb config")
run_cmd("ruby setup.rb setup")
run_cmd("ruby -Iext/oci8 -Ilib -I. test/test_all.rb", false)
end
end
make_gem
ENV['TNS_ADMIN'] = 'c:\oraclexe\app\oracle\product\11.2.0\server\network\admin'
ENV['LOCAL'] = 'XE'
install_and_test
test_on_cygwin