Skip to content

Commit be54de8

Browse files
MSP-Gregeregon
authored andcommitted
Windows mswin - install vcpkg archive with required Ruby packages, cert
1 parent cd42417 commit be54de8

File tree

2 files changed

+68
-20
lines changed

2 files changed

+68
-20
lines changed

dist/index.js

Lines changed: 34 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

windows.js

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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
33

44
const fs = require('fs')
55
const path = require('path')
@@ -13,9 +13,11 @@ const rubyInstallerVersions = require('./windows-versions.json')
1313

1414
const drive = common.drive
1515

16-
const msys2BasePath = 'C:\\msys64'
1716
const msys2GCCReleaseURI = 'https://github.com/ruby/setup-msys2-gcc/releases/download'
1817

18+
const msys2BasePath = process.env['GHCUP_MSYS2']
19+
const vcPkgBasePath = process.env['VCPKG_INSTALLATION_ROOT']
20+
1921
// needed for Ruby 2.0-2.3, and mswin, cert file used by Git for Windows
2022
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
2123

@@ -81,6 +83,8 @@ export async function install(platform, engine, version) {
8183
await installGCCTools(msys2Type)
8284
}
8385

86+
if (version === 'mswin') { await installVCPkg() }
87+
8488
const ridk = `${rubyPrefix}\\bin\\ridk.cmd`
8589
if (fs.existsSync(ridk)) {
8690
await common.measure('Adding ridk env variables', async () => addRidkEnv(ridk))
@@ -99,7 +103,6 @@ async function installGCCTools(type) {
99103
})
100104

101105
await common.measure(`Extracting ${type} build tools`, async () =>
102-
// -aoa overwrite existing, -bd disable progress indicator
103106
exec.exec('7z', ['x', downloadPath, '-aoa', '-bd', `-o${msys2BasePath}`], { silent: true }))
104107
}
105108

@@ -117,7 +120,6 @@ async function installMSYS2Tools() {
117120
fs.rmSync(`${msys2BasePath}\\var\\lib\\pacman\\local`, { recursive: true, force: true })
118121

119122
await common.measure(`Extracting msys2 build tools`, async () =>
120-
// -aoa overwrite existing, -bd disable progress indicator
121123
exec.exec('7z', ['x', downloadPath, '-aoa', '-bd', `-o${msys2BasePath}`], { silent: true }))
122124
}
123125

@@ -128,6 +130,18 @@ export async function installJRubyTools() {
128130
await installGCCTools('mingw64')
129131
}
130132

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+
131145
async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
132146
const parentDir = path.dirname(rubyPrefix)
133147

@@ -137,7 +151,7 @@ async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
137151
})
138152

139153
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
141155
exec.exec('7z', ['x', downloadPath, '-bd', `-xr!${base}\\share\\doc`, `-o${parentDir}`], { silent: true }))
142156

143157
if (base !== path.basename(rubyPrefix)) {
@@ -184,18 +198,28 @@ async function installMSYS1(version) {
184198
async function setupMSWin() {
185199
core.exportVariable('MAKE', 'nmake.exe')
186200

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'
189203
if (!fs.existsSync(certsDir)) {
190-
fs.mkdirSync(certsDir)
204+
fs.mkdirSync(certsDir, { recursive: true })
191205
}
192206

193207
// 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'
195209
if (!fs.existsSync(cert)) {
196210
fs.copyFileSync(certFile, cert)
197211
}
198212

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+
199223
return await common.measure('Setting up MSVC environment', async () => addVCVARSEnv())
200224
}
201225

0 commit comments

Comments
 (0)