graph

package
v0.0.4-d-oss Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package graph builds and represents the dependency graph derived from parsed ninja files, resolving targets, inputs, and discovered dependencies into the nodes the build engine schedules over.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Graph

type Graph struct {
	BuildStartTime time.Time
	GoalTargets    []string
	Defaults       []string
	BuildDir       string
	Pools          map[string]*ninja.Pool
	Goals          xxmap.ObjectsSet[Node]
	Targets        xxmap.StringMap[*Node]
	Nodes          xxmap.ObjectsSet[Node]
	Files          xxmap.StringsSet
}

Graph holds the resolved build graph and the metadata needed to drive a build.

func NewGraph

func NewGraph() *Graph

NewGraph returns an empty Graph ready to be populated by Load.

func (*Graph) Load

func (g *Graph) Load(ctx context.Context, ninjas *ninja.ParsedFiles, goals []string, withDeps bool) error

Load resolves the supplied goals against ninjas and populates g with the transitive build graph. If withDeps is true, the graph also includes dependencies recorded in .ninja_deps.

type GraphBackend

type GraphBackend interface {
	GraphLoading() error
	GraphLoaded(graph *Graph) error
	GetDeps(n *Node) ([]string, error)
}

GraphBackend is implemented by backends that participate in graph loading.

type Node

type Node struct {
	Targets     []string
	Build       *ninja.Build
	Inputs      map[*Node]int
	Outputs     map[*Node]int
	Validations map[*Node]struct{}
	Deps        []string
	Data        any
	// contains filtered or unexported fields
}

Node is a vertex in the build graph: one build edge with its inputs, outputs, and optional validations.

func (*Node) AddTarget

func (n *Node) AddTarget(t string)

AddTarget records t as one of the outputs produced by n.

func (*Node) Command

func (n *Node) Command() string

Command returns the expanded command line for n.

func (*Node) DepFile

func (n *Node) DepFile() string

DepFile returns the expanded value of the build's depfile attribute.

func (*Node) Description

func (n *Node) Description() string

Description returns the rule's expanded "description" field, falling back to the command and finally the node's first target.

func (*Node) InDegree

func (n *Node) InDegree() int

InDegree returns the number of incoming edges, summed across all inputs.

func (*Node) OutDegree

func (n *Node) OutDegree() int

OutDegree returns the number of outgoing edges, summed across all outputs.

func (*Node) Pool

func (n *Node) Pool() string

Pool returns the name of the pool that owns n, or "default" if none was specified.

func (*Node) RSPContent

func (n *Node) RSPContent() string

RSPContent returns the expanded contents of the response file, if any.

func (*Node) RSPFile

func (n *Node) RSPFile() string

RSPFile returns the expanded path of the response file, if any.

func (*Node) String

func (n *Node) String() string

String returns the first declared target of n.

func (*Node) TargetsMatch

func (n *Node) TargetsMatch(re *regexp.Regexp) bool

TargetsMatch reports whether any of n's declared targets match re.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL