parse

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 parse parses ninja build files and depfiles into the data structures consumed by the rest of ninjago, and defines the ParseBackend hook used to source file contents and observe the parsed result.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(ctx context.Context, fn string) (*ninja.ParsedFiles, error)

Parse loads the ninja file at fn and every subninja it includes, returning the parsed and expanded result.

func ParseNinjaFile

func ParseNinjaFile(ctx context.Context, name string, full []byte, parent *ninja.NinjaFile) (*ninja.NinjaFile, error)

ParseNinjaFile parses the contents of a ninja file. The input is split into segments and parsed in parallel using params.CliFlags.ConcurrencyLevel goroutines.

func ReadDepFile

func ReadDepFile(targets []string, depFile string) ([]string, error)

ReadDepFile reads a .d file and returns the dependencies of the first target in "targets" that appears in it.

func ResolveDeps

func ResolveDeps(targets []string, depsList []*DepsRecord) ([]string, error)

ResolveDeps returns the dependencies of the first record in depsList whose target matches one of targets, with each dependency resolved through any symlinks.

Types

type DepsRecord

type DepsRecord struct {
	Target string
	Deps   []string
	// contains filtered or unexported fields
}

DepsRecord is a single Makefile-style dependency record: one target and the list of files it depends on.

func ParseDepFile

func ParseDepFile(fileName string) ([]*DepsRecord, error)

ParseDepFile mmap-reads the depfile at fileName and parses its records.

func ParseDeps

func ParseDeps(buf []byte) ([]*DepsRecord, error)

ParseDeps parses Makefile-style dependency records from buf.

type ParseBackend

type ParseBackend interface {
	ReadNinjaFile(file string) ([]byte, ReleaseFileFunc, error)
	Parsed(ninjas *ninja.ParsedFiles) error
}

ParseBackend is implemented by backends that supply ninja file contents to the parser and observe the parsed result.

type ReleaseFileFunc

type ReleaseFileFunc func() error

ReleaseFileFunc releases the resources associated with a previously read ninja file (e.g. unmaps a memory-mapped buffer).

Jump to

Keyboard shortcuts

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