Plans and runs Nim compiler invocations for Bau targets.
Types
BuildContext = object cfg*: BauConfig ## Effective project configuration. profile*: string ## Requested profile name. projectDir*: string ## Project root directory. verbose*: bool ## Whether command details should be printed. features*: FeatureSelection ## Resolved feature selection.
- Shared state for resolving and compiling targets.
TargetPlan = object target*: TargetInfo ## Target declaration being built. profile*: string ## Effective profile name. profileInfo*: ProfileInfo ## Merged profile configuration. sourceDir*: string ## Source directory relative to the project root. mainFile*: string ## Main Nim file relative to the project root. outputName*: string ## Binary or library output name. outputDir*: string ## Directory where compiled output is written. binaryPath*: string ## Expected compiled artifact path. compilerFlags*: seq[string] ## Nim compiler flags for this build. sourceFiles*: seq[string] ## Source and dependency files tracked by fingerprints. fingerprintInputs*: FingerprintInputs ## Inputs used to compute freshness. fingerprint*: Fingerprint ## Computed freshness fingerprint.
- Fully resolved build plan for one target.
Procs
proc buildAllTargets(cfg: BauConfig; profile: string; projectDir: string; verbose: bool; featureSelection: FeatureSelection = FeatureSelection()) {. ...raises: [ValueError, KeyError, OSError, Exception, IOError], tags: [ ReadEnvEffect, ReadDirEffect, RootEffect, ReadIOEffect, WriteIOEffect, WriteEnvEffect, WriteDirEffect, ExecIOEffect, TimeEffect], forbids: [].}
- Build configured targets, including the default target when requested.
proc buildSingleTarget(cfg: BauConfig; profile: string; projectDir: string; verbose: bool; featureSelection: FeatureSelection = FeatureSelection()): string {. ...raises: [ValueError, KeyError, OSError, Exception, IOError], tags: [ ReadEnvEffect, ReadDirEffect, RootEffect, ReadIOEffect, WriteIOEffect, WriteEnvEffect, WriteDirEffect, ExecIOEffect, TimeEffect], forbids: [].}
- Build the default target and return its artifact path.
proc buildTarget(cfg: BauConfig; targetIdx: int; profile: string; projectDir: string; verbose: bool; featureSelection: FeatureSelection = FeatureSelection()): string {. ...raises: [ValueError, KeyError, OSError, Exception, IOError], tags: [ ReadEnvEffect, ReadDirEffect, RootEffect, ReadIOEffect, WriteIOEffect, WriteEnvEffect, WriteDirEffect, ExecIOEffect, TimeEffect], forbids: [].}
-
Build one target and return the produced artifact path.
Cached fingerprints are used to skip unchanged builds.
proc buildTargetByName(cfg: BauConfig; name: string; profile: string; projectDir: string; verbose: bool; featureSelection: FeatureSelection = FeatureSelection()): string {. ...raises: [ValueError, KeyError, OSError, Exception, IOError], tags: [ ReadEnvEffect, ReadDirEffect, RootEffect, ReadIOEffect, WriteIOEffect, WriteEnvEffect, WriteDirEffect, ExecIOEffect, TimeEffect], forbids: [].}
- Build a named explicit target and return its artifact path.
proc cleanBuild() {....raises: [OSError, IOError], tags: [ReadDirEffect, WriteIOEffect, WriteDirEffect], forbids: [].}
- Remove the default build directory in the current project.
proc collectCompilerFlags(profile: ProfileInfo; kind: BuildKind; outDir: string; sourceDir: string; projectDir: string; cfg: BauConfig; featureSelection: FeatureSelection = FeatureSelection()): seq[string] {. ...raises: [ValueError, OSError], tags: [ReadEnvEffect, ReadDirEffect], forbids: [].}
-
Build the Nim compiler flag list for a target.
The result includes profile flags, feature defines, paths, output settings, color policy, and parallel-build defaults.
proc collectDepFiles(projectDir: string): seq[string] {....raises: [OSError], tags: [ReadDirEffect], forbids: [].}
proc collectFingerprintConfigInputs(projectDir: string): seq[string] {. ...raises: [], tags: [ReadDirEffect, ReadEnvEffect, ReadIOEffect], forbids: [].}
proc collectFingerprintEnvInputs(): seq[string] {....raises: [], tags: [ReadEnvEffect], forbids: [].}
proc findTargetIndex(cfg: BauConfig; name: string): int {....raises: [], tags: [], forbids: [].}
- Return the index of a named explicit target, or -1 when absent.
proc initBuildContext(cfg: BauConfig; profile, projectDir: string; verbose: bool; featureSelection: FeatureSelection = FeatureSelection()): BuildContext {. ...raises: [], tags: [], forbids: [].}
- Create a build context from config, profile, project path, and features.
proc resolveSourceFiles(sourceDir: string; mainFile: string): seq[string] {. ...raises: [OSError, ValueError], tags: [ReadDirEffect], forbids: [].}
- Return the main file plus Nim source files beneath sourceDir.
proc resolveTargetPlan(ctx: BuildContext; targetIdx: int): TargetPlan {. ...raises: [ValueError, KeyError, OSError, Exception], tags: [ReadEnvEffect, ReadDirEffect, RootEffect], forbids: [].}
-
Resolve a target index into compiler inputs, outputs, flags, and profile.
targetIdx == -1 selects the default [build] target.
proc runTarget(cfg: BauConfig; targetIdx: int; profile: string; projectDir: string; runArgs: openArray[string]; verbose: bool; featureSelection: FeatureSelection = FeatureSelection()) {. ...raises: [ValueError, KeyError, OSError, Exception, IOError], tags: [ ReadEnvEffect, ReadDirEffect, RootEffect, ReadIOEffect, WriteIOEffect, WriteEnvEffect, WriteDirEffect, ExecIOEffect, TimeEffect], forbids: [].}
- Build a target by index, then run the produced artifact.
proc runTargetByName(cfg: BauConfig; name: string; profile: string; projectDir: string; runArgs: openArray[string]; verbose: bool; featureSelection: FeatureSelection = FeatureSelection()) {. ...raises: [ValueError, KeyError, OSError, Exception, IOError], tags: [ ReadEnvEffect, ReadDirEffect, RootEffect, ReadIOEffect, WriteIOEffect, WriteEnvEffect, WriteDirEffect, ExecIOEffect, TimeEffect], forbids: [].}
- Build a target by name, then run the produced artifact.