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

ruby-changes:69952

From: Nobuyoshi <ko1@a...>
Date: Fri, 26 Nov 2021 22:32:43 +0900 (JST)
Subject: [ruby-changes:69952] dff8d12226 (master): mkmf: take `PKG_CONFIG_PATH` from `dir_config` library path

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

From dff8d12226088f07435d81b570cc9731b10c0da9 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Fri, 26 Nov 2021 20:55:21 +0900
Subject: mkmf: take `PKG_CONFIG_PATH` from `dir_config` library path

So that version dependent pkg-config files can override files in
the default locations.
---
 lib/mkmf.rb | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 6cc455424e7..52788ab3abc 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -1856,16 +1856,24 @@ SRC https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L1856
   # invoked with the option and a stripped output string is returned
   # without modifying any of the global values mentioned above.
   def pkg_config(pkg, option=nil)
+    _, ldir = dir_config(pkg)
+    if ldir
+      pkg_config_path = "#{ldir}/pkgconfig"
+      if File.directory?(pkg_config_path)
+        Logging.message("PKG_CONFIG_PATH = %s\n", pkg_config_path)
+        envs = ["PKG_CONFIG_PATH"=>[pkg_config_path, ENV["PKG_CONFIG_PATH"]].compact.join(File::PATH_SEPARATOR)]
+      end
+    end
     if pkgconfig = with_config("#{pkg}-config") and find_executable0(pkgconfig)
       # if and only if package specific config command is given
     elsif ($PKGCONFIG ||=
            (pkgconfig = with_config("pkg-config", ("pkg-config" unless CROSS_COMPILING))) &&
            find_executable0(pkgconfig) && pkgconfig) and
-        xsystem("#{$PKGCONFIG} --exists #{pkg}")
+        xsystem([*envs, $PKGCONFIG, "--exists", pkg])
       # default to pkg-config command
       pkgconfig = $PKGCONFIG
       get = proc {|opt|
-        opt = xpopen("#{$PKGCONFIG} --#{opt} #{pkg}", err:[:child, :out], &:read)
+        opt = xpopen([*envs, $PKGCONFIG, "--#{opt}", pkg], err:[:child, :out], &:read)
         Logging.open {puts opt.each_line.map{|s|"=> #{s.inspect}"}}
         opt.strip if $?.success?
       }
@@ -1876,7 +1884,7 @@ SRC https://github.com/ruby/ruby/blob/trunk/lib/mkmf.rb#L1884
     end
     if pkgconfig
       get ||= proc {|opt|
-        opt = xpopen("#{pkgconfig} --#{opt}", err:[:child, :out], &:read)
+        opt = xpopen([*envs, pkgconfig, "--#{opt}"], err:[:child, :out], &:read)
         Logging.open {puts opt.each_line.map{|s|"=> #{s.inspect}"}}
         opt.strip if $?.success?
       }
-- 
cgit v1.2.1


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

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