| author | |
| committer | |
| log | a943422672a9f456a74c20b4c167107ccbadfb1a |
| tree | 2dcfbbb91fe3683aee9dfea748c3e373f211c134 |
| parent | 94e751ad013915b7b2d8dbfdd0d708fe9f56f087 |
| parent | b1793c2b524b4d2e740c130d92ab9499c2b34152 |
| signature |
std.build.Builder: fix for Allocator changes5 files changed, 49 insertions(+), 1 deletions(-)
lib/std/build.zig+1-1| ... | @@ -532,7 +532,7 @@ pub const Builder = struct { | ... | @@ -532,7 +532,7 @@ pub const Builder = struct { |
| 532 | options.appendAssumeCapacity(field.name); | 532 | options.appendAssumeCapacity(field.name); |
| 533 | } | 533 | } |
| 534 | 534 | ||
| 535 | break :blk options.toOwnedSlice(); | 535 | break :blk options.toOwnedSlice() catch unreachable; |
| 536 | } else null; | 536 | } else null; |
| 537 | const available_option = AvailableOption{ | 537 | const available_option = AvailableOption{ |
| 538 | .name = name, | 538 | .name = name, |
test/standalone.zig+11| ... | @@ -5,6 +5,17 @@ const tests = @import("tests.zig"); | ... | @@ -5,6 +5,17 @@ const tests = @import("tests.zig"); |
| 5 | pub fn addCases(cases: *tests.StandaloneContext) void { | 5 | pub fn addCases(cases: *tests.StandaloneContext) void { |
| 6 | cases.add("test/standalone/hello_world/hello.zig"); | 6 | cases.add("test/standalone/hello_world/hello.zig"); |
| 7 | cases.addC("test/standalone/hello_world/hello_libc.zig"); | 7 | cases.addC("test/standalone/hello_world/hello_libc.zig"); |
| 8 | |||
| 9 | cases.addBuildFile("test/standalone/options/build.zig", .{ | ||
| 10 | .extra_argv = &.{ | ||
| 11 | "-Dbool_true", | ||
| 12 | "-Dbool_false=false", | ||
| 13 | "-Dint=1234", | ||
| 14 | "-De=two", | ||
| 15 | "-Dstring=hello", | ||
| 16 | }, | ||
| 17 | }); | ||
| 18 | |||
| 8 | cases.add("test/standalone/cat/main.zig"); | 19 | cases.add("test/standalone/cat/main.zig"); |
| 9 | if (builtin.zig_backend == .stage1) { // https://github.com/ziglang/zig/issues/6025 | 20 | if (builtin.zig_backend == .stage1) { // https://github.com/ziglang/zig/issues/6025 |
| 10 | cases.add("test/standalone/issue_9693/main.zig"); | 21 | cases.add("test/standalone/issue_9693/main.zig"); |
test/standalone/options/build.zig created+22| ... | @@ -0,0 +1,22 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | |||
| 3 | pub fn build(b: *std.build.Builder) void { | ||
| 4 | const target = b.standardTargetOptions(.{}); | ||
| 5 | const mode = b.standardReleaseOptions(); | ||
| 6 | |||
| 7 | const main = b.addTest("src/main.zig"); | ||
| 8 | main.setTarget(target); | ||
| 9 | main.setBuildMode(mode); | ||
| 10 | |||
| 11 | const options = b.addOptions(); | ||
| 12 | main.addOptions("build_options", options); | ||
| 13 | options.addOption(bool, "bool_true", b.option(bool, "bool_true", "t").?); | ||
| 14 | options.addOption(bool, "bool_false", b.option(bool, "bool_false", "f").?); | ||
| 15 | options.addOption(u32, "int", b.option(u32, "int", "i").?); | ||
| 16 | const E = enum { one, two, three }; | ||
| 17 | options.addOption(E, "e", b.option(E, "e", "e").?); | ||
| 18 | options.addOption([]const u8, "string", b.option([]const u8, "string", "s").?); | ||
| 19 | |||
| 20 | const test_step = b.step("test", "Run unit tests"); | ||
| 21 | test_step.dependOn(&main.step); | ||
| 22 | } | ||
test/standalone/options/src/main.zig created+12| ... | @@ -0,0 +1,12 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const assert = std.debug.assert; | ||
| 3 | |||
| 4 | const build_options = @import("build_options"); | ||
| 5 | |||
| 6 | test "build options" { | ||
| 7 | comptime assert(build_options.bool_true); | ||
| 8 | comptime assert(!build_options.bool_false); | ||
| 9 | comptime assert(build_options.int == 1234); | ||
| 10 | comptime assert(build_options.e == .two); | ||
| 11 | comptime assert(std.mem.eql(u8, build_options.string, "hello")); | ||
| 12 | } | ||
test/tests.zig+3| ... | @@ -1043,6 +1043,7 @@ pub const StandaloneContext = struct { | ... | @@ -1043,6 +1043,7 @@ pub const StandaloneContext = struct { |
| 1043 | requires_stage2: bool = false, | 1043 | requires_stage2: bool = false, |
| 1044 | use_emulation: bool = false, | 1044 | use_emulation: bool = false, |
| 1045 | requires_symlinks: bool = false, | 1045 | requires_symlinks: bool = false, |
| 1046 | extra_argv: []const []const u8 = &.{}, | ||
| 1046 | }) void { | 1047 | }) void { |
| 1047 | const b = self.b; | 1048 | const b = self.b; |
| 1048 | 1049 | ||
| ... | @@ -1063,6 +1064,8 @@ pub const StandaloneContext = struct { | ... | @@ -1063,6 +1064,8 @@ pub const StandaloneContext = struct { |
| 1063 | zig_args.append("--build-file") catch unreachable; | 1064 | zig_args.append("--build-file") catch unreachable; |
| 1064 | zig_args.append(b.pathFromRoot(build_file)) catch unreachable; | 1065 | zig_args.append(b.pathFromRoot(build_file)) catch unreachable; |
| 1065 | 1066 | ||
| 1067 | zig_args.appendSlice(features.extra_argv) catch unreachable; | ||
| 1068 | |||
| 1066 | zig_args.append("test") catch unreachable; | 1069 | zig_args.append("test") catch unreachable; |
| 1067 | 1070 | ||
| 1068 | if (b.verbose) { | 1071 | if (b.verbose) { |