From 2f401b9c7b028c3cfce228f507f73f076a766bb1 Mon Sep 17 00:00:00 2001 From: Takuro Ashie Date: Wed, 8 Jun 2022 15:47:06 +0900 Subject: [PATCH 1/2] Support Ruby 3.1 UCRT binary RubyInstaller has migrate from msvcrt.dll to ucrt.dll: https://rubyinstaller.org/2021/12/31/rubyinstaller-3.1.0-1-released.html So that symbols should be loaded from later one. Althouth I considered introducing a new constant like `UCRT_DLL`, this commit still using `MSVCRT_DLL` even if Ruby is run on ucrt.dll to keep backward compatibility. I think replacing `MSVCRT_DLL` with `UCRT_DLL` is almost meaningless, they won't used at same time. Signed-off-by: Takuro Ashie --- .github/workflows/unit-test.yml | 2 +- appveyor.yml | 2 ++ lib/windows/api.rb | 4 +++- test/test_windows_api.rb | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 6174fa9..ba46dcb 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [ '2.5', '2.6', '2.7', '3.0' ] + ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1' ] os: - windows-latest experimental: [false] diff --git a/appveyor.yml b/appveyor.yml index a956c55..0e1fdca 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,6 +14,8 @@ test_script: environment: matrix: + - ruby_version: "31-x64" + - ruby_version: "31" - ruby_version: "30-x64" - ruby_version: "30" - ruby_version: "27-x64" diff --git a/lib/windows/api.rb b/lib/windows/api.rb index 4fcb868..70295b0 100644 --- a/lib/windows/api.rb +++ b/lib/windows/api.rb @@ -8,7 +8,9 @@ module Windows # With Microsoft Visual C++ 8 and later users should use the associated # DLL instead of msvcrt directly, if possible. - if CONFIG['host_os'].split('_')[1] + if RUBY_PLATFORM.split('-')[-1] == "ucrt" + MSVCRT_DLL = 'ucrtbase' + elsif CONFIG['host_os'].split('_')[1] if CONFIG['host_os'].split('_')[1].to_i >= 80 MSVCRT_DLL = 'msvcr' + CONFIG['host_os'].split('_')[1] else diff --git a/test/test_windows_api.rb b/test/test_windows_api.rb index 7e6045f..c15aa66 100644 --- a/test/test_windows_api.rb +++ b/test/test_windows_api.rb @@ -53,7 +53,7 @@ class TC_Windows_API < Test::Unit::TestCase def setup @buf = 0.chr * 256 - @runtimes = ['msvcrt', 'msvcr80', 'msvcr90', 'msvcr100'] + @runtimes = ['msvcrt', 'msvcr80', 'msvcr90', 'msvcr100', 'ucrtbase'] end def test_version From 7dea4d91d94cfa70d848d883f35771b946b3f024 Mon Sep 17 00:00:00 2001 From: Takuro Ashie Date: Wed, 8 Jun 2022 17:43:55 +0900 Subject: [PATCH 2/2] AppVeyor: Try to run ridk exec only on Ruby 3.1 And drop Ruby 3.1 for x86, it's too hard to install current win32-api due to unexpected univeral binary. In addition, probably no one uses Ruby 3.1 for x86 recent days... Signed-off-by: Takuro Ashie --- appveyor.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 0e1fdca..f4d3ac8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,7 +15,6 @@ test_script: environment: matrix: - ruby_version: "31-x64" - - ruby_version: "31" - ruby_version: "30-x64" - ruby_version: "30" - ruby_version: "27-x64" @@ -34,3 +33,15 @@ environment: - ruby_version: "21" - ruby_version: "200-x64" - ruby_version: "200" + +for: +- + matrix: + only: + - ruby_version: "31-x64" + install: + - SET PATH=C:\Ruby%ruby_version%\bin;%PATH% + - ruby --version + - gem --version + - ridk install 1 3 + - ridk exec bundle install