Skip to content

Rewrite ruby/setup-msys2-gcc #762

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:
echo 'ridk is unavailable'
}
} elseif ($plat.Contains('mswin')) {
&"$env:VCPKG_INSTALLATION_ROOT\vcpkg" list
Get-ChildItem "$env:VCPKG_INSTALLATION_ROOT\installed\vcpkg\info"
}
- name: RbConfig::CONFIG
run: ruby -rrbconfig -rpp -e 'pp RbConfig::CONFIG'
Expand Down
32 changes: 4 additions & 28 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const linuxOSInfo = require('linux-os-info')

export const windows = (os.platform() === 'win32')
// Extract to SSD on Windows, see https://github.com/ruby/setup-ruby/pull/14
export const drive = (windows ? (process.env['GITHUB_WORKSPACE'] || 'C')[0] : undefined)
export const drive = (windows ? (process.env['RUNNER_TEMP'] || 'C')[0] : undefined)

export const inputs = {
selfHosted: undefined
Expand Down Expand Up @@ -334,7 +334,7 @@ function engineToToolCacheName(engine) {
}[engine]
}

export function getToolCacheRubyPrefix(platform, engine, version) {
export function getToolCacheRubyPrefix(_platform, engine, version) {
const toolCache = getToolCachePath()
return path.join(toolCache, engineToToolCacheName(engine), version, os.arch())
}
Expand All @@ -356,15 +356,7 @@ 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|vcruntime\d{3})-ruby\d{3}\.dll$/)))
}

export function setupPath(newPathEntries) {
let msys2Type = null
const envPath = windows ? 'Path' : 'PATH'
const originalPath = process.env[envPath].split(path.delimiter)
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
Expand All @@ -382,29 +374,13 @@ export function setupPath(newPathEntries) {
core.exportVariable(envPath, cleanPath.join(path.delimiter))
}

// Then add new path entries using core.addPath()
let newPath
const windowsToolchain = core.getInput('windows-toolchain')
if (windows && windowsToolchain !== 'none') {
// main Ruby dll determines whether mingw or ucrt build
msys2Type = os.arch() === 'arm64'
? 'clangarm64'
: 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\\${msys2Type}\\bin`, 'C:\\msys64\\usr\\bin']
newPath = [...newPathEntries, ...msys2]
} else {
newPath = newPathEntries
}
console.log(`Entries added to ${envPath} to use selected Ruby:`)
for (const entry of newPath) {
for (const entry of newPathEntries) {
console.log(` ${entry}`)
}
core.endGroup()

core.addPath(newPath.join(path.delimiter))
return msys2Type
core.addPath(newPathEntries.join(path.delimiter))
}

export async function setupJavaHome(rubyPrefix) {
Expand Down
Loading
Loading