-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13717 from GethDW/option-fix
std.build.Builder: fix for Allocator changes
- Loading branch information
Showing
5 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const std = @import("std"); | ||
|
||
pub fn build(b: *std.build.Builder) void { | ||
const target = b.standardTargetOptions(.{}); | ||
const mode = b.standardReleaseOptions(); | ||
|
||
const main = b.addTest("src/main.zig"); | ||
main.setTarget(target); | ||
main.setBuildMode(mode); | ||
|
||
const options = b.addOptions(); | ||
main.addOptions("build_options", options); | ||
options.addOption(bool, "bool_true", b.option(bool, "bool_true", "t").?); | ||
options.addOption(bool, "bool_false", b.option(bool, "bool_false", "f").?); | ||
options.addOption(u32, "int", b.option(u32, "int", "i").?); | ||
const E = enum { one, two, three }; | ||
options.addOption(E, "e", b.option(E, "e", "e").?); | ||
options.addOption([]const u8, "string", b.option([]const u8, "string", "s").?); | ||
|
||
const test_step = b.step("test", "Run unit tests"); | ||
test_step.dependOn(&main.step); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const std = @import("std"); | ||
const assert = std.debug.assert; | ||
|
||
const build_options = @import("build_options"); | ||
|
||
test "build options" { | ||
comptime assert(build_options.bool_true); | ||
comptime assert(!build_options.bool_false); | ||
comptime assert(build_options.int == 1234); | ||
comptime assert(build_options.e == .two); | ||
comptime assert(std.mem.eql(u8, build_options.string, "hello")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters