cleanup processPkgConfig
This commit is contained in:
parent
137edcd527
commit
58d8c1434d
@ -150,9 +150,7 @@ fn processIncludeDirs(
|
|||||||
else => continue,
|
else => continue,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (include_dirs.contains(candidate)) continue;
|
include_dirs.putAssumeCapacity(candidate, {});
|
||||||
|
|
||||||
include_dirs.putAssumeCapacityNoClobber(candidate, {});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,20 +160,12 @@ fn processPkgConfig(
|
|||||||
exe: *std.build.LibExeObjStep,
|
exe: *std.build.LibExeObjStep,
|
||||||
) !void {
|
) !void {
|
||||||
for (exe.link_objects.items) |link_object| {
|
for (exe.link_objects.items) |link_object| {
|
||||||
switch (link_object) {
|
if (link_object != .system_lib) continue;
|
||||||
.system_lib => |system_lib| {
|
const system_lib = link_object.system_lib;
|
||||||
switch (system_lib.use_pkg_config) {
|
|
||||||
.no => {},
|
if (system_lib.use_pkg_config == .no) continue;
|
||||||
.yes, .force => {
|
|
||||||
if (exe.runPkgConfig(system_lib.name)) |args| {
|
getPkgConfigIncludes(allocator, include_dirs, exe, system_lib.name) catch |err| switch (err) {
|
||||||
for (args) |arg| {
|
|
||||||
if (std.mem.startsWith(u8, arg, "-I")) {
|
|
||||||
const candidate = arg[2..];
|
|
||||||
if (include_dirs.contains(candidate)) continue;
|
|
||||||
try include_dirs.putNoClobber(allocator, candidate, {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else |err| switch (err) {
|
|
||||||
error.PkgConfigInvalidOutput,
|
error.PkgConfigInvalidOutput,
|
||||||
error.PkgConfigCrashed,
|
error.PkgConfigCrashed,
|
||||||
error.PkgConfigFailed,
|
error.PkgConfigFailed,
|
||||||
@ -190,15 +180,25 @@ fn processPkgConfig(
|
|||||||
},
|
},
|
||||||
.no => unreachable,
|
.no => unreachable,
|
||||||
},
|
},
|
||||||
|
|
||||||
else => |e| return e,
|
else => |e| return e,
|
||||||
}
|
};
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
else => {},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn getPkgConfigIncludes(
|
||||||
|
allocator: std.mem.Allocator,
|
||||||
|
include_dirs: *std.StringArrayHashMapUnmanaged(void),
|
||||||
|
exe: *std.build.LibExeObjStep,
|
||||||
|
name: []const u8,
|
||||||
|
) !void {
|
||||||
|
if (exe.runPkgConfig(name)) |args| {
|
||||||
|
for (args) |arg| {
|
||||||
|
if (std.mem.startsWith(u8, arg, "-I")) {
|
||||||
|
const candidate = arg[2..];
|
||||||
|
try include_dirs.put(allocator, candidate, {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else |err| return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn runBuild(builder: *Builder) anyerror!void {
|
fn runBuild(builder: *Builder) anyerror!void {
|
||||||
|
Loading…
Reference in New Issue
Block a user