summaryrefslogtreecommitdiff
path: root/tool/mkconfig.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-04-15 12:49:06 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-04-15 14:55:22 +0900
commitfd978621ccbc9519afc05ad031ba2518e9a6f379 (patch)
treee25c1ae9834a797c7be749ab1e5881d5fc695d20 /tool/mkconfig.rb
parentdf0f60b690b131810de3dd1603e5bebc7f438903 (diff)
downloadruby-fd978621ccbc9519afc05ad031ba2518e9a6f379.tar.gz
mkconfig.rb: Update around SDKROOT
c.f. https://opensource.apple.com/source/ruby/ruby-145.40.1/patches/tool_mkconfig.rb.diff * moved to "includedir" from "oldincludedir". * honor "$(prefix)/include" if exists, otherwise fallback to `xcrun`.
Diffstat (limited to 'tool/mkconfig.rb')
-rwxr-xr-xtool/mkconfig.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb
index cd42661661..6db60724e9 100755
--- a/tool/mkconfig.rb
+++ b/tool/mkconfig.rb
@@ -124,7 +124,7 @@ File.foreach "config.status" do |line|
if universal
platform = val.sub(/universal/, %q[#{arch && universal[/(?:\A|\s)#{Regexp.quote(arch)}=(\S+)/, 1] || RUBY_PLATFORM[/\A[^-]*/]}])
end
- when /^oldincludedir$/
+ when /^includedir$/
val = '"$(SDKROOT)"'+val if /darwin/ =~ arch
end
v = " CONFIG[\"#{name}\"] #{eq} #{val}\n"
@@ -269,7 +269,15 @@ print <<EOS if $unicode_emoji_version
CONFIG["UNICODE_EMOJI_VERSION"] = #{$unicode_emoji_version.dump}
EOS
print <<EOS if /darwin/ =~ arch
- CONFIG["SDKROOT"] = "\#{ENV['SDKROOT']}" # don't run xcrun every time, usually useless.
+ if sdkroot = ENV["SDKROOT"]
+ sdkroot = sdkroot.dup
+ elsif File.exist?(File.join(CONFIG["prefix"], "include")) ||
+ !(sdkroot = (IO.popen(%w[/usr/bin/xcrun --sdk macosx --show-sdk-path], in: IO::NULL, err: IO::NULL, &:read) rescue nil))
+ sdkroot = +""
+ else
+ sdkroot.chomp!
+ end
+ CONFIG["SDKROOT"] = sdkroot
EOS
print <<EOS
CONFIG["platform"] = #{platform || '"$(arch)"'}