language

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Language

type Language interface {
	config.Configurer
	resolve.Resolver

	// Kinds returns a map of maps rule names (kinds) and information on how to
	// match and merge attributes that may be found in rules of those kinds. All
	// kinds of rules generated for this language may be found here.
	Kinds() map[string]rule.KindInfo

	// Loads returns .bzl files and symbols they define. Every rule generated by
	// GenerateRules, now or in the past, should be loadable from one of these
	// files.
	Loads() []rule.LoadInfo

	// GenerateRules extracts build metadata from source files in a directory.
	// GenerateRules is called in each directory where an update is requested
	// in depth-first post-order.
	//
	// c is the configuration for the current directory.
	// dir is the absolute path to the directory to scan.
	// rel is the relative path to the directory from the repository root.
	// f is the build file. It may be nil. It should not be modified.
	// subdirs is a list of subdirectory names.
	// regularFiles is a list of normal files in the directory.
	// genFiles is a list of generated files, found in outputs of rules.
	// otherEmpty and otherGen are lists of empty and generated rules created
	// by other languages processed before this language.
	//
	// empty is a list of empty rules that may be deleted after merge.
	// gen is a list of generated rules that may be updated or added.
	//
	// Any non-fatal errors this function encounters should be logged using
	// log.Print.
	GenerateRules(c *config.Config, dir, rel string, f *rule.File, subdirs, regularFiles, genFiles []string, otherEmpty, otherGen []*rule.Rule) (empty, gen []*rule.Rule)

	// Fix repairs deprecated usage of language-specific rules in f. This is
	// called before the file is indexed. Unless c.ShouldFix is true, fixes
	// that delete or rename rules should not be performed.
	Fix(c *config.Config, f *rule.File)
}

Language describes an extension for Gazelle that provides support for a set of Bazel rules.

Languages are used primarily by the fix and update commands. The order in which languages are used matters, since languages may depend on one another. For example, go depends on proto, since go_proto_libraries are generated from metadata stored in proto_libraries.

A single instance of Language is created for each fix / update run. Some state may be stored in this instance, but stateless behavior is encouraged, especially since some operations may be concurrent in the future.

Tasks languages are used for

* Configuration (embedded interface config.Configurer). Languages may define command line flags and alter the configuration in a directory based on directives in build files.

* Fixing deprecated usage of rules in build files.

* Generating rules from source files in a directory.

* Resolving library imports (embedded interface resolve.Resolver). For example, import strings like "github.com/foo/bar" in Go can be resolved into Bazel labels like "@com_github_foo_bar//:go_default_library".

Tasks languages support

* Generating load statements: languages list files and symbols that may be loaded.

* Merging generated rules into existing rules: languages provide metadata that helps with rule matching, merging, and deletion.

Directories

Path Synopsis
go
gen_std_package_list
gen_std_package_list reads a text file containing a list of packages (one per line) and generates a .go file containing a set of package names.
gen_std_package_list reads a text file containing a list of packages (one per line) and generates a .go file containing a set of package names.
Package proto provides support for protocol buffer rules.
Package proto provides support for protocol buffer rules.
gen

Jump to

Keyboard shortcuts

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