Skip to content

zig_c_library

Zig module generated from C provider headers.

Description

Runs zig translate-c over headers from one or more c_provider dependencies and exposes the generated Zig source as a zig_module. The C provider link inputs are preserved so downstream Zig build targets can compile against the translated declarations and link against the native library inputs.

Set translate_c_identity when using a standalone translate-c path that can change in place and the action cache should distinguish different executable builds.

Attributes

AttributeTypeRequiredDefaultDescription
zigstringnozig on PATHZig compiler path
zig_versionstringnoemptyExpected zig version output when using zig translate-c
import_namestringnotarget nameName downstream modules use with @import
zigoptslist<string>no[]Extra flags attached to this module specification
datalist<string>no[]Runtime data globs included in provider metadata
targetstringnohost targetZig target triple passed to zig translate-c
cpustringnoemptyProcessor setting passed with -mcpu
modestringnoemptyauto, debug, release_safe, release_small, or release_fast; maps to -O
host_modestringnoemptyAlias for mode when porting configured host targets
threadedstringnoemptymulti passes -fno-single-threaded; single passes -fsingle-threaded
host_threadedstringnoemptyAlias for threaded when porting configured host targets
stripboolnofalseAlias for strip_debug_symbols
strip_debug_symbolsboolnofalsePass -fstrip
zigoptlist<string>no[]Global Zig flags prepended before module-specific zigopts
host_zigoptlist<string>no[]Alias for zigopt when porting configured host targets
use_cc_common_linkintno-1Compatibility setting for C provider linking; Once consumes C providers through its provider model
host_use_cc_common_linkintno-1Host compatibility setting for C provider linking
use_standalone_translate_cintno-1Set to 1 to use a standalone translate-c executable
translate_cstringnoemptyStandalone translate-c executable path
translate_c_identitystringnoemptyStable identity for the standalone translate-c executable, folded into translate action cache keys
bootstrappedintno-1Compatibility selector for bootstrapped Zig toolchains; choose the compiler with zig

Dependency Edges

EdgeAcceptsDescription
depsc_providerC provider dependencies whose headers are translated and whose link inputs are propagated

Providers

The target emits zig_module.

Capabilities

CapabilityOutput groups
buildsource

Example

toml
[[target]]
name = "native_math_zig"
kind = "zig_c_library"
deps = ["./native_math"]

[target.attrs]
import_name = "native_math"

Released under an open-source license.