Skip to content

Commit d263f1e

Browse files
BratishkaErikandrewrk
authored andcommitted
zig build: respect PKG_CONFIG environment variable
`PKG_CONFIG` environment variable is used to override path to pkg-config executable, for example when it's name is prepended by target triple for cross-compilation purposes: ``` PKG_CONFIG=/usr/bin/aarch64-unknown-linux-gnu-pkgconf zig build ``` Signed-off-by: Eric Joldasov <[email protected]>
1 parent c746d7a commit d263f1e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/std/Build/Step/Compile.zig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,9 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
707707
};
708708

709709
var code: u8 = undefined;
710+
const pkg_config_exe = b.graph.env_map.get("PKG_CONFIG") orelse "pkg-config";
710711
const stdout = if (b.runAllowFail(&[_][]const u8{
711-
"pkg-config",
712+
pkg_config_exe,
712713
pkg_name,
713714
"--cflags",
714715
"--libs",
@@ -1852,7 +1853,8 @@ pub fn doAtomicSymLinks(
18521853
}
18531854

18541855
fn execPkgConfigList(compile: *std.Build, out_code: *u8) (PkgConfigError || RunError)![]const PkgConfigPkg {
1855-
const stdout = try compile.runAllowFail(&[_][]const u8{ "pkg-config", "--list-all" }, out_code, .Ignore);
1856+
const pkg_config_exe = compile.graph.env_map.get("PKG_CONFIG") orelse "pkg-config";
1857+
const stdout = try compile.runAllowFail(&[_][]const u8{ pkg_config_exe, "--list-all" }, out_code, .Ignore);
18561858
var list = ArrayList(PkgConfigPkg).init(compile.allocator);
18571859
errdefer list.deinit();
18581860
var line_it = mem.tokenizeAny(u8, stdout, "\r\n");

0 commit comments

Comments
 (0)