mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 22:35:24 +00:00
parent
3a0e8c2b45
commit
32e65c3f96
@ -1816,7 +1816,7 @@ pub const LibExeObjStep = struct {
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
out.print("pub const {z} = {};\n", .{ name, value }) catch unreachable;
|
||||
out.print("pub const {z}: {} = {};\n", .{ name, @typeName(T), value }) catch unreachable;
|
||||
}
|
||||
|
||||
/// The value is the path in the cache dir.
|
||||
@ -2751,6 +2751,34 @@ test "Builder.dupePkg()" {
|
||||
std.testing.expect(dupe_deps[0].path.ptr != pkg_dep.path.ptr);
|
||||
}
|
||||
|
||||
test "LibExeObjStep.addBuildOption" {
|
||||
if (builtin.os.tag == .wasi) return error.SkipZigTest;
|
||||
|
||||
var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
|
||||
defer arena.deinit();
|
||||
var builder = try Builder.create(
|
||||
&arena.allocator,
|
||||
"test",
|
||||
"test",
|
||||
"test",
|
||||
);
|
||||
defer builder.destroy();
|
||||
|
||||
var exe = builder.addExecutable("not_an_executable", "/not/an/executable.zig");
|
||||
exe.addBuildOption(usize, "option1", 1);
|
||||
exe.addBuildOption(?usize, "option2", null);
|
||||
exe.addBuildOption([]const u8, "string", "zigisthebest");
|
||||
exe.addBuildOption(?[]const u8, "optional_string", null);
|
||||
|
||||
std.testing.expectEqualStrings(
|
||||
\\pub const option1: usize = 1;
|
||||
\\pub const option2: ?usize = null;
|
||||
\\pub const string: []const u8 = "zigisthebest";
|
||||
\\pub const optional_string: ?[]const u8 = null;
|
||||
\\
|
||||
, exe.build_options_contents.items);
|
||||
}
|
||||
|
||||
test "LibExeObjStep.addPackage" {
|
||||
if (builtin.os.tag == .wasi) return error.SkipZigTest;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user