Zig
Developer reference: this page includes exported implementation details. BUILD authors should prefer the User API reference.
ZIG_TOOL
const ZIG_TOOL
Undocumented.
zigArtifactName()
zigArtifactName(version, plat)
Return the Zig release artifact filename for a version and platform.
| Parameter | Type | Description |
|---|---|---|
| version | string | |
| plat | { os: string, arch: string } |
Returns: string
zigDownloadUrl()
zigDownloadUrl(version, plat)
Return the Zig release download URL for a version and platform.
| Parameter | Type | Description |
|---|---|---|
| version | string | |
| plat | { os: string, arch: string } |
Returns: string
zigSupportedPlatforms()
zigSupportedPlatforms()
Return the platforms this module resolves Zig release archives for.
Returns: Array<{ os: string, arch: string }>
zigCacheKey()
zigCacheKey(version, plat)
Return the named-cache key for a Zig toolchain version and platform.
| Parameter | Type | Description |
|---|---|---|
| version | string | |
| plat | { os: string, arch: string } |
Returns: string
ZigToolchain (implementation class)
class ZigToolchain
Implementation class. BUILD files should use zigToolchain().
Undocumented.
zigToolchain()
zigToolchain(version, opts = {})
Declare a Zig toolchain version and optionally set it as the default. matching lockfile entry (warns instead of failing). to use instead of the shipped one.
| Parameter | Type | Description |
|---|---|---|
| version | string | |
| [opts] | object | |
| [opts.default=false] | boolean | |
| [opts.unverified=false] | boolean | Allow downloading without a |
| [opts.lockfile] | string | Address of a workspace-owned lockfile |
Returns: object Target handle for this Zig toolchain.
installZigToolchain()
installZigToolchain(version, source)
Install a local Zig toolchain directory into the named cache.
| Parameter | Type | Description |
|---|---|---|
| version | string | |
| source | string | Path to the toolchain root. |
Returns: string|null Local path to the cached toolchain root.
zigGraphTool()
zigGraphTool(version)
Build the managed Zig distribution as a graph-native tool, writing the ar/ranlib/clang wrapper scripts alongside it (see wrapperNames()/ wrapperContent() above for the exact set and content).
isZigToolchain()
isZigToolchain(toolchain)
Undocumented.
zigGraphToolchain()
zigGraphToolchain(version)
Graph-native Zig toolchain: zigGraphTool() plus its prewarmed build-cache tool, mirroring rustGraphToolchain()'s two-directory shape (//rules/rust/ toolchain) — Zig, like Rust, needs a second directory beyond the compiler install itself. Has no Rust-facing role (unlike gcc/mold): this exists to support raw C/C++ consumption of Zig directly. Also conforms to the shared cc-toolchain provider contract (kind, taskInputs, commands, cmakeConfigure, resolvesToolName, toolSpec, resolveState, edgeEnv) — see rules/c/gcc's and rules/c/msvc's own toolchain constructors for the other two providers. cmakeConfigure/ resolvesToolName/toolSpec are stubbed (throw/false) until CMake support for zig exists (see ZIG_CMAKE_UNSUPPORTED_MESSAGE above).
| Parameter | Type | Description |
|---|---|---|
| [version] | string |
Returns: { kind: string, tool: object, buildCacheTool: object, version: string }
defaultZigGraphToolchain()
defaultZigGraphToolchain()
Return the currently configured default Zig toolchain as graph-native handles, or null if none is declared.
Returns: object|null
zigGraphCacheEnv()
zigGraphCacheEnv(exec, resolvedBuildCacheTool)
Graph-native sibling of zigGlobalCacheEnv(): given a task's exec and its already-declared, resolved zigGraphToolchain().buildCacheTool input, resolve the $ZIG_GLOBAL_CACHE_DIR env entry pointing Zig at its shared build-cache tool mount.
| Parameter | Type | Description |
|---|---|---|
| exec | object | Task's exec (see task()'s run(exec, resolved) body). |
| resolvedBuildCacheTool | object | Resolved zigGraphToolchain().buildCacheTool input. |
Returns: string[]
resolveZigToolchainVersion()
resolveZigToolchainVersion(version)
Resolve an explicit or default Zig toolchain version.
| Parameter | Type | Description |
|---|---|---|
| [version] | string |
Returns: string|null
defaultZigToolchainVersion()
defaultZigToolchainVersion()
Return the currently configured default Zig toolchain version.
Returns: string|null