merger

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package merger provides methods for merging parsed BUILD files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckGazelleLoaded added in v0.11.0

func CheckGazelleLoaded(f *bf.File) error

CheckGazelleLoaded searches the given WORKSPACE file for a repository named "bazel_gazelle". If no such repository is found *and* the repo is not declared with a directive *and* at least one load statement mentions the repository, a descriptive error will be returned.

This should be called after modifications have been made to WORKSPACE (i.e., after FixLoads) before writing it to disk.

func FixFile

func FixFile(c *config.Config, f *bf.File)

FixFile updates rules in f that were generated by an older version of Gazelle to a newer form that can be merged with freshly generated rules.

If c.ShouldFix is true, FixFile may perform potentially destructive transformations, such as squashing or deleting rules (e.g., cgo_library). If not, FixFile will perform a set of low-risk transformations (e.g., removing unused attributes) and will print a message about transformations it would have performed.

FixLoads should be called after this, since it will fix load statements that may be broken by transformations applied by this function.

func FixLoads

func FixLoads(f *bf.File)

FixLoads removes loads of unused go rules and adds loads of newly used rules. This should be called after FixFile and MergeFile, since symbols may be introduced that aren't loaded.

func FixWorkspace added in v0.11.0

func FixWorkspace(f *bf.File)

FixWorkspace updates rules in the WORKSPACE file f that were used with an older version of rules_go or gazelle.

func MergeFile

func MergeFile(genRules []bf.Expr, empty []bf.Expr, f *bf.File, attrs MergeableAttrs) (mergedRules []bf.Expr)

MergeFile merges the rules in genRules with matching rules in f and adds unmatched rules to the end of the merged file. MergeFile also merges rules in empty with matching rules in f and deletes rules that are empty after merging. attrs is the set of attributes to merge. Attributes not in this set will be left alone if they already exist.

Types

type MergeableAttrs

type MergeableAttrs map[string]map[string]bool

MergableAttrs is the set of attribute names for each kind of rule that may be merged. When an attribute is mergeable, a generated value may replace or augment an existing value. If an attribute is not mergeable, existing values are preserved. Generated non-mergeable attributes may still be added to a rule if there is no corresponding existing attribute.

var (
	// PreResolveAttrs is the set of attributes that should be merged before
	// dependency resolution, i.e., everything except deps.
	PreResolveAttrs MergeableAttrs

	// PostResolveAttrs is the set of attributes that should be merged after
	// dependency resolution, i.e., deps.
	PostResolveAttrs MergeableAttrs

	// RepoAttrs is the set of attributes that should be merged in repository
	// rules in WORKSPACE.
	RepoAttrs MergeableAttrs
)

Jump to

Keyboard shortcuts

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