Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ jobs:
- name: Setup Zig
uses: mlugg/setup-zig@v2.2.1
with:
version: 0.16.0
version: 0.17.0

- name: Run test suite
run: zig build test --summary all

- name: Run test suite with cached configuration
run: zig build test --summary all
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub fn build(b: *std.Build) !void {
_ = b.addModule("shared", .{
.root_source_file = b.path("src/shared.zig"),
.target = b.resolveTargetQuery(.{}),
.optimize = .Debug,
.optimize = .debug,
});
_ = b.step("gen:prep", "manual prep step");

Expand Down Expand Up @@ -178,7 +178,10 @@ Then reference those manual nodes from the manifest with bare strings:

## Requirements

Zig `0.16.0+`
Zig `0.17.x` only. Zig `0.16` is no longer supported.

When upgrading an existing manifest, rename optimization modes to `.debug`,
`.safe`, `.fast`, and `.small`. The rest of the manifest syntax is unchanged.

## License

Expand Down
52 changes: 41 additions & 11 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ pub fn build(b: *std.Build) void {
.build_args = &.{"info"},
.stdout_match = "full_example v1.0.0",
});
addFixtureCommand(b, tls_test_fixtures, .{
.name = "examples-simple-help",
.cwd = "examples/simple",
.build_args = &.{"help"},
.stdout_match = "simple_example v0.1.0",
});
addFixtureCommand(b, tls_test_fixtures, .{
.name = "examples-full-info-cross",
.cwd = "examples/full",
.build_args = &.{ "info", "-Dtarget=wasm32-freestanding" },
.stdout_match = "full_example v1.0.0",
});
addFixtureCommand(b, tls_test_fixtures, .{
.name = "manual-interop-build",
.cwd = "test/fixtures/manual_interop",
Expand All @@ -79,6 +91,18 @@ pub fn build(b: *std.Build) void {
.build_args = &.{"run:myapp"},
.stderr_match = "manual manual",
});
addFixtureCommand(b, tls_test_fixtures, .{
.name = "manual-interop-args",
.cwd = "test/fixtures/manual_interop",
.build_args = &.{ "run:myapp", "--", "first", "two words" },
.stderr_match = "arg: first\narg: two words\n",
});
addFixtureCommand(b, tls_test_fixtures, .{
.name = "manual-interop-args-changed",
.cwd = "test/fixtures/manual_interop",
.build_args = &.{ "run:myapp", "--", "changed" },
.stderr_match = "arg: changed\n",
});
addFixtureCommand(b, tls_test_fixtures, .{
.name = "manual-interop-cmd",
.cwd = "test/fixtures/manual_interop",
Expand Down Expand Up @@ -151,7 +175,7 @@ pub fn build(b: *std.Build) void {
addFixtureCommand(b, tls_test_fixtures, .{
.name = "inline-name-collision",
.cwd = "test/fixtures/inline_name_collision",
.expect_exit = 2,
.expect_exit = 1,
.stderr_match = "collides with named module",
});
addFixtureCommand(b, tls_test_fixtures, .{
Expand All @@ -171,40 +195,36 @@ pub fn build(b: *std.Build) void {
.cwd = "test/fixtures/dependency_explicit_args",
// Use uncommon target queries for distinguishability on
// common host machines
.build_args = &.{ "-Dtarget=powerpc64-linux-none", "-Doptimize=ReleaseSafe" },
.stderr_match =
\\dep arch=powerpc64 os=linux abi=none optimize=ReleaseFast portable=true
\\dep arch=mips64 os=linux abi=none optimize=ReleaseFast portable=true
,
.build_args = &.{ "-Dtarget=powerpc64-linux-none", "-Doptimize=safe" },
});
addFixtureCommand(b, tls_test_fixtures, .{
.name = "root-module-string-options-module",
.cwd = "test/fixtures/root_module_string_options_module",
.expect_exit = 2,
.expect_exit = 1,
.stderr_match = "options module 'config' is import-only and cannot be used as root_module",
});
addFixtureCommand(b, tls_test_fixtures, .{
.name = "duplicate-installable-artifact-name",
.cwd = "test/fixtures/duplicate_installable_artifact_name",
.expect_exit = 2,
.expect_exit = 1,
.stderr_match = "installable artifact names must be unique",
});
addFixtureCommand(b, tls_test_fixtures, .{
.name = "alias-empty-depends-on",
.cwd = "test/fixtures/alias_empty_depends_on",
.expect_exit = 2,
.expect_exit = 1,
.stderr_match = "aliases 'check': depends_on must not be empty",
});
addFixtureCommand(b, tls_test_fixtures, .{
.name = "preset-unknown-option",
.cwd = "test/fixtures/preset_unknown_option",
.expect_exit = 2,
.expect_exit = 1,
.stderr_match = "presets 'dev.config': unknown option 'missing'",
});
addFixtureCommand(b, tls_test_fixtures, .{
.name = "invalid-optimize",
.cwd = "test/fixtures/invalid_optimize",
.expect_exit = 2,
.expect_exit = 1,
.stderr_match = "executables 'demo': invalid optimize '.Release'",
});
addFixtureCommand(b, tls_test_fixtures, .{
Expand All @@ -217,4 +237,14 @@ pub fn build(b: *std.Build) void {
.cwd = "test/fixtures/stdlib_passthrough",
.build_args = &.{"build-test:unit"},
});
addFixtureCommand(b, tls_test_fixtures, .{
.name = "stdlib-passthrough-no-builtins",
.cwd = "test/fixtures/stdlib_passthrough",
.build_args = &.{"build-obj:without_builtins"},
});
addFixtureCommand(b, tls_test_fixtures, .{
.name = "stdlib-passthrough-fmt",
.cwd = "test/fixtures/stdlib_passthrough",
.build_args = &.{"fmt:source"},
});
}
2 changes: 1 addition & 1 deletion build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.name = .zbuild,
.version = "0.4.0",
.fingerprint = 0x60f98ac2bf5a915c,
.minimum_zig_version = "0.16.0",
.minimum_zig_version = "0.17.0",
.paths = .{ "build.zig", "build.zig.zon", "src" },
.description = "Declarative build configuration for Zig projects",
.dependencies = .{},
Expand Down
2 changes: 1 addition & 1 deletion docs/concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ Example:
_ = b.addModule("shared", .{
.root_source_file = b.path("src/shared.zig"),
.target = b.resolveTargetQuery(.{}),
.optimize = .Debug,
.optimize = .debug,
});
_ = b.step("gen:prep", "manual prep step");
```
Expand Down
8 changes: 6 additions & 2 deletions docs/schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Reusable code units registered with the build system. Modules can be referenced
|-------|------|---------|-------------|
| `root_source_file` | string | — | Path to the root source file |
| `target` | string | host | `"native"` or arch-os-abi triple (e.g. `"x86_64-linux-gnu"`) |
| `optimize` | enum literal | project default | `.Debug`, `.ReleaseSafe`, `.ReleaseFast`, `.ReleaseSmall` |
| `optimize` | enum literal | project default | `.debug`, `.safe`, `.fast`, `.small` |
| `imports` | tuple | — | Modules, options_modules, or dependencies to import |
| `link_libraries` | tuple of strings | — | Dependency library artifacts to link (see below) |
| `include_paths` | tuple of strings | — | Include paths for C/C++ headers |
Expand All @@ -38,6 +38,10 @@ These map directly to `std.Build.Module.CreateOptions`:

`link_libc`, `link_libcpp`, `single_threaded`, `strip`, `unwind_tables`, `dwarf_format`, `code_model`, `error_tracing`, `omit_frame_pointer`, `pic`, `red_zone`, `sanitize_c`, `sanitize_thread`, `stack_check`, `stack_protector`, `fuzz`, `valgrind`, `no_builtin`

On Zig 0.17.0, zbuild omits an explicit `no_builtin = false` to preserve the compiler's
default (builtins enabled) and avoid the invalid `-fno-no-builtin` flag generated by
the upstream build system. `no_builtin = true` is forwarded unchanged.

### `link_libraries` syntax

Format: `"dep_name"` or `"dep_name:artifact_name"`. Resolves a library artifact from a declared dependency. This is distinct from LazyPath resolution.
Expand Down Expand Up @@ -128,7 +132,7 @@ Same fields as executables, plus `win32_module_definition` and `linker_allow_shl

## `objects`

Compiled object files. Simpler subset — no `version`, `linkage`, `dest_sub_path`, or `win32_manifest`. Each entry creates a `build-obj:<name>` step.
Compiled object files installed under `zig-out/lib`. Simpler subset — no `version`, `linkage`, `dest_sub_path`, or `win32_manifest`. Each entry creates a `build-obj:<name>` step.

```zig
.objects = .{
Expand Down
2 changes: 1 addition & 1 deletion examples/full/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.name = .full_example,
.version = "1.0.0",
.fingerprint = 0x3dc5c2f38908b4dc,
.minimum_zig_version = "0.16.0",
.minimum_zig_version = "0.17.0",
.paths = .{ "build.zig", "build.zig.zon", "src" },
.description = "A comprehensive zbuild example showcasing all features",
.dependencies = .{
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.name = .simple_example,
.version = "0.1.0",
.fingerprint = 0x24a585649eafbb78,
.minimum_zig_version = "0.16.0",
.minimum_zig_version = "0.17.0",
.paths = .{ "build.zig", "build.zig.zon", "src" },
.description = "A minimal zbuild example",
.dependencies = .{
Expand Down
Loading
Loading