builtin: Add zig_version
This will enable code to perform version checks and make it easier to support multiple versions of Zig. Within the SemVer implementation, an intermediate value needed to be coerced to a slice to workaround a comptime bug. Closes #6466
This commit is contained in:
committed by
Andrew Kelley
parent
5c49a137d5
commit
a0ad2dee6a
@@ -2703,6 +2703,11 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8
|
||||
\\pub const arch = Target.current.cpu.arch;
|
||||
\\/// Deprecated
|
||||
\\pub const endian = Target.current.cpu.arch.endian();
|
||||
\\
|
||||
\\/// Zig version. When writing code that supports multiple versions of Zig, prefer
|
||||
\\/// feature detection (i.e. with `@hasDecl` or `@hasField`) over version checks.
|
||||
\\pub const zig_version = try @import("std").SemanticVersion.parse("{s}");
|
||||
\\
|
||||
\\pub const output_mode = OutputMode.{};
|
||||
\\pub const link_mode = LinkMode.{};
|
||||
\\pub const is_test = {};
|
||||
@@ -2714,6 +2719,7 @@ pub fn generateBuiltinZigSource(comp: *Compilation, allocator: *Allocator) ![]u8
|
||||
\\ .features = Target.{}.featureSet(&[_]Target.{}.Feature{{
|
||||
\\
|
||||
, .{
|
||||
build_options.version,
|
||||
std.zig.fmtId(@tagName(comp.bin_file.options.output_mode)),
|
||||
std.zig.fmtId(@tagName(comp.bin_file.options.link_mode)),
|
||||
comp.bin_file.options.is_test,
|
||||
|
||||
Reference in New Issue
Block a user