Liking cljdoc? Tell your friends :D

clj-zig.compile

Compile generated Zig into a dynamic library (imperative shell). This namespace owns the only zig invocations: it writes the source, canonicalizes it with zig fmt, and builds a shared library.

On success it returns the library and source paths. On failure it throws a structured diagnostic: the Var and signature first, then the source.zig path, then the compiler's stderr and exit code. The core shell catches it to keep the last good binding.

Compile generated Zig into a dynamic library (imperative shell). This
namespace owns the only `zig` invocations: it writes the source,
canonicalizes it with `zig fmt`, and builds a shared library.

On success it returns the library and source paths. On failure it
throws a structured diagnostic: the Var and signature first, then the
`source.zig` path, then the compiler's stderr and exit code. The core
shell catches it to keep the last good binding.
raw docstring

attribute-failureclj

(attribute-failure stderr module-roots)

Attribute a compile failure to an external module or to the wrapper by matching the compiler's stderr against each module's source directory (ADR 34, ADR 11). A module match carries its import name, so a developer sees which dependency failed rather than only that the build did; with no modules, or an error in the generated source.zig, it is the wrapper. Pure.

Attribute a compile failure to an external module or to the wrapper by
matching the compiler's `stderr` against each module's source directory
(ADR 34, ADR 11). A module match carries its import name, so a developer
sees which dependency failed rather than only that the build did; with no
modules, or an error in the generated `source.zig`, it is the wrapper.
Pure.
sourceraw docstring

build-argumentsclj

(build-arguments zig
                 {:keys [source-abs library-abs options target module-roots
                         global-cache-dir]})

The full zig build-lib argument vector for a compile (pure). Without :module-roots, the source is the positional root and the per-module link flags precede it, exactly as a single-file build. With modules, the source becomes the main module and each module is declared and defined by name (ADR 34). --global-cache-dir is always present so Zig memoizes intermediate artifacts across compiles (ADR 35). A :target triple cross-compiles for another platform.

The full `zig build-lib` argument vector for a compile (pure). Without
`:module-roots`, the source is the positional root and the per-module link
flags precede it, exactly as a single-file build. With modules, the source
becomes the main module and each module is declared and defined by name
(ADR 34). `--global-cache-dir` is always present so Zig memoizes
intermediate artifacts across compiles (ADR 35). A `:target` triple
cross-compiles for another platform.
sourceraw docstring

compile!clj

(compile! {:keys [source source-path library-path ctx options aux-files target
                  module-roots]})

Compile source into a dynamic library at library-path, writing the canonical source to source-path first. Returns {:library <path> :source-path <path>} on success; throws a structured diagnostic on failure. ctx adds :var and :signature to that diagnostic. options carries C-interop include and link flags; aux-files are imported Zig files to write beside the source first, each {:path <absolute> :text <content>}. module-roots names external Zig modules the body may @import, each mapped to its root source path. target is a Zig target triple to cross-compile for (e.g. x86_64-linux-musl); omit it to build for the host.

Compile `source` into a dynamic library at `library-path`, writing the
canonical source to `source-path` first. Returns
`{:library <path> :source-path <path>}` on success; throws a
structured diagnostic on failure. `ctx` adds `:var` and `:signature`
to that diagnostic. `options` carries C-interop include and link flags;
`aux-files` are imported Zig files to write beside the source first, each
`{:path <absolute> :text <content>}`. `module-roots` names external Zig
modules the body may `@import`, each mapped to its root source path.
`target` is a Zig target triple to cross-compile for (e.g.
`x86_64-linux-musl`); omit it to build for the host.
sourceraw docstring

dynamic-library-extensionclj

(dynamic-library-extension)

The platform's shared-library suffix, without the dot.

The platform's shared-library suffix, without the dot.
sourceraw docstring

global-cache-dirclj

(global-cache-dir)

The project-local directory Zig memoizes its intermediate build artifacts in across compiles (ADR 35). Keeping it stable lets a wrapper miss over an unchanged module relink the already-built module rather than rebuild it, and it shares the .clj-zig/ lifecycle the toolchain and artifact cache already own. It is build-tool state, not part of any content hash.

The project-local directory Zig memoizes its intermediate build artifacts
in across compiles (ADR 35). Keeping it stable lets a wrapper miss over an
unchanged module relink the already-built module rather than rebuild it,
and it shares the `.clj-zig/` lifecycle the toolchain and artifact cache
already own. It is build-tool state, not part of any content hash.
sourceraw docstring

options->flagsclj

(options->flags {:keys [include-path system-include-path link-path link]})

The extra zig build-lib flags carried in options for C interop: include paths (-I), system include paths (-isystem), library search paths (-L), and linked libraries (-l). Returns a flat vector of argv tokens, empty when there is nothing to add. Pure.

The extra `zig build-lib` flags carried in `options` for C interop:
include paths (`-I`), system include paths (`-isystem`), library search
paths (`-L`), and linked libraries (`-l`). Returns a flat vector of argv
tokens, empty when there is nothing to add. Pure.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close