authorgravatar for bratishkaerik@landless-city.netEric Joldasov <bratishkaerik@landless-city.net> 2024-05-08 23:21:34+05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-21 02:32:33-07:00
logd263f1ec0eb988f0e4ed1859351f5040f590996b
tree4e08c9468589455827c721c1bfcf8620135475c7
parentc746d7a35d6ba26d783863ef8fa86123891e1d38

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 <bratishkaerik@landless-city.net>

1 files changed, 4 insertions(+), 2 deletions(-)

lib/std/Build/Step/Compile.zig+4-2
......@@ -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
18541855fn 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");