From e109400748a62f142d0b1ca6957dab69ca411de1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 27 Dec 2024 16:26:14 +0900 Subject: [PATCH] Win32: Fix sub make commands `cmd.exe` built-in `cd` does not recognize slashes as path separators, replace to backslashes. --- ext/extmk.rb | 6 +++--- template/exts.mk.tmpl | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ext/extmk.rb b/ext/extmk.rb index 8b6b365a99..30ae56e095 100755 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -817,9 +817,9 @@ begin if $gnumake == "yes" submake = "$(MAKE) -C $(@D)" else - submake = "cd $(@D) && " - config_string("exec") {|str| submake << str << " "} - submake << "$(MAKE)" + submake = ["cd", (sep ? "$(@D:/=#{sep})" : "$(@D)"), "&&"] + config_string("exec") {|str| submake << str} + submake = (submake << "$(MAKE)").join(" ") end targets.each do |tgt| exts.each do |d| diff --git a/template/exts.mk.tmpl b/template/exts.mk.tmpl index 0abbca1f06..e482808f54 100644 --- a/template/exts.mk.tmpl +++ b/template/exts.mk.tmpl @@ -110,12 +110,14 @@ def self.column w end objext = RbConfig::CONFIG["OBJEXT"] +sep = RbConfig::CONFIG['BUILD_FILE_SEPARATOR'] +sep = nil if sep and sep.empty? if gnumake submake = "$(MAKE) -C $(@D)" else - submake = "cd $(@D) && " - exec = RbConfig::CONFIG["exec"] and !exec.empty? and submake << exec << " " - submake << "$(MAKE)" + submake = ["cd", (sep ? "$(@D:/=#{sep})" : "$(@D)"), "&&"] + exec = RbConfig::CONFIG["exec"] and !exec.empty? and submake << exec + submake = (submake << "$(MAKE)").join(" ") mflags = " $(MFLAGS)" end -%>