| ... | @@ -1816,7 +1816,7 @@ pub const LibExeObjStep = struct { | ... | @@ -1816,7 +1816,7 @@ pub const LibExeObjStep = struct { |
| 1816 | }, | 1816 | }, |
| 1817 | else => {}, | 1817 | else => {}, |
| 1818 | } | 1818 | } |
| 1819 | out.print("pub const {z} = {};\n", .{ name, value }) catch unreachable; | 1819 | out.print("pub const {z}: {} = {};\n", .{ name, @typeName(T), value }) catch unreachable; |
| 1820 | } | 1820 | } |
| 1821 | | 1821 | |
| 1822 | /// The value is the path in the cache dir. | 1822 | /// The value is the path in the cache dir. |
| ... | @@ -2751,6 +2751,34 @@ test "Builder.dupePkg()" { | ... | @@ -2751,6 +2751,34 @@ test "Builder.dupePkg()" { |
| 2751 | std.testing.expect(dupe_deps[0].path.ptr != pkg_dep.path.ptr); | 2751 | std.testing.expect(dupe_deps[0].path.ptr != pkg_dep.path.ptr); |
| 2752 | } | 2752 | } |
| 2753 | | 2753 | |
| | 2754 | test "LibExeObjStep.addBuildOption" { |
| | 2755 | if (builtin.os.tag == .wasi) return error.SkipZigTest; |
| | 2756 | |
| | 2757 | var arena = std.heap.ArenaAllocator.init(std.testing.allocator); |
| | 2758 | defer arena.deinit(); |
| | 2759 | var builder = try Builder.create( |
| | 2760 | &arena.allocator, |
| | 2761 | "test", |
| | 2762 | "test", |
| | 2763 | "test", |
| | 2764 | ); |
| | 2765 | defer builder.destroy(); |
| | 2766 | |
| | 2767 | var exe = builder.addExecutable("not_an_executable", "/not/an/executable.zig"); |
| | 2768 | exe.addBuildOption(usize, "option1", 1); |
| | 2769 | exe.addBuildOption(?usize, "option2", null); |
| | 2770 | exe.addBuildOption([]const u8, "string", "zigisthebest"); |
| | 2771 | exe.addBuildOption(?[]const u8, "optional_string", null); |
| | 2772 | |
| | 2773 | std.testing.expectEqualStrings( |
| | 2774 | \\pub const option1: usize = 1; |
| | 2775 | \\pub const option2: ?usize = null; |
| | 2776 | \\pub const string: []const u8 = "zigisthebest"; |
| | 2777 | \\pub const optional_string: ?[]const u8 = null; |
| | 2778 | \\ |
| | 2779 | , exe.build_options_contents.items); |
| | 2780 | } |
| | 2781 | |
| 2754 | test "LibExeObjStep.addPackage" { | 2782 | test "LibExeObjStep.addPackage" { |
| 2755 | if (builtin.os.tag == .wasi) return error.SkipZigTest; | 2783 | if (builtin.os.tag == .wasi) return error.SkipZigTest; |
| 2756 | | 2784 | |