Skip to content

Commit 2647067

Browse files
committed
Small cleanups
1 parent fb94cfb commit 2647067

File tree

3 files changed

+54
-60
lines changed

3 files changed

+54
-60
lines changed

common.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function rubyIsUCRT(path) {
163163
}
164164

165165
export function setupPath(newPathEntries) {
166-
let win_build_sys = null
166+
let msys2Type = null
167167
const envPath = windows ? 'Path' : 'PATH'
168168
const originalPath = process.env[envPath].split(path.delimiter)
169169
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
@@ -185,10 +185,10 @@ export function setupPath(newPathEntries) {
185185
let newPath
186186
if (windows) {
187187
// main Ruby dll determines whether mingw or ucrt build
188-
win_build_sys = rubyIsUCRT(newPathEntries[0]) ? 'ucrt64' : 'mingw64'
188+
msys2Type = rubyIsUCRT(newPathEntries[0]) ? 'ucrt64' : 'mingw64'
189189

190190
// add MSYS2 in path for all Rubies on Windows, as it provides a better bash shell and a native toolchain
191-
const msys2 = [`C:\\msys64\\${win_build_sys}\\bin`, 'C:\\msys64\\usr\\bin']
191+
const msys2 = [`C:\\msys64\\${msys2Type}\\bin`, 'C:\\msys64\\usr\\bin']
192192
newPath = [...newPathEntries, ...msys2]
193193
} else {
194194
newPath = newPathEntries
@@ -200,5 +200,5 @@ export function setupPath(newPathEntries) {
200200
core.endGroup()
201201

202202
core.addPath(newPath.join(path.delimiter))
203-
return win_build_sys
203+
return msys2Type
204204
}

dist/index.js

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

windows.js

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ const msys2BasePath = 'C:\\msys64'
1818
// needed for 2.0-2.3, and mswin, cert file used by Git for Windows
1919
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
2020

21-
// location & path for old RubyInstaller DevKit (MSYS), Ruby 2.0-2.3
22-
const msys = `${drive}:\\DevKit64`
23-
const msysPathEntries = [`${msys}\\mingw\\x86_64-w64-mingw32\\bin`, `${msys}\\mingw\\bin`, `${msys}\\bin`]
21+
// location & path for old RubyInstaller DevKit (MSYS1), Ruby 2.0-2.3
22+
const msys1 = `${drive}:\\DevKit64`
23+
const msysPathEntries = [`${msys1}\\mingw\\x86_64-w64-mingw32\\bin`, `${msys1}\\mingw\\bin`, `${msys1}\\bin`]
2424

2525
const virtualEnv = common.getVirtualEnvironmentName()
2626

@@ -62,7 +62,7 @@ export async function install(platform, engine, version) {
6262
await downloadAndExtract(engine, version, url, base, rubyPrefix);
6363
}
6464

65-
const winMSYS2Type = common.setupPath([`${rubyPrefix}\\bin`, ...toolchainPaths])
65+
const msys2Type = common.setupPath([`${rubyPrefix}\\bin`, ...toolchainPaths])
6666

6767
// install msys2 tools for all Ruby versions, only install mingw or ucrt for Rubies >= 2.4
6868

@@ -72,9 +72,8 @@ export async function install(platform, engine, version) {
7272

7373
// windows 2016 and 2019 need ucrt64 installed, 2022 and future images need
7474
// ucrt64 or mingw64 installed, depending on Ruby version
75-
if (((winMSYS2Type === 'ucrt64') || !hasMSYS2PreInstalled) &&
76-
(common.floatVersion(version) >= 2.4)) {
77-
await installGCCTools(winMSYS2Type)
75+
if (((msys2Type === 'ucrt64') || !hasMSYS2PreInstalled) && common.floatVersion(version) >= 2.4) {
76+
await installGCCTools(msys2Type)
7877
}
7978

8079
const ridk = `${rubyPrefix}\\bin\\ridk.cmd`
@@ -148,28 +147,29 @@ async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
148147
async function setupMingw(version) {
149148
core.exportVariable('MAKE', 'make.exe')
150149

151-
// rename these to avoid confusion when Ruby is using OpenSSL 1.0.2
152-
// most current extconf files look for 1.1.x dll files first, which is the
153-
// version of the renamed files
154-
if (common.floatVersion(version) <= 2.4) { renameSystem32Dlls() }
150+
// rename these to avoid confusion when Ruby is using OpenSSL 1.0.2.
151+
// most current extconf files look for 1.1.x dll files first, which is the version of the renamed files
152+
if (common.floatVersion(version) <= 2.4) {
153+
renameSystem32Dlls()
154+
}
155155

156156
if (common.floatVersion(version) <= 2.3) {
157157
core.exportVariable('SSL_CERT_FILE', certFile)
158-
await common.measure('Installing MSYS', async () => installMSYS(version))
158+
await common.measure('Installing MSYS1', async () => installMSYS1(version))
159159
return msysPathEntries
160160
} else {
161161
return []
162162
}
163163
}
164164

165-
// Ruby 2.0, 2.1, 2.2 and 2.3
166-
async function installMSYS(version) {
165+
// Ruby 2.0-2.3
166+
async function installMSYS1(version) {
167167
const url = 'https://github.com/oneclick/rubyinstaller/releases/download/devkit-4.7.2/DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe'
168168
const downloadPath = await tc.downloadTool(url)
169-
await exec.exec('7z', ['x', downloadPath, `-o${msys}`], { silent: true })
169+
await exec.exec('7z', ['x', downloadPath, `-o${msys1}`], { silent: true })
170170

171171
// below are set in the old devkit.rb file ?
172-
core.exportVariable('RI_DEVKIT', msys)
172+
core.exportVariable('RI_DEVKIT', msys1)
173173
core.exportVariable('CC' , 'gcc')
174174
core.exportVariable('CXX', 'g++')
175175
core.exportVariable('CPP', 'cpp')
@@ -238,27 +238,24 @@ export function addVCVARSEnv() {
238238
return newPathEntries
239239
}
240240

241-
// ssl files cause issues with non RI2 Rubies (<2.4) and ruby/ruby's CI from
242-
// build folder due to dll resolution
241+
// ssl files cause issues with non RI2 Rubies (<2.4) and ruby/ruby's CI from build folder due to dll resolution
243242
function renameSystem32Dlls() {
244243
const sys32 = 'C:\\Windows\\System32\\'
245-
const badFiles = ['libcrypto-1_1-x64.dll', 'libssl-1_1-x64.dll']
246-
badFiles.forEach( (bad) => {
247-
let fn = `${sys32}${bad}`
248-
if (fs.existsSync(fn)) { fs.renameSync(fn, `${fn}_`) }
249-
})
244+
const badFiles = [`${sys32}libcrypto-1_1-x64.dll`, `${sys32}libssl-1_1-x64.dll`]
245+
const existing = badFiles.map((dll) => fs.existsSync(dll))
246+
console.log(`Renaming ${existing.join(' and ')} to avoid dll resolution conflicts on Ruby <= 2.4`)
247+
existing.forEach(dll => fs.renameSync(dll, `${dll}_`))
250248
}
251249

252250
// Sets MSYS2 ENV variables set from running `ridk enable`
253-
//
254251
function addRidkEnv(ridk) {
255252
let newEnv = new Map()
256253
let cmd = `cmd.exe /c "${ridk} enable && set"`
257254
let newSet = cp.execSync(cmd).toString().trim().split(/\r?\n/)
258255
newSet = newSet.filter(line => /^\S+=\S+/.test(line))
259256
newSet.forEach(s => {
260-
let [k,v] = common.partition(s, '=')
261-
newEnv.set(k,v)
257+
let [k, v] = common.partition(s, '=')
258+
newEnv.set(k, v)
262259
})
263260

264261
for (let [k, v] of newEnv) {

0 commit comments

Comments
 (0)