From: Kouhei S. <nu...@co...> - 2017-08-13 11:21:18
|
Kouhei Sutou 2017-08-13 20:20:39 +0900 (Sun, 13 Aug 2017) New Revision: 5f12c2a9b8409b8016fc9b614f70200cced42d80 https://github.com/ruby-gnome2/pkg-config/commit/5f12c2a9b8409b8016fc9b614f70200cced42d80 Message: Improve Homebrew repository path detection Modified files: lib/pkg-config.rb Modified: lib/pkg-config.rb (+14 -3) =================================================================== --- lib/pkg-config.rb 2017-08-10 23:47:58 +0900 (7985bd1) +++ lib/pkg-config.rb 2017-08-13 20:20:39 +0900 (f1ff34a) @@ -376,9 +376,20 @@ class PackageConfig if /-darwin\d+\z/ =~ RUBY_PLATFORM and /\A(\d+\.\d+)\./ =~ `sw_vers -productVersion` mac_os_version = $1 - path = pkg_config_prefix + - "Library/Homebrew/os/mac/pkgconfig/#{mac_os_version}" - paths << path.to_s if path.exist? + homebrew_repository_candidates = [] + brew_path = pkg_config_prefix + "bin" + "brew" + if brew_path.exist? + escaped_brew_path = Shellwords.escape(brew_path.to_s) + homebrew_repository = `#{escaped_brew_path} --repository`.chomp + homebrew_repository_candidates << Pathname.new(homebrew_repository) + else + homebrew_repository_candidates << pkg_config_prefix + "Homebrew" + homebrew_repository_candidates << pkg_config_prefix + end + homebrew_repository_candidates.each do |candidate| + path = candidate + "Library/Homebrew/os/mac/pkgconfig/#{mac_os_version}" + paths << path.to_s if path.exist? + end end paths.concat(default_paths) paths.join(SEPARATOR) |