Skip to content

Commit 2dbe595

Browse files
committed
add a guide for distro packaging
1 parent 8c0d9b5 commit 2dbe595

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

content/zls/guides/packaging.smd

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
{
3+
.title = "Downstream Packaging",
4+
.date = @date("2020-08-04T00:00:00"),
5+
.author = "Sample Author",
6+
.layout = "zls-docs.shtml",
7+
}
8+
---
9+
10+
># [Info]($block.attrs('info'))
11+
>
12+
> This Guide is targeted at developers who create downstream packages of ZLS.
13+
14+
## Build Options
15+
16+
Run `zig build --help` in the root of ZLS source directory to print usage information.
17+
18+
Here are some of the common build options:
19+
20+
- `-Doptimize=ReleaseSafe`
21+
- `-Dtarget`
22+
- `-Dcpu=baseline` (opposite of `-march=native`)
23+
- `--prefix`
24+
25+
## Resolve version string
26+
27+
When compiling a tagged release of ZLS, the version is hard coded. No further action is needed.
28+
29+
For development builds, the version string is determined by running `git -C . describe --match "*.*.*" --tags` and formatting the output as `MAJOR.MINOR.PATCH-dev.COMMIT_HEIGHT+SHORT_COMMIT_HASH` (e.g. `0.14.0-dev.365+6a16b27`). If the version cannot be resolved, it defaults to `MAJOR.MINOR.PATCH-dev` (e.g. `0.14.0-dev`). This logic is implemented in the `getVersion` function within `build.zig`.
30+
31+
If building ZLS without access to Git metadata (e.g., from a shallow clone or tarball), it is recommended to manually specify the version string using the `-Dversion-string` build option.
32+
33+
## Dependency fetching
34+
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.
36+
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+
/home/me/.cache/zig/p
42+
├── 1220102cb2c669d82184fb1dc5380193d37d68b54e8d75b76b2d155b9af7d7e2e76d
43+
│ ├── build.zig
44+
│ ├── DiffMatchPatch.zig
45+
│ └── ...
46+
├── 12205f5e7505c96573f6fc5144592ec38942fb0a326d692f9cddc0c7dd38f9028f29
47+
│ ├── build.zig
48+
│ ├── build.zig.zon
49+
│ ├── known-folders.zig
50+
│ └── ...
51+
└── 12208e12a10e78de19f140acae65e6edc20189459dd208d5f6b7afdf0aa894113d1b
52+
├── build.zig
53+
├── build.zig.zon
54+
├── src
55+
└── ...
56+
```
57+
58+
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.

layouts/templates/with-zls-docs.shtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
</details>
141141
<details open="">
142142
<summary>Usage Guides</summary>
143-
<ul :loop="$site.pages('zls/guides/build-on-save','zls/guides/view-logs')">
143+
<ul :loop="$site.pages('zls/guides/build-on-save','zls/guides/view-logs','zls/guides/packaging')">
144144
<li>
145145
<a
146146
class="$loop.it.isCurrent().then('selected')"

0 commit comments

Comments
 (0)