Skip to content

Support conditional default values for options based on optimize mode #3

@GrapeBaBa

Description

@GrapeBaBa

Summary
Add support for conditional/dynamic default values in options_modules that can depend on build-time variables like optimize mode.

Use Case
I have a leak_detection_level option that should default to different values based on the optimization mode:

"paranoid" in Debug mode (for development)
"disabled" in Release mode (for production)
Currently, I need to manually edit the generated build.zig after each zbuild sync to add this logic:

const default_leak_level: []const u8 = if (optimize == .Debug) "paranoid" else "disabled";
const option_leak_detection_level = b.option([]const u8, "leak_detection_level", "...") orelse default_leak_level;

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions