authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-01 23:04:23-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-02-02 20:43:01-07:00
loga68defbc6559647d23862daa59d5c1f9a64e34e3
tree666b44793fd584e6cee7bbade8304768cc72a939
parented4ccea7bae99c1baa634716941f308d9f922985

std.Build: make systemIntegrationOption take a default


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

lib/std/Build.zig+11-2
......@@ -2356,7 +2356,16 @@ pub fn wantSharedLibSymLinks(target: Target) bool {
23562356 return target.os.tag != .windows;
23572357}
23582358
2359pub fn systemIntegrationOption(b: *Build, name: []const u8) bool {
2359pub const SystemIntegrationOptionConfig = struct {
2360 /// If left as null, then the default will depend on system_package_mode.
2361 default: ?bool = null,
2362};
2363
2364pub fn systemIntegrationOption(
2365 b: *Build,
2366 name: []const u8,
2367 config: SystemIntegrationOptionConfig,
2368) bool {
23602369 const gop = b.graph.system_library_options.getOrPut(b.allocator, name) catch @panic("OOM");
23612370 if (gop.found_existing) switch (gop.value_ptr.*) {
23622371 .user_disabled => {
......@@ -2371,7 +2380,7 @@ pub fn systemIntegrationOption(b: *Build, name: []const u8) bool {
23712380 .declared_enabled => return true,
23722381 } else {
23732382 gop.key_ptr.* = b.dupe(name);
2374 if (b.graph.system_package_mode) {
2383 if (config.default orelse b.graph.system_package_mode) {
23752384 gop.value_ptr.* = .declared_enabled;
23762385 return true;
23772386 } else {