Documentation ¶
Overview ¶
Package merger provides methods for merging parsed BUILD files.
Index ¶
- func FixFile(c *config.Config, oldFile *bf.File) *bf.File
- func FixFileMinor(c *config.Config, oldFile *bf.File) *bf.File
- func FixLoads(oldFile *bf.File) *bf.File
- func MergeFile(genRules []bf.Expr, empty []bf.Expr, oldFile *bf.File, attrs MergeableAttrs) (mergedFile *bf.File, mergedRules []bf.Expr)
- type MergeableAttrs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FixFile ¶
FixFile updates rules in oldFile that were generated by an older version of Gazelle to a newer form that can be merged with freshly generated rules.
FixLoads should be called after this, since it will fix load statements that may be broken by transformations applied by this function.
func FixFileMinor ¶
FixFileMinor updates rules in oldFile that were generated by an older version of Gazelle to a newer form that can be merged with freshly generated rules.
FixFileMinor includes only small, low-risk fixes that can be applied in update mode. When both FixFileMinor and FixFile are called, FixFileMinor should be called first.
FixLoads should be called after this, since it will fix load statements that may be broken by transformations applied by this function.
func FixLoads ¶
FixLoads removes loads of unused go rules and adds loads of newly used rules. This should be called after FixFile and MergeWithExisting, since symbols may be introduced that aren't loaded.
func MergeFile ¶
func MergeFile(genRules []bf.Expr, empty []bf.Expr, oldFile *bf.File, attrs MergeableAttrs) (mergedFile *bf.File, mergedRules []bf.Expr)
MergeFile merges the rules in genRules with matching rules in oldFile and adds unmatched rules to the end of the merged file. MergeFile also merges rules in empty with matching rules in oldFile 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 ¶
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 )