# Idiomatic way of using Zig build system with multiple binaries

**URL:** <https://ziggit.dev/t/idiomatic-way-of-using-zig-build-system-with-multiple-binaries/6086>\
**Category:** Help\
**Tags:** build-system\
**Created:** [September 21, 2024, 4:53pm UTC](https://ziggit.dev/t/idiomatic-way-of-using-zig-build-system-with-multiple-binaries/6086 "2024-09-21T16:53:08Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dimdin](https://ziggit.dev/user_avatar/ziggit.dev/dimdin/32/1457_2.png) [@dimdin](https://ziggit.dev/u/dimdin)\
**Post date:** [September 21, 2024, 5:33pm UTC](https://ziggit.dev/t/idiomatic-way-of-using-zig-build-system-with-multiple-binaries/6086/2 "2024-09-21T17:33:32Z")

</div>

You need to add two steps (build targets):

```zig
    const runtime_step = b.step("runtime", "Build runtime");
    const sandbox_step = b.step("sandbox", "Build sandbox");

```

These steps are listed, with their name and description, when running: `zig build -l`

* * *

EDIT: added calls to addInstallArtifact that copies the executable to `zig-out/bin`

```zig
const install_runtime = b.addInstallArtifact(runtime, .{});
const install_sandbox = b.addInstallArtifact(sandbox, .{});

```

* * *

Finally you need to add the step dependencies:

```zig
    runtime_step.dependOn(&install_runtime.step);
    sandbox_step.dependOn(&install_sandbox.step);

```

* * *

Then you can build:

- `runtime` by running `zig build runtime`,
- `sandbox` by running `zig build sandbox`,
- both by running `zig build runtime sandbox`,
- both (via the default install step) by running `zig build`.

* * *

See also: [Build System Tricks](https://ziggit.dev/t/build-system-tricks/3531)

---

_[View the full topic](https://ziggit.dev/t/idiomatic-way-of-using-zig-build-system-with-multiple-binaries/6086)._
