Skip to content

Commit

Permalink
Add support for pkgconf
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Nov 21, 2024
1 parent aa5460b commit fd2c892
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
brew "cairo"
brew "pkgconf"
29 changes: 18 additions & 11 deletions lib/pkg-config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,25 @@ def with_config(config, default=nil)

def guess_native_pkg_config
exeext = RbConfig::CONFIG["EXEEXT"]
default_pkg_config = ENV["PKG_CONFIG"] || "pkg-config#{exeext}"
pkg_config = with_config("pkg-config", default_pkg_config)
pkg_config = Pathname.new(pkg_config)
unless pkg_config.absolute?
found_pkg_config = search_executable_from_path(pkg_config)
pkg_config = found_pkg_config if found_pkg_config
end
unless pkg_config.absolute?
found_pkg_config = search_pkg_config_by_dln_find_exe(pkg_config)
pkg_config = found_pkg_config if found_pkg_config
candidates = [
with_config("pkg-config"),
ENV["PKG_CONFIG"],
"pkgconf#{exeext}",
"pkg-config#{exeext}",
].compact
candidates.each do |pkg_config|
pkg_config = Pathname.new(pkg_config)
return pkg_config if pkg_config.absolute? and pkg_config.exist?
unless pkg_config.absolute?
found_pkg_config = search_executable_from_path(pkg_config)
return found_pkg_config if found_pkg_config
end
unless pkg_config.absolute?
found_pkg_config = search_pkg_config_by_dln_find_exe(pkg_config)
return found_pkg_config if found_pkg_config
end
end
pkg_config
Pathname.new(candidates[0])
end

def search_executable_from_path(name)
Expand Down

0 comments on commit fd2c892

Please sign in to comment.