Source
pub fn addUserInputFlag(b: *Build, name_raw: []const u8) error{OutOfMemory}!bool {
const name = b.dupe(name_raw);
const gop = try b.user_input_options.getOrPut(name);
if (!gop.found_existing) {
gop.value_ptr.* = .{
.name = name,
.value = .{ .flag = {} },
.used = false,
};
return false;
}
// option already exists
switch (gop.value_ptr.value) {
.scalar => |s| {
log.err("Flag '-D{s}' conflicts with option '-D{s}={s}'.", .{ name, name, s });
return true;
},
.list, .map, .lazy_path_list => {
log.err("Flag '-D{s}' conflicts with multiple options of the same name.", .{name});
return true;
},
.lazy_path => |lp| {
log.err("Flag '-D{s}' conflicts with option '-D{s}={s}'.", .{ name, name, lp.getDisplayName() });
return true;
},
.flag => {},
}
return false;
}