-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy path1_0_build_install_mswin.ps1
More file actions
145 lines (109 loc) · 4.61 KB
/
Copy path1_0_build_install_mswin.ps1
File metadata and controls
145 lines (109 loc) · 4.61 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<# Code by MSP-Greg
Script for building & installing MSWIN Ruby for CI
Assumes a Ruby exe is in path
Assumes 'Git for Windows' is installed at $env:ProgramFiles\Git
Assumes '7z ' is installed at $env:ProgramFiles\7-Zip
For local use, set items in local.ps1
#>
#————————————————————————————————————————————————————————————————— Set-Variables-Local
# set variables only used in this script
function Set-Variables-Local {
$script:ruby_path = $(ruby.exe -e "puts RbConfig::CONFIG['bindir']").trim().replace('\', '/')
$script:time_info = ''
$script:time_old = $null
$script:time_start = $null
$script:d_vcpkg_install = "$d_vcpkg/installed/x64-windows"
}
#——————————————————————————————————————————————————————————————————— start build
cd $PSScriptRoot
(Get-Content ruby/gems/bundled_gems -raw) -replace '(?m)^syslog.+\n', '' | Set-Content ruby/gems/bundled_gems -NoNewline
$global:build_sys = 'mswin'
. ./0_common.ps1 mswin
Set-Variables
Set-Variables-Local
$env:Path = "$ruby_path;$d_repo/git/cmd;$env:Path;$d_msys2/usr/bin;$d_mingw;"
$env:PKG_CONFIG = "d_vcpkg_install/tools/pkgconf/pkgconf.exe"
$files = 'C:/Windows/System32/libcrypto-1_1-x64.dll',
'C:/Windows/System32/libssl-1_1-x64.dll'
Files-Hide $files
Run-Patches @('rubyinstaller2', 'patches_ri2')
Run-Patches @('ruby', 'patches_install_all', 'patches_install_mswin')
Create-Folders
# set time stamp for reproducible build
$ts = $(git log -1 --format=%at).Trim()
if ($ts -match '\A\d+\z' -and $ts -gt "1540000000") {
$env:SOURCE_DATE_EPOCH = [String][int]$ts
# echo "SOURCE_DATE_EPOCH = $env:SOURCE_DATE_EPOCH"
}
# below sets some directories to normal in case they're set to read-only
Remove-Read-Only $d_ruby
Remove-Read-Only $d_build
cd $d_build
Time-Log "start"
$cmd_config = "..\ruby\win32\configure.bat --disable-install-doc --prefix=$d_install --with-opt-dir=$d_vcpkg_install --with-gmp"
Run $cmd_config { cmd.exe /c "$cmd_config" }
Time-Log "configure"
Run "Makefile" { cat ./Makefile }
Run "nmake incs" {
nmake incs
Check-Exit "'make incs` failure"
}
Time-Log "make incs"
$env:Path = "$d_vcpkg_install\bin;$env:Path"
Run "nmake" {
nmake
Check-Exit "'make` failure"
}
Time-Log "nmake"
Files-Unhide $files
Run "nmake 'DESTDIR=' install-nodoc" {
nmake "DESTDIR=" install-nodoc
Check-Exit "'make install-nodoc' failure"
# generates string like 320, 310, etc
$ruby_abi = ([regex]'\Aruby (\d+\.\d+)').match($(./miniruby.exe -v)).groups[1].value.replace('.', '') + '0'
# set correct ABI version for manifest file
$file = "$d_repo/mswin/ruby-exe.xml"
(Get-Content $file -raw) -replace "ruby\d{3}","ruby$ruby_abi" | Set-Content $file
cd $d_install\bin\ruby_builtin_dlls
echo "installing dll files: From $d_vcpkg_install/bin"
# Changes here requires changes to mswin/ruby_builtin_dlls.manifest and
# mswin/ruby-exe.xml, update version in the below
# <assemblyIdentity type="win32" name="ruby_builtin_dlls" version="1.0.0.4"/>
$dlls = @('gmp-10', 'gmpxx-4', 'libcrypto-3-x64', 'libssl-3-x64', 'ffi-8', 'readline', 'yaml', 'z')
foreach ($dll in $dlls) {
Copy-Item $d_vcpkg_install/bin/$dll.dll
echo " $dll.dll"
}
Copy-Item $d_repo/mswin/ruby_builtin_dlls.manifest
cd $d_install\bin\lib\ossl-modules
Copy-Item $d_vcpkg_install/bin/legacy.dll
cd $d_repo
if (Test-Path -Path $d_install/lib/x64-vcruntime140-ruby$ruby_abi-static.lib -PathType Leaf ) {
del $d_install\lib\x64-vcruntime140-ruby$ruby_abi-static.lib
}
# below can't run from built Ruby, as it needs valid cert files
ruby 1_2_post_install_common.rb run
}
Time-Log "make install-nodoc"
Run "manifest ruby.exe, rubyw.exe" {
cd $d_install\bin
mt.exe -manifest $d_repo\mswin\ruby-exe.xml -outputresource:ruby.exe;1
mt.exe -manifest $d_repo\mswin\ruby-exe.xml -outputresource:rubyw.exe;1
}
Time-Log "manifest ruby.exe, rubyw.exe"
Print-Time-Log
# below needs to run from built/installed Ruby
cd $d_repo
$env:Path = "$d_install\bin;$base_path"
&"$d_install/bin/ruby.exe" 1_4_post_install_bin_files.rb
if (Test-Path Env:\SOURCE_DATE_EPOCH ) { Remove-Item Env:\SOURCE_DATE_EPOCH }
$ruby_exe = "$d_install/bin/ruby.exe"
$ruby_v = &$ruby_exe -v
if (-not ($ruby_v -cmatch "$rarch\]\z")) {
throw("Ruby may have compile/install issue, won't start")
} else {
Write-Host $ruby_v
}
# reset to original
$env:Path = $orig_path
# Apply-Patches "mswin_test_patches"