zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 3250b20ceabea044bd4c7b1653d76d7069840058 (tree)
parent 1d041d3a10ec9187b7c4de6b4eb8a90926ea8d6c
Author: Manlio Perillo <manlio.perillo@gmail.com>
Date:   Fri, 27 May 2022 18:52:32 +0200

src/print_env: print the native target

Add the native target triple to the zig env command output.

The target triple is formatted the same way as it is done in the
zig targets command.

Diffstat:
Msrc/print_env.zig | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/print_env.zig b/src/print_env.zig @@ -21,6 +21,10 @@ pub fn cmdEnv(gpa: Allocator, args: []const []const u8, stdout: std.fs.File.Writ const global_cache_dir = try introspect.resolveGlobalCacheDir(gpa); defer gpa.free(global_cache_dir); + const info = try std.zig.system.NativeTargetInfo.detect(gpa, .{}); + const triple = try info.target.zigTriple(gpa); + defer gpa.free(triple); + var bw = std.io.bufferedWriter(stdout); const w = bw.writer(); @@ -42,6 +46,9 @@ pub fn cmdEnv(gpa: Allocator, args: []const []const u8, stdout: std.fs.File.Writ try jws.objectField("version"); try jws.emitString(build_options.version); + try jws.objectField("target"); + try jws.emitString(triple); + try jws.endObject(); try w.writeByte('\n'); try bw.flush();