Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/pkg-config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@ def compute_native_pkg_config_prefix
end

def compute_default_path
libdir = ENV["PKG_CONFIG_LIBDIR"]
if libdir
return [
with_config("pkg-config-path") || ENV["PKG_CONFIG_PATH"],
libdir,
].compact.join(SEPARATOR)
end

default_paths = nil
if native_pkg_config
pc_path = run_command(native_pkg_config.to_s,
Expand Down Expand Up @@ -315,9 +323,6 @@ def compute_default_path
mingw_pkgconfig_path = Pathname.new(mingw_bin_path) + "../lib/pkgconfig"
default_paths.unshift(mingw_pkgconfig_path.cleanpath.to_s)
end
libdir = ENV["PKG_CONFIG_LIBDIR"]
default_paths.unshift(libdir) if libdir

paths = []
if /-darwin\d[\d\.]*\z/ =~ RUBY_PLATFORM and
/\A(\d+\.\d+)/ =~ run_command("sw_vers", "-productVersion")
Expand Down
15 changes: 15 additions & 0 deletions test/test-pkg-config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ def setup
@glib = PackageConfig.new("glib-2.0", options)
end

def test_explicit_libdir_replaces_default_paths
original_libdir = ENV["PKG_CONFIG_LIBDIR"]
original_path = ENV["PKG_CONFIG_PATH"]
ENV["PKG_CONFIG_LIBDIR"] = "/isolated/pkgconfig"
ENV["PKG_CONFIG_PATH"] = "/extra/pkgconfig"
assert_equal([
"/extra/pkgconfig",
"/isolated/pkgconfig",
].join(File::PATH_SEPARATOR),
PackageConfig.__send__(:compute_default_path))
ensure
ENV["PKG_CONFIG_LIBDIR"] = original_libdir
ENV["PKG_CONFIG_PATH"] = original_path
end

def only_pkg_config_version(major, minor)
pkg_config_version = `#{@pkgconf} --version`.chomp
current_major, current_minor = pkg_config_version.split(".").collect(&:to_i)
Expand Down