Skip to content

Commit 37d2b64

Browse files
committed
Rewrite ruby/setup-msys2-gcc
1 parent eaecf78 commit 37d2b64

File tree

4 files changed

+132
-222
lines changed

4 files changed

+132
-222
lines changed

common.js

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,7 @@ export function win2nix(path) {
356356
return path.replace(/\\/g, '/').replace(/ /g, '\\ ')
357357
}
358358

359-
// JRuby is installed after setupPath is called, so folder doesn't exist
360-
function rubyIsUCRT(path) {
361-
return !!(fs.existsSync(path) &&
362-
fs.readdirSync(path, { withFileTypes: true }).find(dirent =>
363-
dirent.isFile() && dirent.name.match(/^x64-(ucrt|vcruntime\d{3})-ruby\d{3}\.dll$/)))
364-
}
365-
366359
export function setupPath(newPathEntries) {
367-
let msys2Type = null
368360
const envPath = windows ? 'Path' : 'PATH'
369361
const originalPath = process.env[envPath].split(path.delimiter)
370362
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
@@ -382,29 +374,13 @@ export function setupPath(newPathEntries) {
382374
core.exportVariable(envPath, cleanPath.join(path.delimiter))
383375
}
384376

385-
// Then add new path entries using core.addPath()
386-
let newPath
387-
const windowsToolchain = core.getInput('windows-toolchain')
388-
if (windows && windowsToolchain !== 'none') {
389-
// main Ruby dll determines whether mingw or ucrt build
390-
msys2Type = os.arch() === 'arm64'
391-
? 'clangarm64'
392-
: rubyIsUCRT(newPathEntries[0]) ? 'ucrt64' : 'mingw64'
393-
394-
// add MSYS2 in path for all Rubies on Windows, as it provides a better bash shell and a native toolchain
395-
const msys2 = [`C:\\msys64\\${msys2Type}\\bin`, 'C:\\msys64\\usr\\bin']
396-
newPath = [...newPathEntries, ...msys2]
397-
} else {
398-
newPath = newPathEntries
399-
}
400377
console.log(`Entries added to ${envPath} to use selected Ruby:`)
401-
for (const entry of newPath) {
378+
for (const entry of newPathEntries) {
402379
console.log(` ${entry}`)
403380
}
404381
core.endGroup()
405382

406-
core.addPath(newPath.join(path.delimiter))
407-
return msys2Type
383+
core.addPath(newPathEntries.join(path.delimiter))
408384
}
409385

410386
export async function setupJavaHome(rubyPrefix) {

dist/index.js

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

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ export async function setupRuby(options = {}) {
7272

7373
// JRuby can use compiled extension code, so make sure gcc exists.
7474
// As of Jan-2022, JRuby compiles against msvcrt.
75-
if (platform.startsWith('windows') && engine === 'jruby' &&
76-
!fs.existsSync('C:\\msys64\\mingw64\\bin\\gcc.exe')) {
75+
if (platform.startsWith('windows') && engine === 'jruby') {
7776
await require('./windows').installJRubyTools()
7877
}
7978

0 commit comments

Comments
 (0)