From b96416802d24ffe80ef844b6a347919d5b858820 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 17 Jan 2025 20:18:11 +0900 Subject: [PATCH 1/9] [ruby/rubygems] Do not pollute source directory by tests https://github.com/ruby/rubygems/commit/ab3c2200d2 --- spec/bundler/support/path.rb | 2 +- spec/bundler/support/rubygems_ext.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb index 0a534dd40e44eb..1c49def88df292 100644 --- a/spec/bundler/support/path.rb +++ b/spec/bundler/support/path.rb @@ -114,7 +114,7 @@ def tmp(*path) end def tmp_root - source_root.join("tmp") + ruby_core? && (tmpdir = ENV["TMPDIR"]) ? Pathname(tmpdir) : source_root.join("tmp") end # Bump this version whenever you make a breaking change to the spec setup diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb index 2d681529aac2ef..997a70747d2093 100644 --- a/spec/bundler/support/rubygems_ext.rb +++ b/spec/bundler/support/rubygems_ext.rb @@ -43,7 +43,7 @@ def test_setup # sign extension bundles on macOS, to avoid trying to find the specified key # from the fake $HOME/Library/Keychains directory. ENV.delete "RUBY_CODESIGN" - ENV["TMPDIR"] = Path.tmpdir.to_s + ENV["TMPDIR"] = Path.tmpdir.to_s unless ruby_core? require "rubygems/user_interaction" Gem::DefaultUserInteraction.ui = Gem::SilentUI.new From 016b2628e86fdd611782faf8ffd8e7f7c04a7650 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 26 Jan 2026 15:27:37 +0900 Subject: [PATCH 2/9] [ruby/rubygems] Fixed missing classname https://github.com/ruby/rubygems/commit/b2002d47d2 --- spec/bundler/support/rubygems_ext.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb index 997a70747d2093..f168c7048701b9 100644 --- a/spec/bundler/support/rubygems_ext.rb +++ b/spec/bundler/support/rubygems_ext.rb @@ -43,7 +43,7 @@ def test_setup # sign extension bundles on macOS, to avoid trying to find the specified key # from the fake $HOME/Library/Keychains directory. ENV.delete "RUBY_CODESIGN" - ENV["TMPDIR"] = Path.tmpdir.to_s unless ruby_core? + ENV["TMPDIR"] = Path.tmpdir.to_s unless Path.ruby_core? require "rubygems/user_interaction" Gem::DefaultUserInteraction.ui = Gem::SilentUI.new From 6e00da098abacd8c9ef0ea621cb1832e654b1813 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 26 Jan 2026 16:19:19 +0900 Subject: [PATCH 3/9] [ruby/rubygems] Revert "Merge pull request #8989 from nobu/test-tmpdir" This reverts commit https://github.com/ruby/rubygems/commit/3aa3ee3ee440, reversing changes made to https://github.com/ruby/rubygems/commit/d1ff3df70f55. https://github.com/ruby/rubygems/commit/0231b5b1bc --- spec/bundler/support/path.rb | 2 +- spec/bundler/support/rubygems_ext.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/bundler/support/path.rb b/spec/bundler/support/path.rb index 1c49def88df292..0a534dd40e44eb 100644 --- a/spec/bundler/support/path.rb +++ b/spec/bundler/support/path.rb @@ -114,7 +114,7 @@ def tmp(*path) end def tmp_root - ruby_core? && (tmpdir = ENV["TMPDIR"]) ? Pathname(tmpdir) : source_root.join("tmp") + source_root.join("tmp") end # Bump this version whenever you make a breaking change to the spec setup diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb index f168c7048701b9..2d681529aac2ef 100644 --- a/spec/bundler/support/rubygems_ext.rb +++ b/spec/bundler/support/rubygems_ext.rb @@ -43,7 +43,7 @@ def test_setup # sign extension bundles on macOS, to avoid trying to find the specified key # from the fake $HOME/Library/Keychains directory. ENV.delete "RUBY_CODESIGN" - ENV["TMPDIR"] = Path.tmpdir.to_s unless Path.ruby_core? + ENV["TMPDIR"] = Path.tmpdir.to_s require "rubygems/user_interaction" Gem::DefaultUserInteraction.ui = Gem::SilentUI.new From b3cca1e201238def12f57a9ad21da8ef65ad3563 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 26 Jan 2026 17:15:49 +0900 Subject: [PATCH 4/9] [ruby/rubygems] Re-generate certificates with sha256WithRSAEncryption for modern OS https://github.com/ruby/rubygems/commit/41612df71d --- spec/bundler/support/builders.rb | 82 ++++++++++++++++---------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/spec/bundler/support/builders.rb b/spec/bundler/support/builders.rb index 6087ea8cc8c652..a58b575b63b38a 100644 --- a/spec/bundler/support/builders.rb +++ b/spec/bundler/support/builders.rb @@ -695,54 +695,54 @@ def _default_files TEST_CERT = <<~CERT -----BEGIN CERTIFICATE----- - MIIDMjCCAhqgAwIBAgIBATANBgkqhkiG9w0BAQUFADAnMQwwCgYDVQQDDAN5b3Ux + MIIDNTCCAh2gAwIBAgIBATANBgkqhkiG9w0BAQsFADAnMQwwCgYDVQQDDAN5b3Ux FzAVBgoJkiaJk/IsZAEZFgdleGFtcGxlMB4XDTE1MDIwODAwMTIyM1oXDTQyMDYy NTAwMTIyM1owJzEMMAoGA1UEAwwDeW91MRcwFQYKCZImiZPyLGQBGRYHZXhhbXBs - ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANlvFdpN43c4DMS9Jo06 - m0a7k3bQ3HWQ1yrYhZMi77F1F73NpBknYHIzDktQpGn6hs/4QFJT4m4zNEBF47UL - jHU5nTK5rjkS3niGYUjvh3ZEzVeo9zHUlD/UwflDo4ALl3TSo2KY/KdPS/UTdLXL - ajkQvaVJtEDgBPE3DPhlj5whp+Ik3mDHej7qpV6F502leAwYaFyOtlEG/ZGNG+nZ - L0clH0j77HpP42AylHDi+vakEM3xcjo9BeWQ6Vkboic93c9RTt6CWBWxMQP7Nol1 - MOebz9XOSQclxpxWteXNfPRtMdAhmRl76SMI8ywzThNPpa4EH/yz34ftebVOgKyM - nd0CAwEAAaNpMGcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFA7D - n9qo0np23qi3aOYuAAPn/5IdMBYGA1UdEQQPMA2BC3lvdUBleGFtcGxlMBYGA1Ud - EgQPMA2BC3lvdUBleGFtcGxlMA0GCSqGSIb3DQEBBQUAA4IBAQA7Gyk62sWOUX/N - vk4tJrgKESph6Ns8+E36A7n3jt8zCep8ldzMvwTWquf9iqhsC68FilEoaDnUlWw7 - d6oNuaFkv7zfrWGLlvqQJC+cu2X5EpcCksg5oRp8VNbwJysJ6JgwosxzROII8eXc - R+j1j6mDvQYqig2QOnzf480pjaqbP+tspfDFZbhKPrgM3Blrb3ZYuFpv4zkqI7aB - 6fuk2DUhNO1CuwrJA84TqC+jGo73bDKaT5hrIDiaJRrN5+zcWja2uEWrj5jSbep4 - oXdEdyH73hOHMBP40uds3PqnUsxEJhzjB2sCCe1geV24kw9J4m7EQXPVkUKDgKrt - LlpDmOoo + ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMkupYkg3Nd1oXM3fo0d + mVJBWNrni88lKDuIIQXwcKe6XCgiloZG708ecLTOws9+o9MkTl9Wtpf/WGXT98NK + EPUYakd2Fv1SuD1jWYlP7iDR6hB3RkWBm5ziujYftVJ4ZrPD42PLjDASvlh75Tvr + MeM7yq/qkcgNsd9dQyUvMNPks3tla9je7Dt7Auli2IN3CNXys7gIOfwJH0Bb/M6t + y7oUfpoUKAfLzwe61abztgDu1lSNgdFBM1kcxYflyh/FkX5TlAcWeAXzLrnxAXGR + UxXrxW4oPC+kZi/pDRBd7X4zQDx7bCmr1+FsS3M05i3w5E08Tt9iKRk4V8nCmE4i + k6UCAwEAAaNsMGowCQYDVR0TBAIwADAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0OBBYE + FOOOFw5TNAqt/TcRRZEU3Dg/58XuMBYGA1UdEQQPMA2BC3lvdUBleGFtcGxlMBYG + A1UdEgQPMA2BC3lvdUBleGFtcGxlMA0GCSqGSIb3DQEBCwUAA4IBAQAy3xnmobxU + 1SyhHvoIXTJmG0wt1DQ/Dqwjy362LpEf1UHt29wtg1Mph58eVtl93z5Vd2t4/O77 + E2BHpSu9ujc6/Br4+2uA/Qk/xRyLBtZAwty6J4uFvOOg985HonN+RCUZbKSUTmtA + TZvNtIDAZFQ8Tu75K4gIBxDcz7biGi4i1VJ3F3GNCNeossr9IQwKvb+UWFq14U5R + IzUnGgMIzcjUG2kKQvddRD1CjS+egtcLvShbOfm5bs4w4rfQ2FPF+Aaf9v7fxa/c + Jrf3K+cB19eAy7O4nlPG1xurvnZd0QpqRk++werrBuKe1Pgga7YBLePfJhzwqcZv + wVOSsB870yeO -----END CERTIFICATE----- CERT TEST_PKEY = <<~PKEY -----BEGIN RSA PRIVATE KEY----- - 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 -----END RSA PRIVATE KEY----- PKEY end From ace5b10de44acc7ce7717d4109beaeba9a130700 Mon Sep 17 00:00:00 2001 From: Edouard CHIN Date: Thu, 15 Jan 2026 17:09:35 +0100 Subject: [PATCH 5/9] [ruby/rubygems] Fix Bundler that re-exec $0 when a `version` is present in the config: - ### Problem If you have a `version` in your config file (this feature was introduced in #6817), then running any `bundle` command will make Bundler re-exec and ultimately run the `bundle` binstub twice. ### Details When the `bundle` binstub gets executed, a `require "bundler"` is evaluated. RubyGems tries to require the `bundler.rb` file from the right `bundler` gem (in the event where you have multiple bundler versions in your system). RubyGems will prioritize a bundler version based on a few heurisitics. https://github.com/ruby/rubygems/blob/b50c40c92abb00bb172f1579356cc73c242b1849/lib/rubygems/bundler_version_finder.rb#L19-L21 This prioritize logic doesn't take into account the bundler version a user has specific in this config. So what happens is: 1. User execute the `bundle` binstub 2. `require 'bundler'` is evaluated. 3. RubyGems prioritize activating the bundler version specified in the Gemfile.lock 4. The CLI starts, and [Auto switch kicks in](https://github.com/ruby/rubygems/blob/b50c40c92abb00bb172f1579356cc73c242b1849/bundler/lib/bundler/cli.rb#L81). Bundler detects that user specifed a version in its config and the current Bundler version doesn't match. 5. Bundler exit and re-exec with the right bundler version. ### Solution This patch introduce two fixes. First, it reads the bundler config file and check for the local config first and then the global config. This is because the local has precedence over global. Second, the prioritization takes into account the version in config and let RubyGems activate the right version in order to prevent re-exec moments later. Finally, I also want to fix this problem because its a step toward fixing https://github.com/ruby/rubygems/issues/8106. I'll open a follow up patch to explain. https://github.com/ruby/rubygems/commit/d6e0f43133 --- lib/rubygems/bundler_version_finder.rb | 73 ++++++++++++------- spec/bundler/runtime/self_management_spec.rb | 18 +++++ .../test_gem_bundler_version_finder.rb | 25 +++++-- 3 files changed, 84 insertions(+), 32 deletions(-) diff --git a/lib/rubygems/bundler_version_finder.rb b/lib/rubygems/bundler_version_finder.rb index c930c2e19c264f..d792358da70176 100644 --- a/lib/rubygems/bundler_version_finder.rb +++ b/lib/rubygems/bundler_version_finder.rb @@ -10,6 +10,8 @@ def self.bundler_version v ||= bundle_update_bundler_version return if v == true + v ||= bundle_config_version + v ||= lockfile_version return unless v @@ -49,21 +51,7 @@ def self.lockfile_version private_class_method :lockfile_version def self.lockfile_contents - gemfile = ENV["BUNDLE_GEMFILE"] - gemfile = nil if gemfile&.empty? - - unless gemfile - begin - Gem::Util.traverse_parents(Dir.pwd) do |directory| - next unless gemfile = Gem::GEM_DEP_FILES.find {|f| File.file?(f) } - - gemfile = File.join directory, gemfile - break - end - rescue Errno::ENOENT - return - end - end + gemfile = gemfile_path return unless gemfile @@ -82,19 +70,24 @@ def self.lockfile_contents private_class_method :lockfile_contents def self.bundle_config_version - config_file = bundler_config_file - return unless config_file && File.file?(config_file) + version = nil - contents = File.read(config_file) - contents =~ /^BUNDLE_VERSION:\s*["']?([^"'\s]+)["']?\s*$/ + [bundler_local_config_file, bundler_global_config_file].each do |config_file| + next unless config_file && File.file?(config_file) - $1 + contents = File.read(config_file) + contents =~ /^BUNDLE_VERSION:\s*["']?([^"'\s]+)["']?\s*$/ + + version = $1 + break if version + end + + version end private_class_method :bundle_config_version - def self.bundler_config_file - # see Bundler::Settings#global_config_file and local_config_file - # global + def self.bundler_global_config_file + # see Bundler::Settings#global_config_file if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty? ENV["BUNDLE_CONFIG"] elsif ENV["BUNDLE_USER_CONFIG"] && !ENV["BUNDLE_USER_CONFIG"].empty? @@ -103,10 +96,36 @@ def self.bundler_config_file ENV["BUNDLE_USER_HOME"] + "config" elsif Gem.user_home && !Gem.user_home.empty? Gem.user_home + ".bundle/config" - else - # local - "config" end end - private_class_method :bundler_config_file + private_class_method :bundler_global_config_file + + def self.bundler_local_config_file + gemfile = gemfile_path + return unless gemfile + + File.join(File.dirname(gemfile), ".bundle", "config") + end + private_class_method :bundler_local_config_file + + def self.gemfile_path + gemfile = ENV["BUNDLE_GEMFILE"] + gemfile = nil if gemfile&.empty? + + unless gemfile + begin + Gem::Util.traverse_parents(Dir.pwd) do |directory| + next unless gemfile = Gem::GEM_DEP_FILES.find {|f| File.file?(f) } + + gemfile = File.join directory, gemfile + break + end + rescue Errno::ENOENT + return + end + end + + gemfile + end + private_class_method :gemfile_path end diff --git a/spec/bundler/runtime/self_management_spec.rb b/spec/bundler/runtime/self_management_spec.rb index fbffd2dca2dfa7..34382df2681780 100644 --- a/spec/bundler/runtime/self_management_spec.rb +++ b/spec/bundler/runtime/self_management_spec.rb @@ -171,6 +171,24 @@ expect(out).to eq(previous_minor) end + it "requires the right bundler version from the config and run bundle CLI without re-exec" do + unless Bundler.rubygems.provides?(">= 4.1.0.dev") + skip "This spec can only run when Gem::BundlerVersionFinder.bundler_versions reads bundler configs" + end + + lockfile_bundled_with(current_version) + + bundle "config set --local version #{previous_minor}" + bundle "config set --local path.system true" + bundle "install" + + script = bundled_app("script.rb") + create_file(script, "p 'executed once'") + + bundle "-v", env: { "RUBYOPT" => "-r#{script}" } + expect(out).to eq(%("executed once"\n9.3.0)) + end + it "does not try to install when using bundle config version global" do lockfile_bundled_with(previous_minor) diff --git a/test/rubygems/test_gem_bundler_version_finder.rb b/test/rubygems/test_gem_bundler_version_finder.rb index a773d6249b5967..88ee9c6759f203 100644 --- a/test/rubygems/test_gem_bundler_version_finder.rb +++ b/test/rubygems/test_gem_bundler_version_finder.rb @@ -66,7 +66,7 @@ def test_bundler_version_with_bundle_config f.write(config_content) f.flush - bvf.stub(:bundler_config_file, f.path) do + bvf.stub(:bundler_global_config_file, f.path) do assert_nil bvf.bundler_version end end @@ -81,7 +81,7 @@ def test_bundler_version_with_bundle_config_single_quoted f.write(config_with_single_quoted_version) f.flush - bvf.stub(:bundler_config_file, f.path) do + bvf.stub(:bundler_global_config_file, f.path) do assert_nil bvf.bundler_version end end @@ -98,18 +98,33 @@ def test_bundler_version_with_bundle_config_version f.write(config_content) f.flush - bvf.stub(:bundler_config_file, f.path) do + bvf.stub(:bundler_global_config_file, f.path) do assert_equal v("1.1.1.1"), bvf.bundler_version end end end def test_bundler_version_with_bundle_config_non_existent_file - bvf.stub(:bundler_config_file, "/non/existent/path") do + bvf.stub(:bundler_global_config_file, "/non/existent/path") do assert_nil bvf.bundler_version end end + def test_bundler_version_set_on_local_config + config_content = <<~CONFIG + BUNDLE_VERSION: "1.2.3" + CONFIG + + Tempfile.create("bundle_config") do |f| + f.write(config_content) + f.flush + + bvf.stub(:bundler_local_config_file, f.path) do + assert_equal v("1.2.3"), bvf.bundler_version + end + end + end + def test_bundler_version_with_bundle_config_without_version config_without_version = <<~CONFIG BUNDLE_JOBS: "8" @@ -120,7 +135,7 @@ def test_bundler_version_with_bundle_config_without_version f.write(config_without_version) f.flush - bvf.stub(:bundler_config_file, f.path) do + bvf.stub(:bundler_global_config_file, f.path) do assert_nil bvf.bundler_version end end From b839989fd22fef85e2af19de1bc83aa72a5b22bd Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 26 Jan 2026 15:36:04 +0900 Subject: [PATCH 6/9] win32: Add CR to all batch files. This reverts commit 23f9a0d655c4d405bb2397a147a1523436205486, "win32: Strip CR from batch files", and add CR to the other batch files too. `cmd.exe` seems to work well with LF at a glance, but sometimes `goto` jumps to an unexpected line. This is probably because it is looking for the beginning of a line, assuming that all lines end with CRLF, and as a result mistaking the `goto` operand for a label. --- win32/configure.bat | 642 ++++++++++++++++---------------- win32/ifchange.bat | 274 +++++++------- win32/install-buildtools.cmd | 28 +- win32/install-msys-packages.cmd | 58 +-- win32/lastrev.bat | 60 +-- win32/makedirs.bat | 6 +- win32/rm.bat | 128 +++---- win32/rmdirs.bat | 68 ++-- win32/rtname.cmd | 72 ++-- win32/vssetup.cmd | 112 +++--- 10 files changed, 724 insertions(+), 724 deletions(-) diff --git a/win32/configure.bat b/win32/configure.bat index a22630385bba14..9355caa4d852da 100755 --- a/win32/configure.bat +++ b/win32/configure.bat @@ -1,321 +1,321 @@ -@echo off -@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 -set PROMPT=$E[94m+$E[m$S -set witharg= - -if "%~dp0" == "%CD%\" ( - echo don't run in win32 directory. - exit /b 999 -) else if "%0" == "%~nx0" ( - set "WIN32DIR=%~$PATH:0" -) else if "%0" == "%~n0" ( - set "WIN32DIR=%~$PATH:0" -) else ( - set "WIN32DIR=%0" -) - -set "WIN32DIR=%WIN32DIR:\=/%:/:" -call set "WIN32DIR=%%WIN32DIR:%~x0:/:=:/:%%" -call set "WIN32DIR=%%WIN32DIR:/%~n0:/:=:/:%%" -set "WIN32DIR=%WIN32DIR:~0,-3%" - -set XINCFLAGS= -set XLDFLAGS= -set pathlist= -set config_make=confargs~%RANDOM%.mak -set confargs=%config_make:.mak=.c% -echo>%config_make% # CONFIGURE -( - echo #define $ $$ // - echo !ifndef CONFIGURE_ARGS - echo #define CONFIGURE_ARGS \ -) >%confargs% -:loop -set opt=%1 -if "%1" == "" goto :end -if "%1" == "--debug-configure" (echo on & shift & goto :loop) -if "%1" == "--no-debug-configure" (echo off & shift & goto :loop) -if "%1" == "--prefix" goto :prefix -if "%1" == "--srcdir" goto :srcdir -if "%1" == "srcdir" goto :srcdir -if "%1" == "--target" goto :target -if "%1" == "target" goto :target -if "%1" == "--with-static-linked-ext" goto :extstatic -if "%1" == "--program-prefix" goto :pprefix -if "%1" == "--program-suffix" goto :suffix -if "%1" == "--program-transform-name" goto :transform_name -if "%1" == "--program-name" goto :installname -if "%1" == "--install-name" goto :installname -if "%1" == "--so-name" goto :soname -if "%1" == "--enable-install-doc" goto :enable-rdoc -if "%1" == "--disable-install-doc" goto :disable-rdoc -if "%1" == "--enable-install-static-library" goto :enable-lib -if "%1" == "--disable-install-static-library" goto :disable-lib -if "%1" == "--enable-debug-env" goto :enable-debug-env -if "%1" == "--disable-debug-env" goto :disable-debug-env -if "%1" == "--enable-devel" goto :enable-devel -if "%1" == "--disable-devel" goto :disable-devel -if "%1" == "--enable-rubygems" goto :enable-rubygems -if "%1" == "--disable-rubygems" goto :disable-rubygems -if "%1" == "--extout" goto :extout -if "%1" == "--path" goto :path -if "%1" == "--with-baseruby" goto :baseruby -if "%1" == "--without-baseruby" goto :nobaseruby -if "%1" == "--with-ntver" goto :ntver -if "%1" == "--with-libdir" goto :libdir -if "%1" == "--with-git" goto :git -if "%1" == "--without-git" goto :nogit -if "%1" == "--without-ext" goto :witharg -if "%1" == "--without-extensions" goto :witharg -if "%1" == "--with-opt-dir" goto :opt-dir -if "%1" == "--with-gmp" goto :gmp -if "%1" == "--with-gmp-dir" goto :gmp-dir -if "%opt:~0,10%" == "--without-" goto :withoutarg -if "%opt:~0,7%" == "--with-" goto :witharg -if "%1" == "-h" goto :help -if "%1" == "--help" goto :help - if "%opt:~0,1%" == "-" ( - echo>>%confargs% %1 \ - set witharg= - ) else if "%witharg%" == "" ( - echo>>%confargs% %1 \ - ) else ( - echo>>%confargs% ,%1\ - ) - shift -goto :loop ; -:srcdir - echo>> %config_make% srcdir = %~2 - echo>>%confargs% --srcdir=%2 \ - shift - shift -goto :loop ; -:prefix - echo>> %config_make% prefix = %~2 - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:pprefix - echo>> %config_make% PROGRAM_PREFIX = %~2 - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:suffix - echo>> %config_make% PROGRAM_SUFFIX = %~2 - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:installname - echo>> %config_make% RUBY_INSTALL_NAME = %~2 - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:soname - echo>> %config_make% RUBY_SO_NAME = %~2 - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:transform_name - - shift - shift -goto :loop ; -:target - echo>> %config_make% target = %~2 - echo>>%confargs% --target=%2 \ - if "%~2" == "x64-mswin64" ( - echo>> %config_make% TARGET_OS = mswin64 - ) - shift - shift -goto :loop ; -:extstatic - echo>> %config_make% EXTSTATIC = static - echo>>%confargs% %1 \ - shift -goto :loop ; -:enable-rdoc - echo>> %config_make% RDOCTARGET = rdoc - echo>>%confargs% %1 \ - shift -goto :loop ; -:disable-rdoc - echo>> %config_make% RDOCTARGET = nodoc - echo>>%confargs% %1 \ - shift -goto :loop ; -:enable-lib - echo>> %config_make% INSTALL_STATIC_LIBRARY = yes - echo>>%confargs% %1 \ - shift -goto :loop ; -:disable-lib - echo>> %config_make% INSTALL_STATIC_LIBRARY = no - echo>>%confargs% %1 \ - shift -goto :loop ; -:enable-debug-env - echo>> %config_make% ENABLE_DEBUG_ENV = yes - echo>>%confargs% %1 \ - shift -goto :loop ; -:disable-debug-env - echo>> %config_make% ENABLE_DEBUG_ENV = no - echo>>%confargs% %1 \ - shift -goto :loop ; -:enable-devel - echo>> %config_make% RUBY_DEVEL = yes - echo>>%confargs% %1 \ - shift -goto :loop ; -:disable-devel - echo>> %config_make% RUBY_DEVEL = no - echo>>%confargs% %1 \ - shift -goto :loop ; -:enable-rubygems - echo>> %config_make% USE_RUBYGEMS = yes - echo>>%confargs% %1 \ - shift -goto :loop ; -:disable-rubygems - echo>> %config_make% USE_RUBYGEMS = no - echo>>%confargs% %1 \ - shift -goto :loop ; -:ntver - ::- For version constants, see - ::- https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt#remarks - set NTVER=%~2 - if /i not "%NTVER:~0,2%" == "0x" if /i not "%NTVER:~0,13%" == "_WIN32_WINNT_" ( - for %%i in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do ( - call set NTVER=%%NTVER:%%i=%%i%% - ) - call set NTVER=_WIN32_WINNT_%%NTVER%% - ) - echo>> %config_make% NTVER = %NTVER% - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:extout - if not "%~2" == ".ext" (echo>> %config_make% EXTOUT = %~2) - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:path - set pathlist=%pathlist%%~2; - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:baseruby - echo>> %config_make% HAVE_BASERUBY = yes - echo>> %config_make% BASERUBY = %~2 - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:nobaseruby - echo>> %config_make% HAVE_BASERUBY = no - echo>> %config_make% BASERUBY = - echo>>%confargs% %1 \ - shift -goto :loop ; -:libdir - echo>> %config_make% libdir_basename = %~2 - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:git - echo>> %config_make% GIT = %~2 - echo>>%confargs% %1=%2 \ - shift - shift -goto :loop ; -:nogit - echo>> %config_make% GIT = never-use - echo>> %config_make% HAVE_GIT = no - echo>>%confargs% %1 \ - shift -goto :loop ; -:gmp - echo>> %config_make% WITH_GMP = yes - echo>>%confargs% %1 \ - shift -goto :loop ; -:gmp-dir -:opt-dir - set opt=%~2 - for %%I in (%opt:;= %) do ( - set d=%%I - call pushd %%d:/=\%% && ( - call set XINCFLAGS=%%XINCFLAGS%% -I%%CD:\=/%%/include - call set XLDFLAGS=%%XLDFLAGS%% -libpath:%%CD:\=/%%/lib - popd - ) - ) -:witharg - echo>>%confargs% %1=%2\ - set witharg=1 - shift - shift -goto :loop ; -:withoutarg - echo>>%confargs% %1 \ - shift -goto :loop ; -:help - echo Configuration: - echo --help display this help - echo --srcdir=DIR find the sources in DIR [configure dir or `..'] - echo Installation directories: - echo --prefix=PREFIX install files in PREFIX [/usr] - echo System types: - echo --target=TARGET configure for TARGET [i386-mswin32] - echo Optional Package: - echo --with-baseruby=RUBY use RUBY as baseruby [ruby] - echo --with-static-linked-ext link external modules statically - echo --with-ext="a,b,..." use extensions a, b, ... - echo --without-ext="a,b,..." ignore extensions a, b, ... - echo --with-opt-dir="DIR-LIST" add optional headers and libraries directories separated by `;' - echo --disable-install-doc do not install rdoc indexes during install - echo --with-ntver=0xXXXX target NT version (shouldn't use with old SDK) - echo --with-ntver=_WIN32_WINNT_XXXX - echo --with-ntver=XXXX same as --with-ntver=_WIN32_WINNT_XXXX - echo Note that `,' and `;' need to be enclosed within double quotes in batch file command line. - del %confargs% %config_make% -goto :exit -:end -( - echo // - echo configure_args = CONFIGURE_ARGS - echo !endif - echo #undef $ -) >> %confargs% -( - cl -EP %confargs% 2>nul | findstr "! =" - echo. - if NOT "%XINCFLAGS%" == "" echo XINCFLAGS = %XINCFLAGS% - if NOT "%XLDFLAGS%" == "" echo XLDFLAGS = %XLDFLAGS% - if NOT "%pathlist%" == "" ( - call echo PATH = %%pathlist:;=/bin;%%$^(PATH^) - call echo INCLUDE = %%pathlist:;=/include;%%$^(INCLUDE^) - call echo LIB = %%pathlist:;=/lib;%%$^(LIB^) - ) -) >> %config_make% -del %confargs% > nul - -nmake -al -f %WIN32DIR%/setup.mak "WIN32DIR=%WIN32DIR%" ^ - config_make=%config_make% ^ - MAKEFILE=Makefile.new MAKEFILE_BACK=Makefile.old MAKEFILE_NEW=Makefile -:exit -@endlocal +@echo off +@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 +set PROMPT=$E[94m+$E[m$S +set witharg= + +if "%~dp0" == "%CD%\" ( + echo don't run in win32 directory. + exit /b 999 +) else if "%0" == "%~nx0" ( + set "WIN32DIR=%~$PATH:0" +) else if "%0" == "%~n0" ( + set "WIN32DIR=%~$PATH:0" +) else ( + set "WIN32DIR=%0" +) + +set "WIN32DIR=%WIN32DIR:\=/%:/:" +call set "WIN32DIR=%%WIN32DIR:%~x0:/:=:/:%%" +call set "WIN32DIR=%%WIN32DIR:/%~n0:/:=:/:%%" +set "WIN32DIR=%WIN32DIR:~0,-3%" + +set XINCFLAGS= +set XLDFLAGS= +set pathlist= +set config_make=confargs~%RANDOM%.mak +set confargs=%config_make:.mak=.c% +echo>%config_make% # CONFIGURE +( + echo #define $ $$ // + echo !ifndef CONFIGURE_ARGS + echo #define CONFIGURE_ARGS \ +) >%confargs% +:loop +set opt=%1 +if "%1" == "" goto :end +if "%1" == "--debug-configure" (echo on & shift & goto :loop) +if "%1" == "--no-debug-configure" (echo off & shift & goto :loop) +if "%1" == "--prefix" goto :prefix +if "%1" == "--srcdir" goto :srcdir +if "%1" == "srcdir" goto :srcdir +if "%1" == "--target" goto :target +if "%1" == "target" goto :target +if "%1" == "--with-static-linked-ext" goto :extstatic +if "%1" == "--program-prefix" goto :pprefix +if "%1" == "--program-suffix" goto :suffix +if "%1" == "--program-transform-name" goto :transform_name +if "%1" == "--program-name" goto :installname +if "%1" == "--install-name" goto :installname +if "%1" == "--so-name" goto :soname +if "%1" == "--enable-install-doc" goto :enable-rdoc +if "%1" == "--disable-install-doc" goto :disable-rdoc +if "%1" == "--enable-install-static-library" goto :enable-lib +if "%1" == "--disable-install-static-library" goto :disable-lib +if "%1" == "--enable-debug-env" goto :enable-debug-env +if "%1" == "--disable-debug-env" goto :disable-debug-env +if "%1" == "--enable-devel" goto :enable-devel +if "%1" == "--disable-devel" goto :disable-devel +if "%1" == "--enable-rubygems" goto :enable-rubygems +if "%1" == "--disable-rubygems" goto :disable-rubygems +if "%1" == "--extout" goto :extout +if "%1" == "--path" goto :path +if "%1" == "--with-baseruby" goto :baseruby +if "%1" == "--without-baseruby" goto :nobaseruby +if "%1" == "--with-ntver" goto :ntver +if "%1" == "--with-libdir" goto :libdir +if "%1" == "--with-git" goto :git +if "%1" == "--without-git" goto :nogit +if "%1" == "--without-ext" goto :witharg +if "%1" == "--without-extensions" goto :witharg +if "%1" == "--with-opt-dir" goto :opt-dir +if "%1" == "--with-gmp" goto :gmp +if "%1" == "--with-gmp-dir" goto :gmp-dir +if "%opt:~0,10%" == "--without-" goto :withoutarg +if "%opt:~0,7%" == "--with-" goto :witharg +if "%1" == "-h" goto :help +if "%1" == "--help" goto :help + if "%opt:~0,1%" == "-" ( + echo>>%confargs% %1 \ + set witharg= + ) else if "%witharg%" == "" ( + echo>>%confargs% %1 \ + ) else ( + echo>>%confargs% ,%1\ + ) + shift +goto :loop ; +:srcdir + echo>> %config_make% srcdir = %~2 + echo>>%confargs% --srcdir=%2 \ + shift + shift +goto :loop ; +:prefix + echo>> %config_make% prefix = %~2 + echo>>%confargs% %1=%2 \ + shift + shift +goto :loop ; +:pprefix + echo>> %config_make% PROGRAM_PREFIX = %~2 + echo>>%confargs% %1=%2 \ + shift + shift +goto :loop ; +:suffix + echo>> %config_make% PROGRAM_SUFFIX = %~2 + echo>>%confargs% %1=%2 \ + shift + shift +goto :loop ; +:installname + echo>> %config_make% RUBY_INSTALL_NAME = %~2 + echo>>%confargs% %1=%2 \ + shift + shift +goto :loop ; +:soname + echo>> %config_make% RUBY_SO_NAME = %~2 + echo>>%confargs% %1=%2 \ + shift + shift +goto :loop ; +:transform_name + + shift + shift +goto :loop ; +:target + echo>> %config_make% target = %~2 + echo>>%confargs% --target=%2 \ + if "%~2" == "x64-mswin64" ( + echo>> %config_make% TARGET_OS = mswin64 + ) + shift + shift +goto :loop ; +:extstatic + echo>> %config_make% EXTSTATIC = static + echo>>%confargs% %1 \ + shift +goto :loop ; +:enable-rdoc + echo>> %config_make% RDOCTARGET = rdoc + echo>>%confargs% %1 \ + shift +goto :loop ; +:disable-rdoc + echo>> %config_make% RDOCTARGET = nodoc + echo>>%confargs% %1 \ + shift +goto :loop ; +:enable-lib + echo>> %config_make% INSTALL_STATIC_LIBRARY = yes + echo>>%confargs% %1 \ + shift +goto :loop ; +:disable-lib + echo>> %config_make% INSTALL_STATIC_LIBRARY = no + echo>>%confargs% %1 \ + shift +goto :loop ; +:enable-debug-env + echo>> %config_make% ENABLE_DEBUG_ENV = yes + echo>>%confargs% %1 \ + shift +goto :loop ; +:disable-debug-env + echo>> %config_make% ENABLE_DEBUG_ENV = no + echo>>%confargs% %1 \ + shift +goto :loop ; +:enable-devel + echo>> %config_make% RUBY_DEVEL = yes + echo>>%confargs% %1 \ + shift +goto :loop ; +:disable-devel + echo>> %config_make% RUBY_DEVEL = no + echo>>%confargs% %1 \ + shift +goto :loop ; +:enable-rubygems + echo>> %config_make% USE_RUBYGEMS = yes + echo>>%confargs% %1 \ + shift +goto :loop ; +:disable-rubygems + echo>> %config_make% USE_RUBYGEMS = no + echo>>%confargs% %1 \ + shift +goto :loop ; +:ntver + ::- For version constants, see + ::- https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt#remarks + set NTVER=%~2 + if /i not "%NTVER:~0,2%" == "0x" if /i not "%NTVER:~0,13%" == "_WIN32_WINNT_" ( + for %%i in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do ( + call set NTVER=%%NTVER:%%i=%%i%% + ) + call set NTVER=_WIN32_WINNT_%%NTVER%% + ) + echo>> %config_make% NTVER = %NTVER% + echo>>%confargs% %1=%2 \ + shift + shift +goto :loop ; +:extout + if not "%~2" == ".ext" (echo>> %config_make% EXTOUT = %~2) + echo>>%confargs% %1=%2 \ + shift + shift +goto :loop ; +:path + set pathlist=%pathlist%%~2; + echo>>%confargs% %1=%2 \ + shift + shift +goto :loop ; +:baseruby + echo>> %config_make% HAVE_BASERUBY = yes + echo>> %config_make% BASERUBY = %~2 + echo>>%confargs% %1=%2 \ + shift + shift +goto :loop ; +:nobaseruby + echo>> %config_make% HAVE_BASERUBY = no + echo>> %config_make% BASERUBY = + echo>>%confargs% %1 \ + shift +goto :loop ; +:libdir + echo>> %config_make% libdir_basename = %~2 + echo>>%confargs% %1=%2 \ + shift + shift +goto :loop ; +:git + echo>> %config_make% GIT = %~2 + echo>>%confargs% %1=%2 \ + shift + shift +goto :loop ; +:nogit + echo>> %config_make% GIT = never-use + echo>> %config_make% HAVE_GIT = no + echo>>%confargs% %1 \ + shift +goto :loop ; +:gmp + echo>> %config_make% WITH_GMP = yes + echo>>%confargs% %1 \ + shift +goto :loop ; +:gmp-dir +:opt-dir + set opt=%~2 + for %%I in (%opt:;= %) do ( + set d=%%I + call pushd %%d:/=\%% && ( + call set XINCFLAGS=%%XINCFLAGS%% -I%%CD:\=/%%/include + call set XLDFLAGS=%%XLDFLAGS%% -libpath:%%CD:\=/%%/lib + popd + ) + ) +:witharg + echo>>%confargs% %1=%2\ + set witharg=1 + shift + shift +goto :loop ; +:withoutarg + echo>>%confargs% %1 \ + shift +goto :loop ; +:help + echo Configuration: + echo --help display this help + echo --srcdir=DIR find the sources in DIR [configure dir or `..'] + echo Installation directories: + echo --prefix=PREFIX install files in PREFIX [/usr] + echo System types: + echo --target=TARGET configure for TARGET [i386-mswin32] + echo Optional Package: + echo --with-baseruby=RUBY use RUBY as baseruby [ruby] + echo --with-static-linked-ext link external modules statically + echo --with-ext="a,b,..." use extensions a, b, ... + echo --without-ext="a,b,..." ignore extensions a, b, ... + echo --with-opt-dir="DIR-LIST" add optional headers and libraries directories separated by `;' + echo --disable-install-doc do not install rdoc indexes during install + echo --with-ntver=0xXXXX target NT version (shouldn't use with old SDK) + echo --with-ntver=_WIN32_WINNT_XXXX + echo --with-ntver=XXXX same as --with-ntver=_WIN32_WINNT_XXXX + echo Note that `,' and `;' need to be enclosed within double quotes in batch file command line. + del %confargs% %config_make% +goto :exit +:end +( + echo // + echo configure_args = CONFIGURE_ARGS + echo !endif + echo #undef $ +) >> %confargs% +( + cl -EP %confargs% 2>nul | findstr "! =" + echo. + if NOT "%XINCFLAGS%" == "" echo XINCFLAGS = %XINCFLAGS% + if NOT "%XLDFLAGS%" == "" echo XLDFLAGS = %XLDFLAGS% + if NOT "%pathlist%" == "" ( + call echo PATH = %%pathlist:;=/bin;%%$^(PATH^) + call echo INCLUDE = %%pathlist:;=/include;%%$^(INCLUDE^) + call echo LIB = %%pathlist:;=/lib;%%$^(LIB^) + ) +) >> %config_make% +del %confargs% > nul + +nmake -al -f %WIN32DIR%/setup.mak "WIN32DIR=%WIN32DIR%" ^ + config_make=%config_make% ^ + MAKEFILE=Makefile.new MAKEFILE_BACK=Makefile.old MAKEFILE_NEW=Makefile +:exit +@endlocal diff --git a/win32/ifchange.bat b/win32/ifchange.bat index fa10c5870351c3..f3fc9ea37c6203 100755 --- a/win32/ifchange.bat +++ b/win32/ifchange.bat @@ -1,137 +1,137 @@ -@echo off -:: usage: ifchange target temporary - -@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 - -:: @set PROMPT=$T:$S -for %%I in (%0) do set progname=%%~nI -set timestamp= -set keepsuffix= -set empty= -set color=auto -:optloop -set optarg= -:optnext -for %%I in (%1) do set opt=%%~I - if not "%opt:~0,2%" == "--" ( - if not "%optarg%" == "" ( - call set %optarg%=%%opt%% - shift - goto :optloop - ) - goto :optend - ) - if "%opt%" == "--" ( - shift - goto :optend - ) - if "%opt%" == "--timestamp" ( - set timestamp=. - set optarg=timestamp - shift - goto :optnext - ) - if "%opt:~0,12%" == "--timestamp=" ( - set timestamp=%opt:~12% - shift - goto :optloop - ) - if "%opt%" == "--keep" ( - set keepsuffix=.old - set optarg=keep - shift - goto :optnext - ) - if "%opt:~0,7%" == "--keep=" ( - set keepsuffix=%opt:~7% - shift - goto :optloop - ) - if "%opt%" == "--empty" ( - set empty=yes - shift - goto :optloop - ) - if "%opt%" == "--color" ( - set color=always - set optarg=color - shift - goto :optnext - ) - if "%opt:~0,8%" == "--color=" ( - set color=%opt:~8% - shift - goto :optloop - ) - if "%opt%" == "--debug" ( - shift - echo on - goto :optloop - ) - if "%opt%" == "--help" ( - call :help - exit /b - ) - echo %progname%: unknown option: %1 1>&2 - exit /b 1 -:optend - -if "%2" == "" ( - call :help 1>&2 - exit /b 1 -) - -set dest=%1 -set src=%2 -set dest=%dest:/=\% -set src=%src:/=\% - -if not "%src%" == "-" goto :srcfile - if not "%TMPDIR%" == "" ( - set src=%TMPDIR%\ifchange%RANDOM%.tmp - ) else if not "%TEMP%" == "" ( - set src=%TEMP%\ifchange%RANDOM%.tmp - ) else if not "%TMP%" == "" ( - set src=%TMP%\ifchange%RANDOM%.tmp - ) else ( - set src=.\ifchange%RANDOM%.tmp - ) - findstr -r -c:"^" > "%src%" -:srcfile - -if exist %dest% ( - if not exist %src% goto :nt_unchanged1 - if not "%empty%" == "" for %%I in (%src%) do if %%~zI == 0 goto :nt_unchanged - fc.exe %dest% %src% > nul && ( - :nt_unchanged - del %src% - :nt_unchanged1 - for %%I in (%1) do echo %%~I unchanged - goto :nt_end - ) -) -for %%I in (%1) do echo %%~I updated -del /f %dest% 2> nul -copy %src% %dest% > nul -del %src% - -:nt_end -if "%timestamp%" == "" goto :end - if "%timestamp%" == "." ( - for %%I in ("%dest%") do set timestamp=%%~dpI.time.%%~nxI - ) - goto :end > "%timestamp%" - -:help - for %%I in ( - "usage: %progname% [options] target new-file" - "options:" - " --timestamp[=file] touch timestamp file. (default: prefixed with '.time')" - " under the directory of the target)" - " --keep[=suffix] keep old file with suffix. (default: '.old')" - " --empty assume unchanged if the new file is empty." - " --color[=always|auto|never] colorize output." - ) do echo.%%~I - goto :eof - -:end +@echo off +:: usage: ifchange target temporary + +@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 + +:: @set PROMPT=$T:$S +for %%I in (%0) do set progname=%%~nI +set timestamp= +set keepsuffix= +set empty= +set color=auto +:optloop +set optarg= +:optnext +for %%I in (%1) do set opt=%%~I + if not "%opt:~0,2%" == "--" ( + if not "%optarg%" == "" ( + call set %optarg%=%%opt%% + shift + goto :optloop + ) + goto :optend + ) + if "%opt%" == "--" ( + shift + goto :optend + ) + if "%opt%" == "--timestamp" ( + set timestamp=. + set optarg=timestamp + shift + goto :optnext + ) + if "%opt:~0,12%" == "--timestamp=" ( + set timestamp=%opt:~12% + shift + goto :optloop + ) + if "%opt%" == "--keep" ( + set keepsuffix=.old + set optarg=keep + shift + goto :optnext + ) + if "%opt:~0,7%" == "--keep=" ( + set keepsuffix=%opt:~7% + shift + goto :optloop + ) + if "%opt%" == "--empty" ( + set empty=yes + shift + goto :optloop + ) + if "%opt%" == "--color" ( + set color=always + set optarg=color + shift + goto :optnext + ) + if "%opt:~0,8%" == "--color=" ( + set color=%opt:~8% + shift + goto :optloop + ) + if "%opt%" == "--debug" ( + shift + echo on + goto :optloop + ) + if "%opt%" == "--help" ( + call :help + exit /b + ) + echo %progname%: unknown option: %1 1>&2 + exit /b 1 +:optend + +if "%2" == "" ( + call :help 1>&2 + exit /b 1 +) + +set dest=%1 +set src=%2 +set dest=%dest:/=\% +set src=%src:/=\% + +if not "%src%" == "-" goto :srcfile + if not "%TMPDIR%" == "" ( + set src=%TMPDIR%\ifchange%RANDOM%.tmp + ) else if not "%TEMP%" == "" ( + set src=%TEMP%\ifchange%RANDOM%.tmp + ) else if not "%TMP%" == "" ( + set src=%TMP%\ifchange%RANDOM%.tmp + ) else ( + set src=.\ifchange%RANDOM%.tmp + ) + findstr -r -c:"^" > "%src%" +:srcfile + +if exist %dest% ( + if not exist %src% goto :nt_unchanged1 + if not "%empty%" == "" for %%I in (%src%) do if %%~zI == 0 goto :nt_unchanged + fc.exe %dest% %src% > nul && ( + :nt_unchanged + del %src% + :nt_unchanged1 + for %%I in (%1) do echo %%~I unchanged + goto :nt_end + ) +) +for %%I in (%1) do echo %%~I updated +del /f %dest% 2> nul +copy %src% %dest% > nul +del %src% + +:nt_end +if "%timestamp%" == "" goto :end + if "%timestamp%" == "." ( + for %%I in ("%dest%") do set timestamp=%%~dpI.time.%%~nxI + ) + goto :end > "%timestamp%" + +:help + for %%I in ( + "usage: %progname% [options] target new-file" + "options:" + " --timestamp[=file] touch timestamp file. (default: prefixed with '.time')" + " under the directory of the target)" + " --keep[=suffix] keep old file with suffix. (default: '.old')" + " --empty assume unchanged if the new file is empty." + " --color[=always|auto|never] colorize output." + ) do echo.%%~I + goto :eof + +:end diff --git a/win32/install-buildtools.cmd b/win32/install-buildtools.cmd index fbbe051f717b3e..7f5e20293b7454 100755 --- a/win32/install-buildtools.cmd +++ b/win32/install-buildtools.cmd @@ -1,14 +1,14 @@ -@echo off -@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 - -set components=VC.Tools.x86.x64 VC.Redist.14.Latest CoreBuildTools -set components=%components% Windows11SDK.26100 -if /i "%PROCESSOR_ARCHITECTURE%" == "ARM64" ( - set components=%components% VC.Tools.ARM64 VC.Tools.ARM64EC -) -set override=--passive -for %%I in (%components%) do ( - call set override=%%override%% --add Microsoft.VisualStudio.Component.%%I -) -echo on -winget install --id Microsoft.VisualStudio.2022.BuildTools --override "%override%" +@echo off +@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 + +set components=VC.Tools.x86.x64 VC.Redist.14.Latest CoreBuildTools +set components=%components% Windows11SDK.26100 +if /i "%PROCESSOR_ARCHITECTURE%" == "ARM64" ( + set components=%components% VC.Tools.ARM64 VC.Tools.ARM64EC +) +set override=--passive +for %%I in (%components%) do ( + call set override=%%override%% --add Microsoft.VisualStudio.Component.%%I +) +echo on +winget install --id Microsoft.VisualStudio.2022.BuildTools --override "%override%" diff --git a/win32/install-msys-packages.cmd b/win32/install-msys-packages.cmd index d3adbaf5956651..f388de5692ccde 100755 --- a/win32/install-msys-packages.cmd +++ b/win32/install-msys-packages.cmd @@ -1,29 +1,29 @@ -::- Install msys packages for rubygems -::- The dependencies are taken from vcpkg.json to share the common info. - -@setlocal EnableExtensions DisableDelayedExpansion || exit /b - 1 -@set PROMPT=$h$e[96m$g$e[39m$s -@set script=%0 -@call set "srcdir=%%script:\win32\%~nx0=%%" - -@if not defined MINGW_PACKAGE_PREFIX ( - ::- Enable msys environment by ridk (from RubyInstaller-DevKit) - where ridk >nul 2>&1 || ( - (echo MINGW_PACKAGE_PREFIX is not set, you have to enable development environment.) 1>&2 - exit /b 1 - ) - call ridk enable %* - echo: -) else if not "%1" == "" ( - ::- Switch msys environment by ridk (from RubyInstaller-DevKit) - call ridk enable %* - echo: -) - -@set pkgs= -@( - for /f %%I in ('powershell -c "(ConvertFrom-Json $input).dependencies"') do @( - call set "pkgs=%%pkgs%% %%MINGW_PACKAGE_PREFIX%%-%%%%I" - ) -) < "%srcdir%\vcpkg.json" -pacman -S --needed --noconfirm %pkgs:~1% +::- Install msys packages for rubygems +::- The dependencies are taken from vcpkg.json to share the common info. + +@setlocal EnableExtensions DisableDelayedExpansion || exit /b - 1 +@set PROMPT=$h$e[96m$g$e[39m$s +@set script=%0 +@call set "srcdir=%%script:\win32\%~nx0=%%" + +@if not defined MINGW_PACKAGE_PREFIX ( + ::- Enable msys environment by ridk (from RubyInstaller-DevKit) + where ridk >nul 2>&1 || ( + (echo MINGW_PACKAGE_PREFIX is not set, you have to enable development environment.) 1>&2 + exit /b 1 + ) + call ridk enable %* + echo: +) else if not "%1" == "" ( + ::- Switch msys environment by ridk (from RubyInstaller-DevKit) + call ridk enable %* + echo: +) + +@set pkgs= +@( + for /f %%I in ('powershell -c "(ConvertFrom-Json $input).dependencies"') do @( + call set "pkgs=%%pkgs%% %%MINGW_PACKAGE_PREFIX%%-%%%%I" + ) +) < "%srcdir%\vcpkg.json" +pacman -S --needed --noconfirm %pkgs:~1% diff --git a/win32/lastrev.bat b/win32/lastrev.bat index c4ce61e34abe82..48e5750c6e188b 100755 --- a/win32/lastrev.bat +++ b/win32/lastrev.bat @@ -1,30 +1,30 @@ -@echo off -@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 - -if "%1" == "" (set gitdir=.) else (set gitdir=%1) -set TZ=UTC -for /f "usebackq tokens=1-3" %%I in ( - `git -C "%gitdir%" log -1 --no-show-signature "--date=format-local:%%F %%T" "--format=%%H %%cd" HEAD` -) do ( - set rev=%%I - set dt=%%J - set tm=%%K -) -if not "%dt%" == "" ( - set /a yy=%dt:-=% / 10000 - set /a mm=%dt:-=% / 100 %% 100 - set /a dd=%dt:-=% %% 100 -) -for /f "usebackq tokens=1" %%I in ( - `git -C "%gitdir%" symbolic-ref --short HEAD` -) do set branch=%%I -if not "%rev%" == "" ( - echo #define RUBY_REVISION "%rev:~,10%" - echo #define RUBY_FULL_REVISION "%rev%" - echo #define RUBY_BRANCH_NAME "%branch%" - echo #define RUBY_RELEASE_DATETIME "%dt%T%tm%Z" - echo #define RUBY_RELEASE_YEAR %yy% - echo #define RUBY_RELEASE_MONTH %mm% - echo #define RUBY_RELEASE_DAY %dd% -) -@endlocal +@echo off +@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 + +if "%1" == "" (set gitdir=.) else (set gitdir=%1) +set TZ=UTC +for /f "usebackq tokens=1-3" %%I in ( + `git -C "%gitdir%" log -1 --no-show-signature "--date=format-local:%%F %%T" "--format=%%H %%cd" HEAD` +) do ( + set rev=%%I + set dt=%%J + set tm=%%K +) +if not "%dt%" == "" ( + set /a yy=%dt:-=% / 10000 + set /a mm=%dt:-=% / 100 %% 100 + set /a dd=%dt:-=% %% 100 +) +for /f "usebackq tokens=1" %%I in ( + `git -C "%gitdir%" symbolic-ref --short HEAD` +) do set branch=%%I +if not "%rev%" == "" ( + echo #define RUBY_REVISION "%rev:~,10%" + echo #define RUBY_FULL_REVISION "%rev%" + echo #define RUBY_BRANCH_NAME "%branch%" + echo #define RUBY_RELEASE_DATETIME "%dt%T%tm%Z" + echo #define RUBY_RELEASE_YEAR %yy% + echo #define RUBY_RELEASE_MONTH %mm% + echo #define RUBY_RELEASE_DAY %dd% +) +@endlocal diff --git a/win32/makedirs.bat b/win32/makedirs.bat index 6688457139ed34..8c06d94041c46b 100755 --- a/win32/makedirs.bat +++ b/win32/makedirs.bat @@ -1,3 +1,3 @@ -@echo off -@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 -for %%I in (%*) do if not exist "%%~I/." mkdir "%%~I" +@echo off +@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 +for %%I in (%*) do if not exist "%%~I/." mkdir "%%~I" diff --git a/win32/rm.bat b/win32/rm.bat index 02077919916b5a..c41ebfa5ee0177 100755 --- a/win32/rm.bat +++ b/win32/rm.bat @@ -1,64 +1,64 @@ -@echo off -@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 - -set prog=%~n0 -set dryrun= -set recursive= -set debug= -set error=0 -set parent= - -:optloop -if "%1" == "-f" shift -if "%1" == "-n" (shift & set "dryrun=%1" & goto :optloop) -if "%1" == "-r" (shift & set "recursive=%1" & goto :optloop) -if "%1" == "--debug" (shift & set "debug=%1" & set PROMPT=$E[34m+$E[m$S & echo on & goto :optloop) -:begin -if "%1" == "" goto :EOF - set p=%1 - shift - set p=%p:/=\% - call :remove %p% -goto :begin - -:remove -setlocal - -::- Split %1 by '?' and '*', wildcard characters -for /f "usebackq delims=?* tokens=1*" %%I in ('%1') do (set "par=%%I" & set "sub=%%J") -if "%sub%" == "" goto :remove_plain -if "%sub:\=%" == "%sub%" goto :remove_plain - ::- Extract the first wildcard - set "q=%1" - call set "q=%%q:%par%=%%" - set q=%q:~0,1% - - ::- `delims` chars at the beginning are removed in `for` - if "%sub:~0,1%" == "\" ( - set "sub=%sub:~1%" - set "par=%par%%q%" - ) else ( - for /f "usebackq delims=\\ tokens=1*" %%I in ('%sub%') do (set "par=%par%%q%%%I" & set "sub=%%J") - ) - - ::- Recursive search - for /d %%D in (%par%) do ( - call :remove %sub% %2%%D\ - ) -goto :remove_end -:remove_plain - set p=%2%1 - if not exist "%1" goto :remove_end - if not "%dryrun%" == "" ( - echo Removing %p:\=/% - goto :remove_end - ) - ::- Try `rd` first for symlink to a directory; `del` attemps to remove all - ::- files under the target directory, instead of the symlink itself. - (rd /q "%p%" || del /q "%p%") 2> nul && goto :remove_end - - if "%recursive%" == "-r" for /D %%I in (%p%) do ( - rd /s /q %%I || call set error=%%ERRORLEVEL%% - ) -:remove_end -endlocal & set "error=%error%" & goto :EOF +@echo off +@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 + +set prog=%~n0 +set dryrun= +set recursive= +set debug= +set error=0 +set parent= + +:optloop +if "%1" == "-f" shift +if "%1" == "-n" (shift & set "dryrun=%1" & goto :optloop) +if "%1" == "-r" (shift & set "recursive=%1" & goto :optloop) +if "%1" == "--debug" (shift & set "debug=%1" & set PROMPT=$E[34m+$E[m$S & echo on & goto :optloop) +:begin +if "%1" == "" goto :EOF + set p=%1 + shift + set p=%p:/=\% + call :remove %p% +goto :begin + +:remove +setlocal + +::- Split %1 by '?' and '*', wildcard characters +for /f "usebackq delims=?* tokens=1*" %%I in ('%1') do (set "par=%%I" & set "sub=%%J") +if "%sub%" == "" goto :remove_plain +if "%sub:\=%" == "%sub%" goto :remove_plain + ::- Extract the first wildcard + set "q=%1" + call set "q=%%q:%par%=%%" + set q=%q:~0,1% + + ::- `delims` chars at the beginning are removed in `for` + if "%sub:~0,1%" == "\" ( + set "sub=%sub:~1%" + set "par=%par%%q%" + ) else ( + for /f "usebackq delims=\\ tokens=1*" %%I in ('%sub%') do (set "par=%par%%q%%%I" & set "sub=%%J") + ) + + ::- Recursive search + for /d %%D in (%par%) do ( + call :remove %sub% %2%%D\ + ) +goto :remove_end +:remove_plain + set p=%2%1 + if not exist "%1" goto :remove_end + if not "%dryrun%" == "" ( + echo Removing %p:\=/% + goto :remove_end + ) + ::- Try `rd` first for symlink to a directory; `del` attemps to remove all + ::- files under the target directory, instead of the symlink itself. + (rd /q "%p%" || del /q "%p%") 2> nul && goto :remove_end + + if "%recursive%" == "-r" for /D %%I in (%p%) do ( + rd /s /q %%I || call set error=%%ERRORLEVEL%% + ) +:remove_end +endlocal & set "error=%error%" & goto :EOF diff --git a/win32/rmdirs.bat b/win32/rmdirs.bat index a1a97fde145c48..a8abebd3839051 100755 --- a/win32/rmdirs.bat +++ b/win32/rmdirs.bat @@ -1,34 +1,34 @@ -@echo off -@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 -set parents=1 -:optloop -if "%1" == "--debug" (shift & set PROMPT=$E[34m+$E[m$S & echo on & goto :optloop) -if "%1" == "-p" (shift & (set parents=1) & goto :optloop) -:begin -if "%1" == "" goto :end - set dir=%1 - shift - set dir=%dir:/=\% - :rmdirs - if /%dir:~-2%/ == /\./ set dir=%dir:~0,-2% - if not exist "%dir%\." goto :begin - if "%dir%" == "." goto :begin - if "%dir%" == ".." goto :begin - rd "%dir%" 2> nul || goto :begin - if "%parents%" == "" goto :begin - :trim_sep - if not /%dir:~-1%/ == /\/ goto :trim_base - set dir=%dir:~0,-1% - if not "%dir%" == "" goto :trim_sep - :trim_base - if /%dir:~-1%/ == /\/ goto :parent - set dir=%dir:~0,-1% - if not "%dir%" == "" goto :trim_base - :parent - set dir=%dir:~0,-1% - if "%dir%" == "" goto :begin - if "%dir:~-1%" == ":" goto :begin - goto :rmdirs -shift -goto :begin -:end +@echo off +@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 +set parents=1 +:optloop +if "%1" == "--debug" (shift & set PROMPT=$E[34m+$E[m$S & echo on & goto :optloop) +if "%1" == "-p" (shift & (set parents=1) & goto :optloop) +:begin +if "%1" == "" goto :end + set dir=%1 + shift + set dir=%dir:/=\% + :rmdirs + if /%dir:~-2%/ == /\./ set dir=%dir:~0,-2% + if not exist "%dir%\." goto :begin + if "%dir%" == "." goto :begin + if "%dir%" == ".." goto :begin + rd "%dir%" 2> nul || goto :begin + if "%parents%" == "" goto :begin + :trim_sep + if not /%dir:~-1%/ == /\/ goto :trim_base + set dir=%dir:~0,-1% + if not "%dir%" == "" goto :trim_sep + :trim_base + if /%dir:~-1%/ == /\/ goto :parent + set dir=%dir:~0,-1% + if not "%dir%" == "" goto :trim_base + :parent + set dir=%dir:~0,-1% + if "%dir%" == "" goto :begin + if "%dir:~-1%" == ":" goto :begin + goto :rmdirs +shift +goto :begin +:end diff --git a/win32/rtname.cmd b/win32/rtname.cmd index 1ac008ebf06d3c..b85c6a0c7c0d40 100755 --- a/win32/rtname.cmd +++ b/win32/rtname.cmd @@ -1,36 +1,36 @@ -@echo off -@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 -set rt= -set rtver= -set osver= -for /f "usebackq" %%I in (` - dumpbin -dependents %1 ^| - findstr -r -i -c:"\&2 - exit 1 -) -for %%I in ( - "PLATFORM = $(TARGET_OS)%osver%" - "RT = %rt%" - "RT_VER = %rtver%" -) do @( - echo %%~I -) +@echo off +@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 +set rt= +set rtver= +set osver= +for /f "usebackq" %%I in (` + dumpbin -dependents %1 ^| + findstr -r -i -c:"\&2 + exit 1 +) +for %%I in ( + "PLATFORM = $(TARGET_OS)%osver%" + "RT = %rt%" + "RT_VER = %rtver%" +) do @( + echo %%~I +) diff --git a/win32/vssetup.cmd b/win32/vssetup.cmd index 2bbfbf1384f27e..f9f49fb27687cd 100755 --- a/win32/vssetup.cmd +++ b/win32/vssetup.cmd @@ -1,56 +1,56 @@ -@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 -::- do not `echo off` that affects the called batch files - -::- check for vswhere -@set vswhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe -@if not exist "%vswhere%" ( - echo 1>&2 vswhere.exe not found - exit /b 1 -) - -::- find the latest build tool and its setup batch file. -@set VSDEVCMD= -@set VSDEV_ARGS= -@set where_opt= -@set arch= -:argloop -@(set arg=%1) & if defined arg (shift) else (goto :argend) - @if "%arg%" == "-prerelease" ( - set where_opt=-prerelease - goto :argloop - ) - @if /i "%arg%" == "-arch" ( - set arch=%1 - shift - goto :argloop - ) - @if /i "%arg:~0,6%" == "-arch=" ( - set arch=%arg:~6% - goto :argloop - ) - - @set VSDEV_ARGS=%VSDEV_ARGS% %arg% - @goto :argloop -:argend -@if defined VSDEV_ARGS set VSDEV_ARGS=%VSDEV_ARGS:~1% - -@for /f "delims=" %%I in ('"%vswhere%" -products * -latest -property installationPath %where_opt%') do @( - set VSDEVCMD=%%I\Common7\Tools\VsDevCmd.bat -) -@if not defined VSDEVCMD ( - echo 1>&2 Visual Studio not found - exit /b 1 -) - -::- default to the current processor. -@set host_arch=%PROCESSOR_ARCHITECTURE% -@if not defined arch set arch=%PROCESSOR_ARCHITECTURE% -::- `vsdevcmd.bat` requires arch names to be lowercase -@for %%i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do @( - call set arch=%%arch:%%i=%%i%% - call set host_arch=%%host_arch:%%i=%%i%% -) -@if "%arch%" == "x86_64" set arch=amd64 - -::- chain to `vsdevcmd.bat` -@(endlocal && "%VSDEVCMD%" -arch=%arch% -host_arch=%host_arch% %VSDEV_ARGS%) +@setlocal EnableExtensions DisableDelayedExpansion || exit /b -1 +::- do not `echo off` that affects the called batch files + +::- check for vswhere +@set vswhere=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe +@if not exist "%vswhere%" ( + echo 1>&2 vswhere.exe not found + exit /b 1 +) + +::- find the latest build tool and its setup batch file. +@set VSDEVCMD= +@set VSDEV_ARGS= +@set where_opt= +@set arch= +:argloop +@(set arg=%1) & if defined arg (shift) else (goto :argend) + @if "%arg%" == "-prerelease" ( + set where_opt=-prerelease + goto :argloop + ) + @if /i "%arg%" == "-arch" ( + set arch=%1 + shift + goto :argloop + ) + @if /i "%arg:~0,6%" == "-arch=" ( + set arch=%arg:~6% + goto :argloop + ) + + @set VSDEV_ARGS=%VSDEV_ARGS% %arg% + @goto :argloop +:argend +@if defined VSDEV_ARGS set VSDEV_ARGS=%VSDEV_ARGS:~1% + +@for /f "delims=" %%I in ('"%vswhere%" -products * -latest -property installationPath %where_opt%') do @( + set VSDEVCMD=%%I\Common7\Tools\VsDevCmd.bat +) +@if not defined VSDEVCMD ( + echo 1>&2 Visual Studio not found + exit /b 1 +) + +::- default to the current processor. +@set host_arch=%PROCESSOR_ARCHITECTURE% +@if not defined arch set arch=%PROCESSOR_ARCHITECTURE% +::- `vsdevcmd.bat` requires arch names to be lowercase +@for %%i in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do @( + call set arch=%%arch:%%i=%%i%% + call set host_arch=%%host_arch:%%i=%%i%% +) +@if "%arch%" == "x86_64" set arch=amd64 + +::- chain to `vsdevcmd.bat` +@(endlocal && "%VSDEVCMD%" -arch=%arch% -host_arch=%host_arch% %VSDEV_ARGS%) From a30831133604cc5cc4a96309bd909a8897e42a2f Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 26 Jan 2026 18:11:27 +0900 Subject: [PATCH 7/9] [ruby/rubygems] Removed unused deprecate loading https://github.com/ruby/rubygems/commit/e379022ed0 --- lib/rubygems/version.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb index 90fe1b3c24324a..f4f57d675522c5 100644 --- a/lib/rubygems/version.rb +++ b/lib/rubygems/version.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require_relative "deprecate" - ## # The Version class processes string versions into comparable # values. A version string should normally be a series of numbers From e410d938fa1b8474fd4763b9b8383defa7f1db3f Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Mon, 26 Jan 2026 19:40:36 +0900 Subject: [PATCH 8/9] Workround for directly loading Gem::Version --- lib/rubygems/version.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb index f4f57d675522c5..091858b7570e79 100644 --- a/lib/rubygems/version.rb +++ b/lib/rubygems/version.rb @@ -150,6 +150,9 @@ # For the last example, single-digit versions are automatically extended with # a zero to give a sensible result. +# Workaround for directly loading Gem::Version in some cases +module Gem; end + class Gem::Version include Comparable From 5f254209184f4bcddc3155a85da7dc970f5708bf Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Mon, 26 Jan 2026 12:16:34 +0100 Subject: [PATCH 9/9] [ruby/prism] Fix `on_words_sep` for ripper translator with newlines Ripper emits a token each per line. https://github.com/ruby/prism/commit/4b5c9f5437 --- lib/prism/lex_compat.rb | 9 +++++++++ lib/prism/lex_ripper.rb | 7 ------- test/prism/ruby/ripper_test.rb | 8 -------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/lib/prism/lex_compat.rb b/lib/prism/lex_compat.rb index 0d78023ebab46d..775be2759ad722 100644 --- a/lib/prism/lex_compat.rb +++ b/lib/prism/lex_compat.rb @@ -657,6 +657,15 @@ def result IgnoreStateToken.new([[lineno, column], event, value, lex_state]) when :on_embexpr_end IgnoreStateToken.new([[lineno, column], event, value, lex_state]) + when :on_words_sep + # Ripper emits one token each per line. + lines = value.lines + lines[0...-1].each do |whitespace| + tokens << Token.new([[lineno, column], event, whitespace, lex_state]) + lineno += 1 + column = 0 + end + Token.new([[lineno, column], event, lines.last, lex_state]) when :on_regexp_end # On regex end, Ripper scans and then sets end state, so the ripper # lexed output is begin, when it should be end. prism sets lex state diff --git a/lib/prism/lex_ripper.rb b/lib/prism/lex_ripper.rb index 2054cf55ac0c70..f069e50ba9aa77 100644 --- a/lib/prism/lex_ripper.rb +++ b/lib/prism/lex_ripper.rb @@ -26,13 +26,6 @@ def result results << token previous = token end - when :on_words_sep - if previous[1] == :on_words_sep - previous[2] << token[2] - else - results << token - previous = token - end else results << token previous = token diff --git a/test/prism/ruby/ripper_test.rb b/test/prism/ruby/ripper_test.rb index 6e9dcee4c9c26a..c8d259135f47cc 100644 --- a/test/prism/ruby/ripper_test.rb +++ b/test/prism/ruby/ripper_test.rb @@ -62,18 +62,10 @@ class RipperTest < TestCase ] omitted_lex = [ - "comments.txt", - "heredoc_percent_q_newline_delimiter.txt", "heredoc_with_escaped_newline_at_start.txt", "heredocs_with_fake_newlines.txt", "indented_file_end.txt", - "seattlerb/TestRubyParserShared.txt", - "seattlerb/class_comments.txt", - "seattlerb/module_comments.txt", - "seattlerb/parse_line_block_inline_comment_leading_newlines.txt", - "seattlerb/parse_line_block_inline_multiline_comment.txt", "spanning_heredoc_newlines.txt", - "strings.txt", "whitequark/dedenting_heredoc.txt", "whitequark/procarg0.txt", ]