@imp/rules/c/cmake/ninja_graph
Module: @imp/rules/c/cmake/ninja_graph.
edge_dependencies(edge)
Documentation is not yet available for this implementation export.
Source: rules/c/cmake/ninja_graph.luau:210.
edge_outputs(edge)
Documentation is not yet available for this implementation export.
Source: rules/c/cmake/ninja_graph.luau:206.
expand_var(template, edge, top_vars, rule_defaults)
Resolve $in, $out, and $VAR references in template. The edge variables
come first, then the rule defaults, then the top-level variables, as
Ninja scopes them in the subset that CMake writes.
$in_newline and $out_newline are Ninja builtins. The MSVC
static-library rule uses rspfile_content = $in_newline $LINK_FLAGS.
They join with a space, not a newline: replay writes the response file
through argv elements of sh, and the argv of Git for Windows removes
newline bytes. lib.exe and link.exe read spaces and newlines as the same
separator.
Source: rules/c/cmake/ninja_graph.luau:183.
extract_copy_destinations(command, build_dir_path)
The destinations of cmake -E copy and cmake -E copy_if_different in a
resolved command, relative to the workspace.
A POST_BUILD or PRE_BUILD custom command can copy a built artifact, for example into the source tree. The Ninja graph has no edge for that copy, so replay finds the copy command and captures its destination as an extra output of the edge.
Source: rules/c/cmake/ninja_graph.luau:594.
is_command_edge(edge, rules)
Documentation is not yet available for this implementation export.
Source: rules/c/cmake/ninja_graph.luau:523.
join_and_normalize(base_dir, relative_path)
Join a path that is relative to base_dir onto it, and resolve . and
.. parts. The result is relative to the workspace.
Source: rules/c/cmake/ninja_graph.luau:492.
list_named_cmake_targets(graph)
The named CMake targets of graph that have a real artifact, as
{ name, outputs, type } entries sorted by name.
CMake writes the scratch directory CMakeFiles/<name>.dir/ of a target
into the variables of its edges (OBJECT_DIR, DEP_FILE, ...). That finds
each target, also an executable that has no phony alias. A name must
reach at least one edge with a command. outputs has only the final
products: an output that another reached edge reads, such as an object
file, is not a product.
Source: rules/c/cmake/ninja_graph.luau:537.
parse_ninja(main_text, read_include)
Parse main_text (normally build.ninja) and each file that it includes.
read_include(path) returns the text of an included file, so that the
parser works on CAS reads and on test fixtures.
Source: rules/c/cmake/ninja_graph.luau:167.
reachable_edges(edges, target_names)
The edges that target_names need, in dependency order (for example
from "all"). CMake bookkeeping edges, such as build.ninja regeneration
and clean, are not reached.
Source: rules/c/cmake/ninja_graph.luau:275.
reachable_edges_bounded(edges, target_names, boundary_outputs)
The edges that target_names need, in dependency order. A dependency
path in the set boundary_outputs stops the walk: the walk records it
and does not visit its edge.
boundary_outputs holds the final outputs of the other named CMake
targets. CMake names that path in a | or || reference when one target
depends on another, for example || libcrypto.a on a library link edge
or | libssl.a libcrypto.a on an executable link edge. The other target
has its own replay task, so this walk does not derive its edges again.
Returns { edges, boundaries }.
Source: rules/c/cmake/ninja_graph.luau:235.
rebase_absolute_paths(text, sandbox_root, replacement)
Replace the configure sandbox root and its slash in text with
replacement.
Source: rules/c/cmake/ninja_graph.luau:419.
rebase_path(path, sandbox_root)
Rebase one path token of an edge input or output list: remove the configure sandbox root. These paths are relative to the workspace, not to the directory where the command runs.
Source: rules/c/cmake/ninja_graph.luau:442.
replace_all(text, needle, replacement)
Documentation is not yet available for this implementation export.
Source: rules/c/cmake/ninja_graph.luau:27.
resolve_edge_command(edge, rules, top_vars, sandbox_root, build_dir_path)
Resolve one edge to a shell command that runs in build_dir_path, as
Ninja runs it. Configure sandbox paths become relative to the build
directory, and tool paths become bare names (see
rewrite_tool_invocations).
Returns { command, tool_names, rspfile }, or nil when the rule has no
command. rspfile is { path, content } or nil.
Source: rules/c/cmake/ninja_graph.luau:473.
rewrite_tool_invocations(command)
Rewrite each tool in command position to its bare name, so that the tools of the replay action resolve it through PATH. An absolute host path, such as "/usr/bin/cc", is not present in a sandbox. Argument paths, such as "-I/abs/inc", stay.
Returns { command, tool_names }. tool_names has the bare names of the
absolute host paths, in first-use order. A path through the Imp tool
mount is rewritten but not added, because the mount of its tool already
covers it.
Source: rules/c/cmake/ninja_graph.luau:370.
sandbox_root_from_workdir(cmake_ninja_workdir, build_dir_path)
The sandbox root of the configure action. CMake makes the source and
build directories absolute, so each generated path starts with that root,
which a later replay sandbox does not have. CMake writes the absolute
build directory as cmake_ninja_workdir. With the workspace-relative
build directory, that gives the root. Returns nil when they do not agree.
Source: rules/c/cmake/ninja_graph.luau:392.