Skip to content

Commit 5580575

Browse files
MSP-Gregeregon
authored andcommitted
Add windows-toolchain input
1 parent 432702e commit 5580575

File tree

6 files changed

+43
-6
lines changed

6 files changed

+43
-6
lines changed

.github/workflows/test.yml

+13
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,19 @@ jobs:
335335
bundler-cache: true
336336
- run: bundle list | grep nokogiri
337337

338+
testWindowsToolchain:
339+
name: "Test windows-toolchain: none"
340+
runs-on: windows-latest
341+
steps:
342+
- uses: actions/checkout@v4
343+
- uses: ./
344+
with:
345+
ruby-version: '2.7'
346+
windows-toolchain: none
347+
bundler: none
348+
- name: C:/msys64/mingw64/bin/gcc.exe not installed
349+
run: ruby -e "abort if File.exist?('C:/msys64/mingw64/bin/gcc.exe')"
350+
338351
lint:
339352
runs-on: ubuntu-20.04
340353
steps:

action.yml

+10
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ inputs:
3636
Consider the runner as a self-hosted runner, which means not using prebuilt Ruby binaries which only work
3737
on GitHub-hosted runners or self-hosted runners with a very similar image to the ones used by GitHub runners.
3838
The default is to detect this automatically based on the OS, OS version and architecture.
39+
windows-toolchain:
40+
description: |
41+
This input allows to override the default toolchain setup on Windows.
42+
The default setting ('default') installs a toolchain based on the selected Ruby.
43+
Specifically, it installs MSYS2 if not already there and installs mingw/ucrt/mswin build tools and packages.
44+
It also sets environment variables using 'ridk' or 'vcvars64.bat' based on the selected Ruby.
45+
At present, the only other setting than 'default' is 'none', which only adds Ruby to PATH.
46+
No build tools or packages are installed, nor are any ENV setting changed to activate them.
47+
default: 'default'
48+
3949
outputs:
4050
ruby-prefix:
4151
description: 'The prefix of the installed ruby'

common.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ export function setupPath(newPathEntries) {
341341

342342
// Then add new path entries using core.addPath()
343343
let newPath
344-
if (windows) {
344+
const windowsToolchain = core.getInput('windows-toolchain')
345+
if (windows && windowsToolchain !== 'none') {
345346
// main Ruby dll determines whether mingw or ucrt build
346347
msys2Type = rubyIsUCRT(newPathEntries[0]) ? 'ucrt64' : 'mingw64'
347348

dist/index.js

+10-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const inputDefaults = {
1717
'working-directory': '.',
1818
'cache-version': bundler.DEFAULT_CACHE_VERSION,
1919
'self-hosted': 'false',
20+
'windows-toolchain': 'default',
2021
}
2122

2223
// entry point when this action is run on its own

windows.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,17 @@ export async function install(platform, engine, version) {
6565
rubyPrefix = `${drive}:\\${base}`
6666
}
6767

68-
let toolchainPaths = (version === 'mswin') ? await setupMSWin() : await setupMingw(version)
69-
7068
if (!inToolCache) {
7169
await downloadAndExtract(engine, version, url, base, rubyPrefix);
7270
}
7371

72+
const windowsToolchain = core.getInput('windows-toolchain')
73+
if (windowsToolchain === 'none') {
74+
common.setupPath([`${rubyPrefix}\\bin`])
75+
return rubyPrefix
76+
}
77+
78+
let toolchainPaths = (version === 'mswin') ? await setupMSWin() : await setupMingw(version)
7479
const msys2Type = common.setupPath([`${rubyPrefix}\\bin`, ...toolchainPaths])
7580

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

0 commit comments

Comments
 (0)