std.Build: make systemIntegrationOption take a default

This commit is contained in:
Andrew Kelley 2024-02-01 23:04:23 -07:00
parent ed4ccea7ba
commit a68defbc65

View File

@ -2356,7 +2356,16 @@ pub fn wantSharedLibSymLinks(target: Target) bool {
return target.os.tag != .windows;
}
pub fn systemIntegrationOption(b: *Build, name: []const u8) bool {
pub const SystemIntegrationOptionConfig = struct {
/// If left as null, then the default will depend on system_package_mode.
default: ?bool = null,
};
pub fn systemIntegrationOption(
b: *Build,
name: []const u8,
config: SystemIntegrationOptionConfig,
) bool {
const gop = b.graph.system_library_options.getOrPut(b.allocator, name) catch @panic("OOM");
if (gop.found_existing) switch (gop.value_ptr.*) {
.user_disabled => {
@ -2371,7 +2380,7 @@ pub fn systemIntegrationOption(b: *Build, name: []const u8) bool {
.declared_enabled => return true,
} else {
gop.key_ptr.* = b.dupe(name);
if (b.graph.system_package_mode) {
if (config.default orelse b.graph.system_package_mode) {
gop.value_ptr.* = .declared_enabled;
return true;
} else {