[前][次][番号順一覧][スレッド一覧]

ruby-changes:74347

From: Nobuyoshi <ko1@a...>
Date: Fri, 4 Nov 2022 18:08:16 +0900 (JST)
Subject: [ruby-changes:74347] cb18deee72 (master): Substitute from the actual netinet6/in6.h

https://git.ruby-lang.org/ruby.git/commit/?id=cb18deee72

From cb18deee7285dde67102c9702796d7eba0046af5 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Fri, 4 Nov 2022 17:38:28 +0900
Subject: Substitute from the actual netinet6/in6.h

Xcode no longer links the system include files directory to `/usr`.
Extract the actual header file path from cpp output.
---
 ext/socket/extconf.rb | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index b70a862414..8998bb5c2f 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -655,12 +655,20 @@ EOS https://github.com/ruby/ruby/blob/trunk/ext/socket/extconf.rb#L655
   end
 
   hdr = "netinet6/in6.h"
-  if /darwin/ =~ RUBY_PLATFORM and !try_compile(<<"SRC", nil, :werror=>true)
+  /darwin/ =~ RUBY_PLATFORM and
+  checking_for("if apple's #{hdr} needs s6_addr patch") {!try_compile(<<"SRC", nil, :werror=>true)} and
 #include <netinet/in.h>
 int t(struct in6_addr *addr) {return IN6_IS_ADDR_UNSPECIFIED(addr);}
 SRC
-    print "fixing apple's netinet6/in6.h ..."; $stdout.flush
-    in6 = File.read("/usr/include/#{hdr}")
+  checking_for("fixing apple's #{hdr}", "%s") do
+    file = xpopen(%w"clang -include netinet/in.h -E -xc -", in: IO::NULL) do |f|
+      re = %r[^# *\d+ *"(.*/netinet/in\.h)"]
+      Logging.message "  grep(#{re})\n"
+      f.read[re, 1]
+    end
+    Logging.message "Substitute from #{file}\n"
+
+    in6 = File.read(file)
     if in6.gsub!(/\*\(const\s+__uint32_t\s+\*\)\(const\s+void\s+\*\)\(&(\(\w+\))->s6_addr\[(\d+)\]\)/) do
         i, r = $2.to_i.divmod(4)
         if r.zero?
@@ -673,9 +681,9 @@ SRC https://github.com/ruby/ruby/blob/trunk/ext/socket/extconf.rb#L681
       open(hdr, "w") {|f| f.write(in6)}
       $distcleanfiles << hdr
       $distcleandirs << File.dirname(hdr)
-      puts "done"
+      "done"
     else
-      puts "not needed"
+      "not needed"
     end
   end
   create_makefile("socket")
-- 
cgit v1.2.3


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]