Skip to content

Commit ec8774f

Browse files
committed
update downstream packaging guide regarding dependency fetching
fixes #20
1 parent ef756ea commit ec8774f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

content/zls/guides/packaging.smd

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,31 @@ If building ZLS without access to Git metadata (e.g., from a shallow clone or ta
3232

3333
## Dependency fetching
3434

35-
ZLS uses the Zig's builtin package manager to fetch dependencies and compile them from source. By default, Zig stores dependencies in the global cache directory at `$(zig env | jq -r .global_cache_dir)/p`, where each dependency is uniquely identified by a hash of its content.
35+
ZLS uses Zig's builtin package manager to fetch dependencies and compile them from source. By default, Zig automatically downloads dependencies and stores them in a global cache directory. The global cache directory can be found by running `zig env` and inspecting the `global_cache_dir` field. Packages are stored in the `p` subdirectory.
3636

37-
The content after building ZLS may look similar to this:
38-
39-
```bash
40-
$ tree $(zig env | jq -r .global_cache_dir)/p
41-
```
37+
Below is an example of how the package directory may look after building ZLS:
4238

4339
```
4440
/home/me/.cache/zig/p
45-
├── N-V-__8AABhrAQAQLLLGadghhPsdxTgBk9N9aLVOjXW3ay0V
41+
├── diffz-0.0.1-G2tlIQrOAQCfH15jdyaLyrMgV8eGPouFhkCeYFTmJaLk
4642
│ ├── build.zig
43+
│ ├── build.zig.zon
4744
│ ├── DiffMatchPatch.zig
4845
│ └── ...
49-
├── known_folders-0.0.0-Fy-PJtLDAADGDOwYwMkVydMSTp_aN-nfjCZw6qPQ2ECL
46+
├── known_folders-0.0.0-Fy-PJkfRAAAVdptXWXBspIIC7EkVgLgWozU5zIk5Zgcy
5047
│ ├── build.zig
5148
│ ├── build.zig.zon
5249
│ ├── known-folders.zig
5350
│ └── ...
54-
└── lsp_codegen-0.1.0-CMjjo0ZXCQB-rAhPYrlfzzpU0u0u2MeGvUucZ-_g32eg
51+
└── lsp_kit-0.1.0-bi_PL04yCgAxLsF0hH2a5sZKT84MGQaKXouw2jvCE8Nl
5552
├── build.zig
5653
├── build.zig.zon
5754
├── src
5855
└── ...
5956
```
6057

61-
If you need to fetch dependencies in a separate phase (e.g. during the configure phase), use `--system [pkgdir]` to disable automatic package fetching and manually specify the directory containing the fetched dependencies. Dependency hashes and URLs can be found in the `build.zig.zon` file.
58+
Dependencies are listed in the `build.zig.zon` file, where `url` specifies the canonical source and `hash` is used to pin and verify the package contents. Be aware that there may be additional transitive dependencies that are not listed in the `build.zig.zon` of the root project.
59+
60+
To support workflows in which dependency fetching is performed separately from the build process, the `--system [pkgdir]` option disables automatic package fetching and allows dependencies to be supplied from a pre-fetched package directory. Downstream vendors may choose their preferred method for fetching the required packages (for example, `zig fetch`, `git clone`, or `curl source.tar.gz`), provided that the resulting package contents match the specified hash.
61+
62+
Refer to `zig fetch` for instructions on acquiring packages and computing or verifying their hashes.

0 commit comments

Comments
 (0)