-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
add zig dep-hash
command
#20281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dweiller
wants to merge
13
commits into
ziglang:master
Choose a base branch
from
dweiller:dep-hash
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add zig dep-hash
command
#20281
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e559a74
to
5c9fbbf
Compare
fbbc024
to
c994903
Compare
b5b0327
to
ce54075
Compare
ccb57da
to
13f3215
Compare
Specifying sub-dependencies with a period-separated syntax does not work as dependency names can include a period.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the
zig dep-hash
command (calledzig pkg-hash
in #20180) for inspecting the dependency tree of a package.What follows is a description of the current behaviour, for any bike-shedding/suggestions for alternative behaviour.
The command works solely off the
build.zig.zon
s of a package and its transitive dependencies and doesn't perform any package fetching, so packages must already be present in the global cache to inspect their dependencies.To get the hash of a (sub) dependency the name of the dependency (according to build.zig.zon) is given as a positional parameter with the name of sub-dependencies given as additional positional parameters. For example
> zig dep-hash mach mach_basisu basisu 1220da74ddbae5ccae5d0141e747023039488f266b98e7ceb860015f95b2dd10c650
prints the hash of the (third-level) sub-dependency
basisu
(this invocation walks the dependency treeroot_pkg -> mach -> mach_basisu
and gets the hash ofbasisu
in thebuild.zig.zon
ofmach_basisu
)The
--list
flag can be provided to list the names and hashes of all dependencies instead of printing a single hash:> zig dep-hash mach --list mach_freetype 12206251ed342f400b80abf3c338521f5d8c83eb596899abf77a2afe0cfd46e61ff0 font_assets 12202b816e7c31c516bd87218fd56f9b1f93671e4ab42a2a98110d586c4b3bdd2730 mach_gpu_dawn 122060fbe61aa4a828002ca8949d9c3ef1b6b7ae3fa92558af7ccea7182e8d9d516c mach_glfw 1220e5343c2fe2a490aa90dc52d92fd34ebfd7d0ffc7d246dd4720bb5c339ead4d7b mach_objc 1220211475420584a552b461dd569f891d29cb8e9e485b97053be604680c8d6e2a3e xcode_frameworks 12205d131983601cdb3500f38e9d8adaed5574fb0211b8b39291d2e9b90c6555ce59 direct3d_headers 12203594c3c97220742be1cc5343547bb25d8947e77bd52c50ef713da676d6f6d31f opengl_headers 12209f5ec4fa073c3b5b5129a72b7b230596af48a732bed539e35161395ed590095d vulkan_zig_generated 1220d2b6789b71a94e692cb2f060bff4ffa4edfe196216cd573da68e74ab884eb34e linux_audio_headers 122042c20087cc1e40d24a61c9d725be36ac5914d6e87e1776cc3cfaecedbcc0be16 wayland_headers 1220f350a0782d20a6618ea4e2884f7d0205a4e9b02c2d65fe3bf7b8113e7860fadf x11_headers 1220ddf168c855cf69b4f8c5284403106a3c681913e34453df10cc5a588d9bd1d005 zigimg 1220dc313944ea71a87b4f54f26b1427ad2992a721a221cb42f7f80b8eee4e4944b7 mach_opus 12203e942ae6563c5fb05dff8e8a406b71fe6682342ae5d8d26093e6f9e3d2e02777 mach_example_assets 12204101e99906bee0fde5f82682bc822744a6f879dbf45374bebd92458492313df9
If a relative dependency it's path is displayed along with the annotation
(local)
:> zig dep-hash --list zigimg 1220c0980dc05816b12a8188546b4847bcf38e5e99defc0ea79a8d6bd4809049a029 zig_wfc 1220ca5d40e299dd2e00396e13ecef043831d1438610a0c8f9246ec0c48ceee253f3 mach 12206c34197e552379b7b83b9b71e16230d3c87b5bff689f80d686b41b3486e9f486 nanovg 1220a6a2572713f2a29e54584b060ea19fd89b298bf89baf0b090b85a0a473527d4f ztracy vendor/ztracy (local)
The
--graph
flag can be provided to show the whole dependency graph of a package> zig dep-hash --graph RTD ├─ zigimg 1220c0980dc05816b12a8188546b4847bcf38e5e99defc0ea79a8d6bd4809049a029 ├─ zig_wfc 1220ca5d40e299dd2e00396e13ecef043831d1438610a0c8f9246ec0c48ceee253f3 ├─ mach 12206c34197e552379b7b83b9b71e16230d3c87b5bff689f80d686b41b3486e9f486 │ ├─ mach_freetype 12206251ed342f400b80abf3c338521f5d8c83eb596899abf77a2afe0cfd46e61ff0 │ │ ├─ freetype 1220babb7939707ca390b934657dfd3c8c3a6a78cc9442e4cbd43e3f9ffd49daec9e │ │ │ └─ brotli 122059777e9e24227733f386b2929a78e15be9b748c99dba0d209744c910671b101c │ │ ├─ harfbuzz 1220557b115b730afbece2ff4a073b6dc095d143318ba2f6b258cee13f580dd7e8ba │ │ │ ├─ freetype 1220babb7939707ca390b934657dfd3c8c3a6a78cc9442e4cbd43e3f9ffd49daec9e (seen previously) │ │ │ └─ brotli 122059777e9e24227733f386b2929a78e15be9b748c99dba0d209744c910671b101c (seen previously) │ │ └─ font_assets 12202b816e7c31c516bd87218fd56f9b1f93671e4ab42a2a98110d586c4b3bdd2730 │ ├─ font_assets 12202b816e7c31c516bd87218fd56f9b1f93671e4ab42a2a98110d586c4b3bdd2730 (seen previously) │ ├─ mach_gpu_dawn 122060fbe61aa4a828002ca8949d9c3ef1b6b7ae3fa92558af7ccea7182e8d9d516c │ ├─ mach_glfw 1220e5343c2fe2a490aa90dc52d92fd34ebfd7d0ffc7d246dd4720bb5c339ead4d7b │ ├─ mach_objc 1220211475420584a552b461dd569f891d29cb8e9e485b97053be604680c8d6e2a3e │ ├─ xcode_frameworks 12205d131983601cdb3500f38e9d8adaed5574fb0211b8b39291d2e9b90c6555ce59 │ ├─ direct3d_headers 12203594c3c97220742be1cc5343547bb25d8947e77bd52c50ef713da676d6f6d31f │ ├─ opengl_headers 12209f5ec4fa073c3b5b5129a72b7b230596af48a732bed539e35161395ed590095d │ ├─ vulkan_zig_generated 1220d2b6789b71a94e692cb2f060bff4ffa4edfe196216cd573da68e74ab884eb34e │ ├─ linux_audio_headers 122042c20087cc1e40d24a61c9d725be36ac5914d6e87e1776cc3cfaecedbcc0be16 │ ├─ wayland_headers 1220f350a0782d20a6618ea4e2884f7d0205a4e9b02c2d65fe3bf7b8113e7860fadf │ ├─ x11_headers 1220ddf168c855cf69b4f8c5284403106a3c681913e34453df10cc5a588d9bd1d005 │ ├─ zigimg 1220dc313944ea71a87b4f54f26b1427ad2992a721a221cb42f7f80b8eee4e4944b7 │ ├─ mach_opus 12203e942ae6563c5fb05dff8e8a406b71fe6682342ae5d8d26093e6f9e3d2e02777 │ └─ mach_example_assets 12204101e99906bee0fde5f82682bc822744a6f879dbf45374bebd92458492313df9 ├─ nanovg 1220a6a2572713f2a29e54584b060ea19fd89b298bf89baf0b090b85a0a473527d4f └─ ztracy vendor/ztracy (local) └─ system_sdk vendor/system-sdk (local)
Note that this prints the graph as a tree and will not re-print the subtree/subgraph of a dependency that has already been printed (note the '(seen previously)' annotations). This reduces the amount printed at the cost introducing some indirection (i.e. if you look at the second
freetype
line above, you'd have to scan upwards and find the prior occurrence offreetype
to see that it depends onbrotli
). This is also a mitigation against the possibility of cycles in the dependency graph, which the compiler/build system currently allows (but doesn't handle robustly).For convenience, when no positional parameters are given, the default behaviour is the same as
--graph
.The
--build-root
flag can be used to specify the directory to operate on, rather than the current working directory (note that the usual search up parent directories will still happen when--build-root
is provided, it just changes where the search starts from).A minimum of four spaces are used to separate dependency names and hashes with
--list
, with extra spaces used in order to align the hashes. The alignment for--graph
could probably use some work, it aligns hashes that are in the same manifest.