buildtag

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsWaBuild

func IsWaBuild(line string) bool

IsWaBuild reports whether the line of text is a “#wa:build” constraint. It only checks the prefix of the text, not that the expression itself parses.

Types

type AndExpr

type AndExpr struct {
	X, Y Expr
}

An AndExpr represents the expression X && Y.

func (*AndExpr) Eval

func (x *AndExpr) Eval(ok func(tag string) bool) bool

func (*AndExpr) String

func (x *AndExpr) String() string

type Expr

type Expr interface {
	// String returns the string form of the expression,
	// using the boolean syntax used in #wa:build lines.
	String() string

	// Eval reports whether the expression evaluates to true.
	// It calls ok(tag) as needed to find out whether a given build tag
	// is satisfied by the current build configuration.
	Eval(ok func(tag string) bool) bool
	// contains filtered or unexported methods
}

An Expr is a build tag constraint expression. The underlying concrete type is *AndExpr, *OrExpr, *NotExpr, or *TagExpr.

func Parse

func Parse(line string) (Expr, error)

Parse parses a single build constraint line of the form “#wa:build ...” and returns the corresponding boolean expression.

type NotExpr

type NotExpr struct {
	X Expr
}

A NotExpr represents the expression !X (the negation of X).

func (*NotExpr) Eval

func (x *NotExpr) Eval(ok func(tag string) bool) bool

func (*NotExpr) String

func (x *NotExpr) String() string

type OrExpr

type OrExpr struct {
	X, Y Expr
}

An OrExpr represents the expression X || Y.

func (*OrExpr) Eval

func (x *OrExpr) Eval(ok func(tag string) bool) bool

func (*OrExpr) String

func (x *OrExpr) String() string

type SyntaxError

type SyntaxError struct {
	Offset int    // byte offset in input where error was detected
	Err    string // description of error
}

A SyntaxError reports a syntax error in a parsed build expression.

func (*SyntaxError) Error

func (e *SyntaxError) Error() string

type TagExpr

type TagExpr struct {
	Tag string // for example, “linux” or “cgo”
}

A TagExpr is an Expr for the single tag Tag.

func (*TagExpr) Eval

func (x *TagExpr) Eval(ok func(tag string) bool) bool

func (*TagExpr) String

func (x *TagExpr) String() string

Jump to

Keyboard shortcuts

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