Zig: `zig` executable: add a way for it to tell what directory locations it would default to for stdlib path, cache dir etc.

Created on 10 Feb 2020  路  5Comments  路  Source: ziglang/zig

Use-case: "given zig in PATH (or a full path to the executable) have a way for it to output what stdlib path it would default to (if not overridden) for a build or other compile operation. Possibly also include default cache-path it would default to from cwd if not overridden.

This could be a new subcommand such as zig info / zig paths or simply additional indented lines to zig version. If showing more than 1 path (ie. others than stdlib location), could go either for NAME=value lines or a JSON dict I guess.

accepted contributor friendly proposal

Most helpful comment

I like zig info and I further propose:

  • that it follows the pattern established by zig targets in outputting JSON format
  • that it is implemented self-hosted
  • that it contain the following fields:

    • detected path to lib/ dir

    • detected path to std/ dir (should be lib/std)

    • compiler id hash (zig id can be deprecated)

    • global cache dir

    • version (zig version can be redundant)

All 5 comments

I like zig info and I further propose:

  • that it follows the pattern established by zig targets in outputting JSON format
  • that it is implemented self-hosted
  • that it contain the following fields:

    • detected path to lib/ dir

    • detected path to std/ dir (should be lib/std)

    • compiler id hash (zig id can be deprecated)

    • global cache dir

    • version (zig version can be redundant)

I think this will help projects like zls a lot too!

Is anyone already working on this? I'd like to try it

Ok, assuming that no one is working on this. @metaleap, @andrewrk correct me if I'm wrong

similar to go env

[nix-shell:~/Downloads/zig/build]$ ./zig-cache/bin/zig env
{
 "lib_dir": "/home/andy/Downloads/zig/build/zig-cache/lib/zig",
 "std_dir": "/home/andy/Downloads/zig/build/zig-cache/lib/zig/std",
 "id": "425a2d736364746e424a494b58497556",
 "global_cache_dir": "/home/andy/.cache/zig",
 "version": "0.6.0+a916f6394"
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

bheads picture bheads  路  3Comments

dobkeratops picture dobkeratops  路  3Comments

zimmi picture zimmi  路  3Comments

andrewrk picture andrewrk  路  3Comments

jayschwa picture jayschwa  路  3Comments