Skip to content

Commit aa47823

Browse files
authored
Add MSYS2 platform support (#16)
This PR adds support for the MSYS2 environment on Windows, porting the functionality from the deprecated native-package-installer gem. Note that this isn't for Ruby installed by RubyInstaller. Ruby installed by RubyInstaller must use `msys2_mingw_dependencies` gemspec metadata instead of this. Supported MSYS2 platforms: - CLANG64 - CLANGARM64 - MINGW32 - MINGW64 - UCRT64
1 parent 0d1e456 commit aa47823

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed

.github/workflows/test.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,47 @@ jobs:
9292
cd test/fixture/dummy-cairo
9393
gem build *.gemspec
9494
gem install ./*.gem
95+
96+
windows-msys2:
97+
name: Windows ${{ matrix.msystem }}
98+
runs-on: ${{ matrix.runner }}
99+
timeout-minutes: 10
100+
strategy:
101+
fail-fast: false
102+
matrix:
103+
include:
104+
- msystem: CLANG64
105+
package-prefix: mingw-w64-clang-x86_64
106+
runner: windows-latest
107+
- msystem: CLANGARM64
108+
package-prefix: mingw-w64-clang-aarch64
109+
runner: windows-11-arm
110+
- msystem: MINGW32
111+
package-prefix: mingw-w64-i686
112+
runner: windows-latest
113+
- msystem: MINGW64
114+
package-prefix: mingw-w64-x86_64
115+
runner: windows-latest
116+
- msystem: UCRT64
117+
package-prefix: mingw-w64-ucrt-x86_64
118+
runner: windows-latest
119+
steps:
120+
- uses: actions/checkout@v6
121+
- uses: msys2/setup-msys2@v2
122+
with:
123+
msystem: ${{ matrix.msystem }}
124+
update: true
125+
install: >-
126+
base-devel
127+
${{ matrix.package-prefix }}-ruby
128+
${{ matrix.package-prefix }}-toolchain
129+
- name: Install
130+
shell: msys2 {0}
131+
run: |
132+
rake install
133+
- name: Install dummy-cairo gem
134+
shell: msys2 {0}
135+
run: |
136+
cd test/fixture/dummy-cairo
137+
gem build *.gemspec
138+
gem install ./*.gem

lib/rubygems-requirements-system/platform.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def detect(ui)
6262
require_relative "platform/alpine-linux"
6363

6464

65+
# Windows
66+
require_relative "platform/msys2"
67+
68+
6569
# Platform independent
6670
require_relative "platform/homebrew"
6771
require_relative "platform/conda"
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright (C) 2025 Ruby-GNOME Project Team
2+
#
3+
# This program is free software: you can redistribute it and/or modify
4+
# it under the terms of the GNU Lesser General Public License as published by
5+
# the Free Software Foundation, either version 3 of the License, or
6+
# (at your option) any later version.
7+
#
8+
# This program is distributed in the hope that it will be useful,
9+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
# GNU Lesser General Public License for more details.
12+
#
13+
# You should have received a copy of the GNU Lesser General Public License
14+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
16+
require_relative "base"
17+
18+
module RubyGemsRequirementsSystem
19+
module Platform
20+
class MSYS2 < Base
21+
Platform.register(self)
22+
23+
class << self
24+
def current_platform?
25+
return false if Object.const_defined?(:RubyInstaller)
26+
return false if package_prefix.nil?
27+
ExecutableFinder.exist?("pacman")
28+
end
29+
30+
def package_prefix
31+
ENV["MINGW_PACKAGE_PREFIX"]
32+
end
33+
end
34+
35+
def target?(platform)
36+
platform == "msys2"
37+
end
38+
39+
private
40+
def install_command_line(package)
41+
[
42+
"pacman",
43+
"-S",
44+
"--noconfirm",
45+
"#{self.class.package_prefix}-#{package}"
46+
]
47+
end
48+
49+
def need_super_user_priviledge?
50+
false
51+
end
52+
end
53+
end
54+
end

test/fixture/dummy-cairo/dummy-cairo.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Gem::Specification.new do |spec|
5252
spec.requirements << "system: cairo >= 1.2.0: gentoo_linux: x11-libs/cairo"
5353
spec.requirements << "system: cairo >= 1.2.0: homebrew: cairo"
5454
spec.requirements << "system: cairo >= 1.2.0: macports: cairo"
55+
spec.requirements << "system: cairo >= 1.2.0: msys2: cairo"
5556
spec.requirements << "system: cairo >= 1.2.0: pld_linux: cairo-devel"
5657
spec.requirements << "system: cairo >= 1.2.0: suse: cairo-devel"
5758
end

0 commit comments

Comments
 (0)