aboutsummaryrefslogtreecommitdiff
path: root/lib/init/src/main.zig
AgeCommit message (Collapse)Author
2025-08-11std.ArrayList: make unmanaged the defaultAndrew Kelley
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: appease zig fmt checkLoris Cro
last commit introduced a templated variable name that made zig fmt angry
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-02-26zig init: adjust template lang to allow zig fmt passthroughAndrew Kelley
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.
2025-02-11fuzzer: write inputs to shared memory before runningAndrew Kelley
breaking change to the fuzz testing API; it now passes a type-safe context parameter to the fuzz function. libfuzzer is reworked to select inputs from the entire corpus. I tested that it's roughly as good as it was before in that it can find the panics in the simple examples, as well as achieve decent coverage on the tokenizer fuzz test. however I think the next step here will be figuring out why so many points of interest are missing from the tokenizer in both Debug and ReleaseSafe modes. does not quite close #20803 yet since there are some more important things to be done, such as opening the previous corpus, continuing fuzzing after finding bugs, storing the length of the inputs, etc.
2024-12-18init template: expand slightly, migrate from deprecated std.Build APIsmlugg
2024-09-11fix init template for new fuzz testing APIAndrew Kelley
2024-08-18update comment in init templateAndrew Kelley
Unit tests are not run from the install step. closes #21123
2024-07-26update init templateAndrew Kelley
* add fuzz example * explain that you might want to delete main.zig or root.zig
2023-11-20merge `zig init-exe` and `zig init-lib` into `zig init`Andrew Kelley
Instead of `zig init-lib` and `zig init-exe`, now there is only `zig init`, which initializes any of the template files that do not already exist, and makes a package that contains both an executable and a static library. The idea is that the user can delete whatever they don't want. In fact, I think even more things should be added to the build.zig template.