Msvc
Developer reference: this page includes exported implementation details. BUILD authors should prefer the User API reference.
NASM_TOOL
const NASM_TOOL
Undocumented.
nasmSupportedPlatforms()
nasmSupportedPlatforms()
Return the platforms NASM publishes release archives for.
Returns: Array<{ os: string, arch: string }>
nasmArtifactName()
nasmArtifactName(version, plat)
Return the NASM release archive filename for a version and platform.
| Parameter | Type | Description |
|---|---|---|
| version | string | |
| plat | { os: string, arch: string } |
Returns: string
nasmDownloadUrl()
nasmDownloadUrl(version, plat)
Return the NASM release download URL for a version and platform.
| Parameter | Type | Description |
|---|---|---|
| version | string | |
| plat | { os: string, arch: string } |
Returns: string
msvcToolchain()
msvcToolchain()
Declare the ambient host MSVC toolchain — pass as cmakeProject({ toolchain }). There is no version to pick (unlike gccGraphToolchain() / zigGraphToolchain()): this always resolves whatever Visual Studio the host has installed, via one shared "discover MSVC host toolchain" graph node (msvcHostGraphOutput()) rather than a fresh vswhere shellout per caller. Also conforms to the shared cc-toolchain provider contract (kind, taskInputs, commands, cmakeConfigure, resolvesToolName, toolSpec, resolveState, edgeEnv) — see rules/c/gcc's and rules/c/zig's own toolchain constructors for the other two providers, and rules/c/toolchain.js's ccToolchainForPlatform() for the platform-indexed union all three plug into. This object literal is still inert to construct (no vswhere lookup, no action) — only taskInputs() references the discovery task node, and only calling it (via any consumer's declared inputs) causes it to actually run.
Returns: object Toolchain handle for cmakeProject()'s toolchain option.
isMsvcToolchain()
isMsvcToolchain(toolchain)
Undocumented.
NasmToolchain (implementation class)
class NasmToolchain
Implementation class. BUILD files should use nasmToolchain().
Undocumented.
nasmGraphTool()
nasmGraphTool(version)
Build the managed NASM assembler as a graph-native tool: the shared verified download (downloadToolArtifact) plus a wrapper-strip extract task that publishes nasm.exe into NASM_CACHE. Mirrors moldGraphTool() in //rules/c/mold.
| Parameter | Type | Description |
|---|---|---|
| [version] | string |
Returns: object Graph tool handle for the installed NASM directory.
nasmToolchain()
nasmToolchain(version, opts = {})
Declare the NASM assembler toolchain and optionally set it as the default. A msvcToolchain()-driven cmakeProject() picks up whatever default is declared — see resolveNasmHost(). matching lockfile entry (warns instead of failing). use instead of the shipped one, so the address is stated one time only.
| Parameter | Type | Description |
|---|---|---|
| [version] | string | |
| [opts] | object | |
| [opts.default=false] | boolean | |
| [opts.unverified=false] | boolean | Allow downloading without a |
| [opts.lockfile] | string | Address of a workspace-owned lockfile to |
Returns: object Target handle for this NASM toolchain.
nasmGenLockfiles()
nasmGenLockfiles(version, opts = {})
Lockfile generation root for a NASM toolchain declared elsewhere (e.g. via a frozen handle), mirroring odinfmtGenLockfiles(). A workspace that captured the nasmToolchain() handle can use handle[GEN_LOCKFILES] directly instead.
| Parameter | Type | Description |
|---|---|---|
| [version] | string | |
| [opts] | object | |
| [opts.lockfile] | string | Override the address to write. |
Returns: object
resolveNasmHost()
resolveNasmHost(exec, resolvedNasmTool)
Resolve the NASM assembler for a msvcToolchain()-driven cmakeProject(). Acquisition is declared at graph-declaration time by nasmGraphTool() (the shared downloadToolArtifact plus a wrapper-strip extract task) and reaches this helper as the task's already-resolved nasm input (msvcToolchain().taskInputs()). exec.path() is called only to consume() the binding so the graph scheduler orders the install task first — the same shape as moldBinDir() in //rules/c/mold.
| Parameter | Type | Description |
|---|---|---|
| exec | object | Task's exec. |
| resolvedNasmTool | object | The task's resolved nasm input. |
Returns: string Real, absolute host path to nasm.exe.
msvcHostDirs()
msvcHostDirs(host)
The MSVC/Windows-SDK bin/include/lib directories for a resolved host, x86_64 (Hostx64/x64) only.
| Parameter | Type | Description |
|---|---|---|
| host | {vsRoot: string, mscVersion: string, sdkRoot: string, sdkVersion: string} |
msvcCMakeCompilerArgs()
msvcCMakeCompilerArgs(host, nasmPath)
CMake configure arguments pointing at a resolved host MSVC toolchain: just the compiler/RC/MT paths. Deliberately not /I or /LIBPATH flags baked into CMAKE_
| Parameter | Type | Description |
|---|---|---|
| host | {vsRoot: string, mscVersion: string, sdkRoot: string, sdkVersion: string} | |
| nasmPath | string | Real, absolute host path to nasm.exe — see |
Returns: string[]
msvcEnv()
msvcEnv(host)
INCLUDE/LIB env entries (run({env: [...]})-shaped "KEY=VALUE" strings) for a resolved host — cl.exe/link.exe's own standard mechanism for finding system headers/libs (the same env vars vcvarsall.bat sets), used here instead of baking /I"..."/LIBPATH:"..." flags into CMAKE_C_FLAGS / CMAKE_EXE_LINKER_FLAGS. Needed because those flags would be replayed as literal shell argv text later (rules/c/cmake/graph_replay.js replays each ninja edge through sh -c), and rules/c/cmake/ninja_graph.js's own cmd.exe-wrapper cleanup unconditionally strips every double quote from a replayed command (confirmed by a real failure: bash choked on the bare (/)/spaces in an unquoted "...Program Files (x86)..." path once its surrounding quotes were stripped) — env var values never go through that argv tokenization at all, so this sidesteps the whole class of problem rather than trying to out-escape it. Also carries MSYS2_ARG_CONV_EXCL=* — cl.exe/link.exe are native (non-MSYS) children of the sh -c replaying each edge (see graph_replay.js's executeEdge()), and Git-for-Windows' MSYS runtime auto-mangles any argv token that looks like a POSIX path into a Windows one before exec'ing a native child. A single-slash MSVC flag like /FoCMakeFiles/foo.dir/x.obj matches that heuristic and got silently rewritten/dropped in testing — cl then fell back to its own default output name in cwd, producing a plausible-looking command that nonetheless wrote its .obj to the wrong path. Confirmed by reproducing the exact resolved command by hand: it only matched the real (broken) behavior once this var was unset, and worked once set — see rules/c/gcc's own PASSTHROUGH_ENV_VARS_WINDOWS comment for the sibling issue on the gcc path (which doesn't need this only because clang/gcc flags use -o / --foo, never a bare leading slash).
| Parameter | Type | Description |
|---|---|---|
| host | {vsRoot: string, mscVersion: string, sdkRoot: string, sdkVersion: string} |
Returns: string[]
MSVC_GRAPH_TOOL_NAMES
const MSVC_GRAPH_TOOL_NAMES
Undocumented.
msvcGraphToolSpec()
msvcGraphToolSpec(name, host)
A {name, cache, key, binDirs} tool spec for cl.exe/link.exe/lib.exe/ nasm.exe, mountable directly via exec.action({tools: [...]}) — mirrors rules/c/gcc's gccGraphToolSpec(), except the "install" is just cachePut()-registering the ambient VS root discoverMsvcHost() already found (see this module's own header comment on why: there's nothing to download, the toolchain already exists on the host) — nasm.exe is the one exception, actually downloaded by nasmGraphTool(). cachePut()'d) via discoverMsvcHost() earlier in the same task run(). Unused for nasm.exe, which resolves by cache name alone.
| Parameter | Type | Description |
|---|---|---|
| name | string | One of MSVC_GRAPH_TOOL_NAMES. |
| host | {vsRoot: string, mscVersion: string} | Already-resolved (and |
Returns: {name: string, cache: string, key: string, binDirs: string[]}