Module: Rubycc::Pkgconf::SearchPath

Defined in:
lib/rubycc/pkgconf/search_path.rb

Overview

Where a <name>.pc is looked up when nothing else says otherwise.

Constant Summary collapse

DEFAULT_DIRECTORIES =

The multiarch directory comes first because that is where this environment's real .pc files actually live (/usr/lib/x86_64-linux-gnu/pkgconfig/zlib,libffi,openssl,....pc — see the Step 59 report); /usr/lib/pkgconfig and /usr/share/pkgconfig are the architecture-independent locations pkg-config falls back to next on a Debian/Ubuntu multiarch system.

[
  "/usr/lib/x86_64-linux-gnu/pkgconfig",
  "/usr/lib/pkgconfig",
  "/usr/share/pkgconfig"
].freeze

Class Method Summary collapse

Class Method Details

.directories(env = ENV) ⇒ Object

PKG_CONFIG_PATH (colon-separated, mirroring PATH) is searched before the defaults — the same precedence mkmf's own pkg_config() relies on when dir_config found a --with-*-dir libdir and set PKG_CONFIG_PATH to that libdir's pkgconfig/ subdirectory before invoking pkg-config.



23
24
25
26
# File 'lib/rubycc/pkgconf/search_path.rb', line 23

def self.directories(env = ENV)
  extra = (env["PKG_CONFIG_PATH"] || "").split(File::PATH_SEPARATOR).reject(&:empty?)
  extra + DEFAULT_DIRECTORIES
end

.find(name, directories: directories()) ⇒ Object

The first <name>.pc found across directories, or nil.



29
30
31
32
33
34
35
# File 'lib/rubycc/pkgconf/search_path.rb', line 29

def self.find(name, directories: directories())
  directories.each do |dir|
    path = File.join(dir, "#{name}.pc")
    return path if File.file?(path)
  end
  nil
end