From 3250b20ceabea044bd4c7b1653d76d7069840058 Mon Sep 17 00:00:00 2001 From: Manlio Perillo Date: Fri, 27 May 2022 18:52:32 +0200 Subject: [PATCH] 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. --- src/print_env.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/print_env.zig b/src/print_env.zig index ad772d416b..f1a786392b 100644 --- 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();