C
Developer reference: this page includes exported implementation details. BUILD authors should prefer the User API reference.
DEFAULT_CPP_SRCS
const DEFAULT_CPP_SRCS
Undocumented.
DEFAULT_CPP_HDRS
const DEFAULT_CPP_HDRS
Undocumented.
ccWorkloadSpecs()
ccWorkloadSpecs()
Undocumented.
ccLibrary()
ccLibrary(opts = {})
Declare a graph-native raw C/C++ library. deps takes other ccLibrary()/cmake-project-target call results directly (handle-passing, not label references) — see this module's own docstring for the transitiveArchives contract shared with rules/c/cmake's graph-native targets.
| Parameter | Type | Description |
|---|---|---|
| [opts] | object | |
| [opts.path] | string | Workspace-relative directory. Defaults to the calling BUILD.js's own directory ("."). |
| [opts.srcs] | string[] | Source glob, default DEFAULT_CPP_SRCS. |
| [opts.hdrs] | string[] | Header glob (input-only, not individually inspected), default DEFAULT_CPP_HDRS. |
| [opts.deps=[]] | Array | Other ccLibrary()/cmake-target results this library links against. |
| [opts.toolchain] | object | gccGraphToolchain()/zigGraphToolchain() result, or the workspace default. |
| [opts.copts=[]] | string[] | Extra compiler flags. |
| [opts.outputName] | string | Portable artifact filename stem. Defaults to the directory-derived slug; rules add the platform-specific library suffix. |
| [opts.unsafeSystemPaths=false] | boolean | Bypass Bootlin's toolchain-wrapper unsafe-path guard (which rejects -I/-isystem/-L flags under /usr/include or /usr/lib) so this target can link against host system packages (e.g. libwebkit2gtk-4.1). No-op on a zig toolchain, which has no such guard. |
| [opts.shared=false] | boolean | Build a dynamically-loadable shared object (-shared, platform-correct extension: .dll on Windows, .so elsewhere) instead of a static .a archive. The result is reported as transitiveSharedLibs rather than transitiveArchives, so a dependent ccLibrary()/ccBinary() links against it but never tries to ar it in. A consumer's product carries the library beside its own executable and is linked with an $ORIGIN rpath, so it also loads at run time — see ccBinary(). |
Returns: object Frozen {[BUILD], archive, transitiveArchives, transitiveSharedLibs, transitiveIncludeDirs, transitiveHdrs, transitiveLinkopts, [PACKAGE]}.
ccBinary()
ccBinary(opts = {})
Declare a graph-native raw C/C++ binary. Same deps/toolchain contract as ccLibrary() — see this module's own docstring.
| Parameter | Type | Description |
|---|---|---|
| [opts] | object | |
| [opts.path] | string | Workspace-relative directory. Defaults to the calling BUILD.js's own directory ("."). |
| [opts.srcs] | string[] | Source glob, default DEFAULT_CPP_SRCS. |
| [opts.hdrs] | string[] | Header glob, default DEFAULT_CPP_HDRS. |
| [opts.deps=[]] | Array | ccLibrary()/cmake-target results this binary links against. |
| [opts.toolchain] | object | gccGraphToolchain()/zigGraphToolchain() result, or the workspace default. |
| [opts.copts=[]] | string[] | Extra compiler flags. |
| [opts.linkopts=[]] | string[] | Extra linker flags for this binary's own link step (not propagated to anything that might depend on it — deps' own transitiveLinkopts are folded in automatically instead). |
| [opts.outputName] | string | Portable executable filename stem. Defaults to the directory-derived slug; .exe is added on Windows. |
| [opts.unsafeSystemPaths=false] | boolean | Bypass Bootlin's toolchain-wrapper unsafe-path guard (which rejects -I/-isystem/-L flags under /usr/include or /usr/lib) so this target can link against host system packages (e.g. libwebkit2gtk-4.1). No-op on a zig toolchain, which has no such guard. |
Returns: object Frozen {[BUILD], [PACKAGE], [RUN]}. The product is a single executable file, or a directory holding the executable plus every transitive shared library when there is one (see this module's own docstring).
ccTest()
ccTest(opts = {})
Declare a graph-native raw C/C++ test binary: a ccBinary() whose exit code is the test result. Same deps/toolchain contract as ccBinary() — see this module's own docstring. The binary is run with no arguments and nothing else mounted, so an assertion belongs inside main() (return actual == expected ? 0 : 1). That is the same granularity //rules/c/cmake reports for a CTest entry and //rules/rust for a test binary: one unit per executable, not per case.
| Parameter | Type | Description |
|---|---|---|
| [opts] | object | Every ccBinary() option, unchanged. |
| [opts.outputName] | string | Portable executable filename stem. Defaults to the directory-derived slug; .exe is added on Windows. |
Returns: object Frozen {[BUILD], [RUN], [TEST]}.