Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows MSYS2 ucrt support #194

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion common.js
Expand Up @@ -149,6 +149,13 @@ export function win2nix(path) {
return path.replace(/\\/g, '/').replace(/ /g, '\\ ')
}

// JRuby is installed after setupPath is called, so folder doesn't exist
function rubyIsUCRT(path) {
return !!(fs.existsSync(path) &&
fs.readdirSync(path, { withFileTypes: true }).find(dirent =>
dirent.isFile() && dirent.name.match(/^x64-ucrt-ruby\d{3}\.dll$/)))
}
eregon marked this conversation as resolved.
Show resolved Hide resolved

export function setupPath(newPathEntries) {
const envPath = windows ? 'Path' : 'PATH'
const originalPath = process.env[envPath].split(path.delimiter)
Expand All @@ -170,8 +177,11 @@ export function setupPath(newPathEntries) {
// Then add new path entries using core.addPath()
let newPath
if (windows) {
// main Ruby dll determines whether mingw or ucrt build
let build_sys = rubyIsUCRT(newPathEntries[0]) ? 'ucrt64' : 'mingw64'

// add MSYS2 in path for all Rubies on Windows, as it provides a better bash shell and a native toolchain
const msys2 = ['C:\\msys64\\mingw64\\bin', 'C:\\msys64\\usr\\bin']
const msys2 = [`C:\\msys64\\${build_sys}\\bin`, 'C:\\msys64\\usr\\bin']
newPath = [...newPathEntries, ...msys2]
} else {
newPath = newPathEntries
Expand Down
16 changes: 13 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions windows.js
Expand Up @@ -50,12 +50,12 @@ export async function install(platform, engine, version) {

let toolchainPaths = (version === 'mswin') ? await setupMSWin() : await setupMingw(version)

common.setupPath([`${rubyPrefix}\\bin`, ...toolchainPaths])

if (!inToolCache) {
await downloadAndExtract(engine, version, url, base, rubyPrefix);
}

common.setupPath([`${rubyPrefix}\\bin`, ...toolchainPaths])

return rubyPrefix
}

Expand Down