Odin

Developer reference: this page includes exported implementation details. BUILD authors should prefer the User API reference.

odinConfigSchema

const odinConfigSchema

Declarative workspace configuration schema for Odin. collections is a dynamic map[string]string from Odin collection names to workspace-relative paths. For example: export const odinConfig = { collections: { lib: "library" }, }; Package-local Odin collections use the collections option on odinPackage/odinTestPackage instead and may include target handles or { name, path } entries. buildGenerate enables imp goal generate-build for unowned .odin files (off by default).

declared_path()

declared_path(handle, path = ".")

Undocumented.

OdinPackageAnalysis

class OdinPackageAnalysis

Undocumented.

graphDefaultOutputPath()

graphDefaultOutputPath(address)

Default build output path for a graph-native package, given its resolved address.

odin_output_path()

odin_output_path(out, analysis)

Undocumented.

generateBuild

const generateBuild

Undocumented.

registerOdinPackageHook()

registerOdinPackageHook(hook)

Register an optional facet enabled by importing an Odin extension.

odinModeFlags()

odinModeFlags(opt)

The odin build/odin test flags for the shared opt mode axis (see //rules/imp/mode): -debug for debug info + runtime bounds/type checks, -o:speed to optimize for speed instead. Any value other than "release" is treated as "debug", matching the axis's own declared default.

ParameterTypeDescription
optstringResolved "opt" mode axis value.

Returns: string[]

odinMergeLinkopts()

odinMergeLinkopts(lists)

Merge the transitiveLinkopts of every dep the source closure reached into one flag list. One library is commonly reachable more than one time (both directly and through a dep package), so a flag is kept at its first occurrence only — that keeps the linker's own left-to-right order, which decides how it resolves symbols. order.

ParameterTypeDescription
listsstring[][]One transitiveLinkopts array per dep, in closure

Returns: string[]

odinExtraLinkerFlagsArgs()

odinExtraLinkerFlagsArgs(linkopts)

A dep's own transitiveLinkopts (e.g. a cmakeLibraryDep()'s pkg-config- derived -L/-l flags) reach Odin's own linker invocation as a single -extra-linker-flags:"..." arg — Odin takes one string, not repeated flags, so this joins them the same way gccCMakeCompilerArgs()'s own compiler-args construction already does for CMake.

ParameterTypeDescription
linkoptsstring[]

Returns: string[] [], or a single -extra-linker-flags: arg.

odinLinkerPathDir()

odinLinkerPathDir(clangPath)

The gcc toolchain bin dir to put on PATH for Odin's own linker invocation (Odin execs a program literally named "clang" to link — see gccTool()'s own docstring). Its graph tool selects either bin/ or bin-unsafe-paths/ before the executor constructs PATH, so the mounted tool's own normal bin/ directory cannot override an unsafeSystemPaths selection. (exec.tool(resolved.gcc, "clang")).

ParameterTypeDescription
clangPathstringSandbox path to the GCC tool's clang launcher

Returns: string

odinGccLinkerPathDir()

odinGccLinkerPathDir(exec, resolvedGccTool)

Resolve the GCC linker directory through the graph tool mount. exec.path is not valid here: a mounted graph tool is available only at its .imp/tools/... mount point.

ParameterTypeDescription
execobjectTask executor.
resolvedGccToolobjectResolved GCC graph tool input.

Returns: string

odinTestLibraryPathEnv()

odinTestLibraryPathEnv(sharedLibPaths)

The LD_LIBRARY_PATH entry an odin test action needs, or no entry at all. odin test compiles and runs in one action, so unlike odin build it has no product for graphOdinBundle() to carry a shared library in. Odin's own $ORIGIN rpath does not help either: it resolves to wherever odin put the test binary (the sandbox root), not to the build/c/ directory the library is staged under. Measured as a real failure before this: "error while loading shared libraries: librules_odin_example_shared.so". The entries are relative paths, which the loader reads against the working directory. That is sound here because a build action's cwd is the sandbox root, which is the same root the staged paths are relative to. Unlike the executor-wide loader path this replaces, this is a declared env value on one action: it keys that action's own digest, and it names a staged directory, never a host one. Left out on Windows, which has no LD_LIBRARY_PATH — the epic that covers shared-library run-time linkage scopes Windows out, because it finds a DLL beside the executable through its own default search order.

ParameterTypeDescription
sharedLibPathsstring[]Sandbox paths of the staged shared libraries.

Returns: string[] [], or a single LD_LIBRARY_PATH= env entry.

odinPackage()

odinPackage(opts = {})

Declare an immutable, graph-native Odin package.

odinTestPackage()

odinTestPackage(opts = {})

Declare an immutable, graph-native Odin test package.

odin_test_package

const odin_test_package

Undocumented.