Zaza Examples

The index of every directory under examples/, with the command that builds and runs each one.

Every directory here has its own README.md covering what it demonstrates, what it needs, and the exact command to build and run it.

ZAZA_EXAMPLES restricts which examples are wired into the root build graph. Setting it to a single example keeps configure time short and stops Zaza from resolving dependencies you do not need. Every command below is written that way. Dropping the prefix also works, at the cost of configuring the whole graph.

To run the whole verified surface in one command:

zig build example-matrix

That target shells out to ./zig for each step. See setup.sh.

Index

ExampleCommandDemonstrates
bench_suiteZAZA_EXAMPLES=bench-suite zig build bench-suite-runA benchmark declared through the addBench API
benchmark_workflowZAZA_EXAMPLES=benchmark-workflow zig build benchmark-workflow-runA benchmark exposed as size-specific run targets
bindingsZAZA_EXAMPLES=bindings zig build bindings-runZig calling C++ across a C ABI wrapper
cmake(none)Unwired early experiment, kept for reference
cmake_comboZAZA_EXAMPLES=cmake-combo zig build cmake-combo-runfmt + spdlog built by CMake, linked by Zig
cmake_consumersh examples/cmake_consumer/verify.shA plain CMake project consuming a Zaza-built library via find_package
cmake_netZAZA_EXAMPLES=cmake-net zig build cmake-net-runcurl + zlib + mbedtls with an ordering constraint
cmake_shimZAZA_EXAMPLES=cmake-shim ZAZA_SYSTEM_CMDS=1 zig build cmake-shim-runThe smallest complete CMake interop path
cmake_subdirZAZA_EXAMPLES=cmake-subdir zig build cmake-subdir-runBuilding an in-tree CMake subtree and linking it into a Zaza target
cross_compile_cliZAZA_EXAMPLES=cross-compile-cli zig build cross-compile-cli-reportNested build for a non-host triple
cxx20_modulesZAZA_EXAMPLES=cxx20-modules zig build cxx20-modules-runA C++20 named-module pipeline
find_packageZAZA_EXAMPLES=find-package zig build find-packageLinking an installed library resolved by pkg-config and CMake find_package
generated_codeZAZA_EXAMPLES=generated-code zig build generated-code-runA custom command generating a .cpp
generated_headersZAZA_EXAMPLES=generated-headers zig build generated-headers-runA custom command generating a header
hello_zazaZAZA_EXAMPLES=hello-zaza zig build run-hello-zazaA Zig exe and a C++ exe in one graph
interface_object_graphZAZA_EXAMPLES=interface-object-graph zig build interface-object-graph-runObject library folded into a static library
jsonZAZA_EXAMPLES=json zig build runnlohmann/json as a Zig package dependency
juceZAZA_EXAMPLES=juce ZAZA_SYSTEM_CMDS=1 zig build juceA JUCE GUI app through JUCE's CMake integration
mixed_stackZAZA_EXAMPLES=mixed-stack zig build mixed-stack-runC library, C++ bridge, Zig executable
orchestrationZAZA_EXAMPLES=orchestration zig build orchestration-runA generator-expressioned define, a target_link_options linker option, and a phony target
package_consumerZAZA_EXAMPLES=package-consumer zig build package-consumer-runConsuming an installed package from its manifest
package_producerZAZA_EXAMPLES=package-producer zig build package-producer-runPublishing headers, an archive, and a manifest
preset_profilesZAZA_EXAMPLES=preset-profiles zig build preset-profiles-runZAZA_PRESET selecting a build configuration
proof_libraryZAZA_EXAMPLES=proof-library zig build proof-library-runA plain static library with install/export metadata
resources_bundleZAZA_EXAMPLES=resources-bundle zig build resources-bundle-runA runtime asset staged into zig-out/share
rust_interopZAZA_EXAMPLES=rust-interop zig build rust-interop-runA Cargo staticlib linked into a Zig executable
shared_pluginZAZA_EXAMPLES=shared-plugin zig build shared-plugin-runA shared library loaded at runtime via dlopen
test_workflowsZAZA_EXAMPLES=test-workflows zig build test-workflows-runRun modes differing by arg, env, and cwd, via the addTest API
unity_buildZAZA_EXAMPLES=unity-build zig build unity-build-runSeveral sources compiled as one translation unit (CMAKE_UNITY_BUILD)
universal_binaryZAZA_EXAMPLES=universal-binary zig build universal-binary-reportA macOS universal binary combined from x86_64 and arm64 slices with zaza-lipo
wasm_exportsZAZA_EXAMPLES=wasm-exports zig build wasm-exports-runA freestanding wasm module with exports
wasm_wasiZAZA_EXAMPLES=wasm-wasi zig build wasm-wasi-reportA wasm32-wasi-musl executable, validated
zaza-juceZAZA_EXAMPLES=zaza-juce ZAZA_SYSTEM_CMDS=1 zig build zaza-juceA JUCE audio app with the audio modules on
zaza_subprojectZAZA_EXAMPLES=zaza-subproject zig build zaza-subproject-runA Zaza subproject with its own build.zig, composed into a parent build

Grouped by what you are looking for

Start here

hello_zaza, proof_library, mixed_stack.

Generated code

generated_code, generated_headers.

Packaging and consumption

package_producer, package_consumer.

Target graph shapes

interface_object_graph, shared_plugin, resources_bundle, zaza_subproject (a subproject with its own build.zig), unity_build (sources as one translation unit).

Other languages

bindings (C++ from Zig), rust_interop (Rust from Zig).

CMake interop

cmake_shim, cmake_combo, cmake_net, juce, zaza-juce.

WebAssembly

wasm_wasi, wasm_exports.

Configuration and workflow

preset_profiles, test_workflows, bench_suite, benchmark_workflow, cross_compile_cli, orchestration (generator expressions, link options, a phony target).

Optional tools

Most examples need nothing beyond Zig. These are the exceptions:

ToolNeeded by
cmake + gitcmake_shim, cmake_combo, cmake_net, juce, zaza-juce
cargorust_interop
nodewasm_wasi, wasm_exports
clang++ with C++20 modulescxx20_modules
file(1)cross_compile_cli report target
./zig wrapperpackage_consumer, cross_compile_cli, rust_interop, example-matrix

setup.sh checks all of these and tells you which examples are unavailable on your machine.

Which targets exist

zig build --list-steps

Further reading