Skip to content

Commit 2f55240

Browse files
ntkmeeregon
authored andcommitted
Apply review feedbacks
1 parent a871308 commit 2f55240

File tree

3 files changed

+41
-18
lines changed

3 files changed

+41
-18
lines changed

dist/index.js

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

generate-windows-versions.rb

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
min_requirements = ['~> 2.0.0', '~> 2.1.9', '>= 2.2.6'].map { |req| Gem::Requirement.new(req) }
66

77
url = 'https://raw.githubusercontent.com/oneclick/rubyinstaller.org-website/master/_data/downloads.yaml'
8-
entries = YAML.load(URI.open(url) { |f| f.read }, symbolize_names: true)
8+
entries = YAML.load(URI.open(url, &:read), symbolize_names: true)
99

1010
versions = entries.select { |entry|
1111
entry[:filetype] == 'rubyinstaller7z' and
@@ -51,31 +51,32 @@
5151
File.binwrite 'windows-versions.json', "#{JSON.pretty_generate(versions)}\n"
5252

5353
base_url = 'https://github.com/ntkme/setup-msys2-gcc/releases/latest/download/windows-toolchain.json'
54-
windows_toolchain = JSON.parse(URI.open(base_url) { |f| f.read }, symbolize_names: true)
54+
windows_toolchain = JSON.parse(URI.open(base_url, &:read), symbolize_names: true)
5555

5656
versions.each do |raw_version, archs|
5757
version = Gem::Version.correct?(raw_version) ? Gem::Version.new(raw_version) : head_version
5858

5959
archs.each_key do |raw_arch|
6060
arch = raw_arch == 'arm64' ? 'aarch64' : raw_arch
6161

62-
platform = case raw_version
63-
when 'head', 'ucrt'
64-
"#{arch}-mingw-ucrt"
65-
when 'mingw'
66-
"#{arch}-mingw32"
67-
when 'mswin'
68-
"#{arch}-mswin64"
69-
else
70-
if version >= Gem::Version.new('3.1.0.dev')
71-
"#{arch}-mingw-ucrt"
72-
else
73-
"#{arch}-mingw32"
74-
end
75-
end
62+
platform =
63+
case raw_version
64+
when 'head', 'ucrt'
65+
"#{arch}-mingw-ucrt"
66+
when 'mingw'
67+
"#{arch}-mingw32"
68+
when 'mswin'
69+
"#{arch}-mswin64"
70+
else
71+
if version >= Gem::Version.new('3.1.0.dev')
72+
"#{arch}-mingw-ucrt"
73+
else
74+
"#{arch}-mingw32"
75+
end
76+
end
7677

77-
toolchain = windows_toolchain
78-
.select do |pkg|
78+
toolchain =
79+
windows_toolchain.select do |pkg|
7980
pkg[:platform] == platform && pkg[:required_ruby_version].any? do |requirement|
8081
Gem::Requirement.new(requirement).satisfied_by?(version)
8182
end

windows.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ async function installMSYS2(url, rubyPrefix = process.env.RUNNER_TEMP) {
120120
await common.measure('Extracting msys2 build tools', async () =>
121121
exec.exec('7z', ['x', downloadPath, '-aoa', '-bd', `-o${extractPath}`], { silent: true }))
122122

123+
// https://github.com/oneclick/rubyinstaller2/blob/HEAD/lib/ruby_installer/build/msys2_installation.rb
124+
//
125+
// ri2 searches for msys64 in the following order:
126+
// - ENV["MSYS2_PATH"]
127+
// - File.join(RbConfig::TOPDIR, "msys64")
128+
// - File.join(File.dirname(RbConfig::TOPDIR), "msys64")
129+
// - "C:\msys64"
130+
// - ...
131+
//
132+
// The first option ENV["MSYS2_PATH"] is only supported in ruby >=3.0.7.
133+
// Therefore we use the second option to avoid conflict with existing "C:\msys64"
123134
const msys2Path = path.join(rubyPrefix, 'msys64')
124135
if (extractPath !== msys2Path) {
125136
fs.symlinkSync(extractPath, msys2Path, 'junction')

0 commit comments

Comments
 (0)