1
- // Most of this logic is from
2
- // https://github.com/MSP-Greg/actions-ruby/blob/master/lib/main.js
1
+ // 7z arguments
2
+ // -aoa overwrite existing, -bd disable progress indicator
3
3
4
4
const fs = require ( 'fs' )
5
5
const path = require ( 'path' )
@@ -13,9 +13,11 @@ const rubyInstallerVersions = require('./windows-versions.json')
13
13
14
14
const drive = common . drive
15
15
16
- const msys2BasePath = 'C:\\msys64'
17
16
const msys2GCCReleaseURI = 'https://github.com/ruby/setup-msys2-gcc/releases/download'
18
17
18
+ const msys2BasePath = process . env [ 'GHCUP_MSYS2' ]
19
+ const vcPkgBasePath = process . env [ 'VCPKG_INSTALLATION_ROOT' ]
20
+
19
21
// needed for Ruby 2.0-2.3, and mswin, cert file used by Git for Windows
20
22
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
21
23
@@ -81,6 +83,8 @@ export async function install(platform, engine, version) {
81
83
await installGCCTools ( msys2Type )
82
84
}
83
85
86
+ if ( version === 'mswin' ) { await installVCPkg ( ) }
87
+
84
88
const ridk = `${ rubyPrefix } \\bin\\ridk.cmd`
85
89
if ( fs . existsSync ( ridk ) ) {
86
90
await common . measure ( 'Adding ridk env variables' , async ( ) => addRidkEnv ( ridk ) )
@@ -99,7 +103,6 @@ async function installGCCTools(type) {
99
103
} )
100
104
101
105
await common . measure ( `Extracting ${ type } build tools` , async ( ) =>
102
- // -aoa overwrite existing, -bd disable progress indicator
103
106
exec . exec ( '7z' , [ 'x' , downloadPath , '-aoa' , '-bd' , `-o${ msys2BasePath } ` ] , { silent : true } ) )
104
107
}
105
108
@@ -117,7 +120,6 @@ async function installMSYS2Tools() {
117
120
fs . rmSync ( `${ msys2BasePath } \\var\\lib\\pacman\\local` , { recursive : true , force : true } )
118
121
119
122
await common . measure ( `Extracting msys2 build tools` , async ( ) =>
120
- // -aoa overwrite existing, -bd disable progress indicator
121
123
exec . exec ( '7z' , [ 'x' , downloadPath , '-aoa' , '-bd' , `-o${ msys2BasePath } ` ] , { silent : true } ) )
122
124
}
123
125
@@ -128,6 +130,18 @@ export async function installJRubyTools() {
128
130
await installGCCTools ( 'mingw64' )
129
131
}
130
132
133
+ // Install vcpkg files needed to build mswin Ruby
134
+ async function installVCPkg ( ) {
135
+ const downloadPath = await common . measure ( `Downloading mswin vcpkg packages` , async ( ) => {
136
+ let url = `${ msys2GCCReleaseURI } /msys2-gcc-pkgs/mswin.7z`
137
+ console . log ( url )
138
+ return await tc . downloadTool ( url )
139
+ } )
140
+
141
+ await common . measure ( `Extracting mswin vcpkg packages` , async ( ) =>
142
+ exec . exec ( '7z' , [ 'x' , downloadPath , '-aoa' , '-bd' , `-o${ vcPkgBasePath } ` ] , { silent : true } ) )
143
+ }
144
+
131
145
async function downloadAndExtract ( engine , version , url , base , rubyPrefix ) {
132
146
const parentDir = path . dirname ( rubyPrefix )
133
147
@@ -137,7 +151,7 @@ async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
137
151
} )
138
152
139
153
await common . measure ( 'Extracting Ruby' , async ( ) =>
140
- // -bd disable progress indicator, - xr extract but exclude share\doc files
154
+ // -xr extract but exclude share\doc files
141
155
exec . exec ( '7z' , [ 'x' , downloadPath , '-bd' , `-xr!${ base } \\share\\doc` , `-o${ parentDir } ` ] , { silent : true } ) )
142
156
143
157
if ( base !== path . basename ( rubyPrefix ) ) {
@@ -184,18 +198,28 @@ async function installMSYS1(version) {
184
198
async function setupMSWin ( ) {
185
199
core . exportVariable ( 'MAKE' , 'nmake.exe' )
186
200
187
- // All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL
188
- const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
201
+ // Pre-installed OpenSSL use C:\Program Files\Common Files\SSL
202
+ let certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
189
203
if ( ! fs . existsSync ( certsDir ) ) {
190
- fs . mkdirSync ( certsDir )
204
+ fs . mkdirSync ( certsDir , { recursive : true } )
191
205
}
192
206
193
207
// cert.pem location is hard-coded by OpenSSL msvc builds
194
- const cert = 'C:\\Program Files\\Common Files\\SSL\\cert.pem'
208
+ let cert = 'C:\\Program Files\\Common Files\\SSL\\cert.pem'
195
209
if ( ! fs . existsSync ( cert ) ) {
196
210
fs . copyFileSync ( certFile , cert )
197
211
}
198
212
213
+ // vcpkg openssl uses packages\openssl_x64-windows\certs
214
+ certsDir = `${ vcPkgBasePath } \\packages\\openssl_x64-windows\\certs`
215
+ if ( ! fs . existsSync ( certsDir ) ) {
216
+ fs . mkdirSync ( certsDir , { recursive : true } )
217
+ }
218
+
219
+ // vcpkg openssl uses packages\openssl_x64-windows\cert.pem
220
+ cert = `${ vcPkgBasePath } \\packages\\openssl_x64-windows\\cert.pem`
221
+ fs . copyFileSync ( certFile , cert )
222
+
199
223
return await common . measure ( 'Setting up MSVC environment' , async ( ) => addVCVARSEnv ( ) )
200
224
}
201
225
0 commit comments