| author | |
| committer | |
| log | 8d8d568854d33be7bcc2bc9874029d1082914af7 |
| tree | 5f586a97c22f088515f9291e37f3af229aa28db3 |
| parent | 66d76cc4f938209470fedd8e52f71267f0e0d0e4 |
3 files changed, 26 insertions(+), 6 deletions(-)
build.zig+20| ... | ... | @@ -10,6 +10,8 @@ const io = std.io; |
| 10 | 10 | const fs = std.fs; |
| 11 | 11 | const InstallDirectoryOptions = std.build.InstallDirectoryOptions; |
| 12 | 12 | |
| 13 | const zig_version = std.builtin.Version{ .major = 0, .minor = 6, .patch = 0 }; | |
| 14 | ||
| 13 | 15 | pub fn build(b: *Builder) !void { |
| 14 | 16 | b.setPreferredReleaseMode(.ReleaseFast); |
| 15 | 17 | const mode = b.standardReleaseOptions(); |
| ... | ... | @@ -79,6 +81,24 @@ pub fn build(b: *Builder) !void { |
| 79 | 81 | |
| 80 | 82 | const log_scopes = b.option([]const []const u8, "log", "Which log scopes to enable") orelse &[0][]const u8{}; |
| 81 | 83 | |
| 84 | const opt_version_string = b.option([]const u8, "version-string", "Override Zig version string. Default is to find out with git."); | |
| 85 | const version = if (opt_version_string) |version| version else v: { | |
| 86 | var code: u8 = undefined; | |
| 87 | const version_untrimmed = b.execAllowFail(&[_][]const u8{ | |
| 88 | "git", "-C", b.build_root, "name-rev", "HEAD", | |
| 89 | "--tags", "--name-only", "--no-undefined", "--always", | |
| 90 | }, &code, .Ignore) catch |err| { | |
| 91 | std.debug.print( | |
| 92 | \\Unable to determine zig version string: {} | |
| 93 | \\Provide the zig version string explicitly using the `version-string` build option. | |
| 94 | , .{err}); | |
| 95 | std.process.exit(1); | |
| 96 | }; | |
| 97 | const trimmed = mem.trim(u8, version_untrimmed, " \n\r"); | |
| 98 | break :v b.fmt("{}.{}.{}+{}", .{ zig_version.major, zig_version.minor, zig_version.patch, trimmed }); | |
| 99 | }; | |
| 100 | exe.addBuildOption([]const u8, "version", version); | |
| 101 | ||
| 82 | 102 | exe.addBuildOption([]const []const u8, "log_scopes", log_scopes); |
| 83 | 103 | exe.addBuildOption(bool, "enable_tracy", tracy != null); |
| 84 | 104 | if (tracy) |tracy_path| { |
src-self-hosted/link.zig+4-1| ... | ... | @@ -15,6 +15,9 @@ const leb128 = std.debug.leb; |
| 15 | 15 | const Package = @import("Package.zig"); |
| 16 | 16 | const Value = @import("value.zig").Value; |
| 17 | 17 | const Type = @import("type.zig").Type; |
| 18 | const build_options = @import("build_options"); | |
| 19 | ||
| 20 | const producer_string = if (std.builtin.is_test) "zig test" else "zig " ++ build_options.version; | |
| 18 | 21 | |
| 19 | 22 | // TODO Turn back on zig fmt when https://github.com/ziglang/zig/issues/5948 is implemented. |
| 20 | 23 | // zig fmt: off |
| ... | ... | @@ -1132,7 +1135,7 @@ pub const File = struct { |
| 1132 | 1135 | // Write the form for the compile unit, which must match the abbrev table above. |
| 1133 | 1136 | const name_strp = try self.makeDebugString(self.base.options.root_pkg.root_src_path); |
| 1134 | 1137 | const comp_dir_strp = try self.makeDebugString(self.base.options.root_pkg.root_src_dir_path); |
| 1135 | const producer_strp = try self.makeDebugString("zig (TODO version here)"); | |
| 1138 | const producer_strp = try self.makeDebugString(producer_string); | |
| 1136 | 1139 | // Currently only one compilation unit is supported, so the address range is simply |
| 1137 | 1140 | // identical to the main program header virtual address and memory size. |
| 1138 | 1141 | const text_phdr = &self.program_headers.items[self.phdr_load_re_index.?]; |
src-self-hosted/main.zig+2-5| ... | ... | @@ -95,11 +95,8 @@ pub fn main() !void { |
| 95 | 95 | const stdout = io.getStdOut().outStream(); |
| 96 | 96 | return @import("print_targets.zig").cmdTargets(arena, cmd_args, stdout, info.target); |
| 97 | 97 | } else if (mem.eql(u8, cmd, "version")) { |
| 98 | // Need to set up the build script to give the version as a comptime value. | |
| 99 | // TODO when you solve this, also take a look at link.zig, there is a placeholder | |
| 100 | // that says "TODO version here". | |
| 101 | std.debug.print("TODO version command not implemented yet\n", .{}); | |
| 102 | return error.Unimplemented; | |
| 98 | std.io.getStdOut().writeAll(build_options.version ++ "\n") catch process.exit(1); | |
| 99 | return; | |
| 103 | 100 | } else if (mem.eql(u8, cmd, "zen")) { |
| 104 | 101 | try io.getStdOut().writeAll(info_zen); |
| 105 | 102 | } else if (mem.eql(u8, cmd, "help")) { |