36 lines
878 B
Zig
36 lines
878 B
Zig
// the module startup system.
|
|
|
|
const std = @import("std");
|
|
const core = @import("core.zig");
|
|
|
|
// a series of comptime functions for letting you select which features are compiled and brought
|
|
// into the engine.
|
|
|
|
pub const ModuleDescription = struct {
|
|
name: []const u8,
|
|
enabledByDefault: bool,
|
|
};
|
|
|
|
pub fn isModuleEnabled(comptime module: ModuleDescription, spec: *core.SpecVariantMap) bool {
|
|
if (spec.get(module.name)) |x| {
|
|
return x.boolean;
|
|
} else {
|
|
return module.enabledByDefault;
|
|
}
|
|
}
|
|
|
|
test "isModule in build test" {
|
|
const ModA = ModuleDescription{
|
|
.name = "featureA",
|
|
.enabledByDefault = false,
|
|
};
|
|
|
|
const buildDesc: struct {
|
|
enabledModules: struct {
|
|
featureA: bool = true,
|
|
} = .{},
|
|
} = .{};
|
|
|
|
std.debug.print("modA enabled = {any}\n", .{isModuleEnabled(ModA, buildDesc)});
|
|
}
|