Skip to content

Commit

Permalink
src/print_env: print the native target
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
perillo authored and andrewrk committed Sep 14, 2022
1 parent 1d041d3 commit 3250b20
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/print_env.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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();
Expand Down

0 comments on commit 3250b20

Please sign in to comment.