bau/nimscan

Scans Nim modules, imports, and target candidates.

Types

NimDependencyEdge = object
  importer*: string          ## Module that imports or depends on another module.
  imported*: string          ## Module imported by `importer`.
Compiler-reported dependency edge.
NimModuleInfo = object
  path*: string              ## Project-relative module path.
  moduleName*: string        ## Filename stem used as the module name.
  imports*: seq[string]      ## Non-stdlib modules imported by the file.
  includes*: seq[string]     ## Non-stdlib modules included by the file.
  isMainModule*: bool        ## True when the file references `isMainModule`.
Lightweight facts extracted from a Nim source file.

Procs

proc compilerDependencyEdges(projectDir: string; cfg: BauConfig): seq[
    NimDependencyEdge] {....raises: [OSError, ValueError, IOError], tags: [
    ReadDirEffect, RootEffect, WriteDirEffect, ExecIOEffect, ReadEnvEffect,
    ReadIOEffect, TimeEffect], forbids: [].}

Ask the Nim compiler for dependency edges for targets and tests.

Failures are tolerated so source-level scanning can still provide results.

proc scanNimModule(projectDir, path: string): NimModuleInfo {.
    ...raises: [ValueError, OSError, IOError],
    tags: [RootEffect, ReadDirEffect, ReadIOEffect], forbids: [].}

Scan one Nim module for imports, includes, and isMainModule.

The scanner is intentionally lightweight and ignores stdlib imports.

proc scanProjectModules(projectDir: string; cfg: BauConfig): seq[NimModuleInfo] {.
    ...raises: [OSError, ValueError, IOError],
    tags: [ReadDirEffect, RootEffect, ReadIOEffect], forbids: [].}
Scan project source and test directories for Nim modules.