aboutsummaryrefslogtreecommitdiff
path: root/lib/init/build.zig.zon
AgeCommit message (Collapse)Author
2025-06-13zig init: simplify templating logic (#24170)Loris Cro
and also rename `advancedPrint` to `bufferedPrint` in the zig init templates These are left overs from my previous changes to zig init. The new templating system removes LITNAME because the new restrictions on package names make it redundant with NAME, and the use of underscores for marking templated identifiers lets us template variable names while still keeping zig fmt happy.
2025-06-02zig init: add new --strip flag and improve template filesLoris Cro
This commit introduces a new flag to generate a new Zig project using `zig init` without comments for users who are already familiar with the Zig build system. Additionally, the generated files are now different. Previously we would generate a set of files that defined a static library and an executable, which real-life experience has shown to cause confusion to newcomers. The new template generates one Zig module and one executable both in order to accommodate the two most common use cases, but also to suggest that a library could use a CLI tool (e.g. a parser library could use a CLI tool that provides syntax checking) and vice-versa a CLI tool might want to expose its core functionality as a Zig module. All references to C interoperability are removed from the template under the assumption that if you're tall enough to do C interop, you're also tall enough to find your way around the build system. Experienced users will still be able to use the current template and adapt it with minimal changes in order to perform more advanced operations. As an example, one only needs to change `b.addExecutable` to `b.addLibrary` to switch from generating an executable to a dynamic (or static) library.
2025-03-01zig init template: remove outdated commentsAndrew Kelley
closes #23040
2025-02-26rename "nonce" to "fingerprint"Andrew Kelley
2025-02-26zig init: adjust template lang to allow zig fmt passthroughAndrew Kelley
2025-02-26switch from "id" to "nonce"Andrew Kelley
mainly this addresses the following use case: 1. Someone creates a template with build.zig.zon, id field included (note that zig init does not create this problem since it generates fresh id every time it runs). 2. User A uses the template, changing package name to "example" but not id field. 3. User B uses the same template, changing package name also to "example", also not changing the id field. Here, both packages have unintentional conflicting logical ids. By making the field a combination of name checksum + random id, this accident is avoided. "nonce" is an OK name for this. Also relaxes errors on remote packages when using `zig fetch`.
2025-02-26introduce package id and redo hash format againAndrew Kelley
Introduces the `id` field to `build.zig.zon`. Together with name, this represents a globally unique package identifier. This field should be initialized with a 16-bit random number when the package is first created, and then *never change*. This allows Zig to unambiguously detect when one package is an updated version of another. When forking a Zig project, this id should be regenerated with a new random number if the upstream project is still maintained. Otherwise, the fork is *hostile*, attempting to take control over the original project's identity. `0x0000` is invalid because it obviously means a random number wasn't used. `0xffff` is reserved to represent "naked" packages. Tracking issue #14288 Additionally: * Fix bad path in error messages regarding build.zig.zon file. * Manifest validates that `name` and `version` field of build.zig.zon are maximum 32 bytes. * Introduce error for root package to not switch to enum literal for name. * Introduce error for root package to omit `id`. * Update init template to generate `id` * Update init template to populate `minimum_zig_version`. * New package hash format changes: - name and version limited to 32 bytes via error rather than truncation - truncate sha256 to 192 bits rather than 40 bits - include the package id This means that, given only the package hashes for a complete dependency tree, it is possible to perform version selection and know the final size on disk, without doing any fetching whatsoever. This prevents wasted bandwidth since package versions not selected do not need to be fetched.
2024-12-21doc: mention zig can't use URLs if their content changesJonathan Marler
There's been some proliferation of dependency URLs that reference mutable data such as links to git branches that can change. This has resulted in broken projects, i.e. * https://github.com/RohanVashisht1234/raylib_rain_train/blob/9eef9de94c511f2eb4fe5db1d6abd574ee245c9b/build.zig.zon * https://github.com/rcmagic/ZigFightingGame/commit/4b64353e9c69de0fa2eb87fa9c3a3da76a8a3e7b There's also disagreement about whether it's fine for URL's to point to git branches, i.e. https://github.com/Not-Nik/raylib-zig/pull/130 This updates the docs to mention that zig won't be able to use URLs if their content changes.
2024-07-15add a missing comment in build.zig.zonKNnut
2024-06-05seriously people, don't put "zig-" in your package namesAndrew Kelley
related #20178
2024-05-28init: clarify .paths usage in build.zig.zonTim Culverhouse
Clarify the usage of .paths in build.zig.zon. Follow the recommendation of the comments to explicitly list paths by explicitly listing the paths in the init project.
2024-04-11Document lazy dependency in init build.zig.zonJeremia Dominguez
Also added the same description to doc/build.zig.zon.md
2023-12-20Grammar fixes (#18320)Maximilian
* Grammar fixes Just a couple things I noticed * Update build.zig.zon.md Fix a/an usage for zon doc
2023-11-26`zig fetch`: add `--save` flagAndrew Kelley
``` --save Add the fetched package to build.zig.zon --save=[name] Add the fetched package to build.zig.zon as name ```
2023-11-20zig init: also create a build.zig.zonAndrew Kelley