authorgravatar for jay@jayschwa.netJay Petacat <jay@jayschwa.net> 2024-11-25 00:01:36-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-11-29 15:11:14-05:00
log97b8d662e63ae90bc7b8bb29221e8b79bca5bfbe
treeb9caad8d43aab8648380fc4ee1b7e630f10044ec
parentcfdb001a8f0353466a4445cc046341ce9cc43fc5

std.Build: Detect `pkg-config` names with "lib" prefix


1 files changed, 7 insertions(+), 5 deletions(-)

lib/std/Build/Step/Compile.zig+7-5
...@@ -695,6 +695,7 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {...@@ -695,6 +695,7 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
695 // -lSDL2 -> pkg-config sdl2695 // -lSDL2 -> pkg-config sdl2
696 // -lgdk-3 -> pkg-config gdk-3.0696 // -lgdk-3 -> pkg-config gdk-3.0
697 // -latk-1.0 -> pkg-config atk697 // -latk-1.0 -> pkg-config atk
698 // -lpulse -> pkg-config libpulse
698 const pkgs = try getPkgConfigList(b);699 const pkgs = try getPkgConfigList(b);
699700
700 // Exact match means instant winner.701 // Exact match means instant winner.
...@@ -711,13 +712,14 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {...@@ -711,13 +712,14 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8) !PkgConfigResult {
711 }712 }
712 }713 }
713714
714 // Now try appending ".0".715 // Prefixed "lib" or suffixed ".0".
715 for (pkgs) |pkg| {716 for (pkgs) |pkg| {
716 if (std.ascii.indexOfIgnoreCase(pkg.name, lib_name)) |pos| {717 if (std.ascii.indexOfIgnoreCase(pkg.name, lib_name)) |pos| {
717 if (pos != 0) continue;718 const prefix = pkg.name[0..pos];
718 if (mem.eql(u8, pkg.name[lib_name.len..], ".0")) {719 const suffix = pkg.name[pos + lib_name.len ..];
719 break :match pkg.name;720 if (prefix.len > 0 and !mem.eql(u8, prefix, "lib")) continue;
720 }721 if (suffix.len > 0 and !mem.eql(u8, suffix, ".0")) continue;
722 break :match pkg.name;
721 }723 }
722 }724 }
723725