Remove the blueprint.Config type.
This change removes the definition of the Config type in the blueprint package. The type was simply an empty interface, and it seems more clear to just have that be explicit in the APIs. Change-Id: Ia23a978f28e8627f890f483f62536f67264401bf
This commit is contained in:
parent
7ab5f3c4ba
commit
6eb4d24fad
8 changed files with 36 additions and 41 deletions
|
@ -106,7 +106,7 @@ func isBootstrapBinaryModule(module blueprint.Module) bool {
|
|||
return isBinary
|
||||
}
|
||||
|
||||
func generatingBootstrapper(config blueprint.Config) bool {
|
||||
func generatingBootstrapper(config interface{}) bool {
|
||||
bootstrapConfig, ok := config.(Config)
|
||||
if ok {
|
||||
return bootstrapConfig.GeneratingBootstrapper()
|
||||
|
|
|
@ -16,7 +16,7 @@ var checkFile string
|
|||
|
||||
// topLevelBlueprintsFile is set by Main as a way to pass this information on to
|
||||
// the bootstrap build manifest generators. This information was not passed via
|
||||
// the Config object so as to allow the caller of Main to use whatever Config
|
||||
// the config object so as to allow the caller of Main to use whatever Config
|
||||
// object it wants.
|
||||
var topLevelBlueprintsFile string
|
||||
|
||||
|
@ -26,7 +26,7 @@ func init() {
|
|||
flag.StringVar(&checkFile, "c", "", "the existing file to check against")
|
||||
}
|
||||
|
||||
func Main(ctx *blueprint.Context, config blueprint.Config) {
|
||||
func Main(ctx *blueprint.Context, config interface{}) {
|
||||
if !flag.Parsed() {
|
||||
flag.Parse()
|
||||
}
|
||||
|
|
|
@ -45,11 +45,6 @@ type Context struct {
|
|||
requiredNinjaMicro int // For the ninja_required_version variable
|
||||
}
|
||||
|
||||
// A Config contains build configuration information that can affect the
|
||||
// contents of the Ninja build file is that will be generated. The specific
|
||||
// representation of this configuration information is not defined here.
|
||||
type Config interface{}
|
||||
|
||||
type Error struct {
|
||||
Err error
|
||||
Pos scanner.Position
|
||||
|
@ -564,7 +559,7 @@ func (c *Context) checkForDependencyCycles() (errs []error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (c *Context) PrepareBuildActions(config Config) []error {
|
||||
func (c *Context) PrepareBuildActions(config interface{}) []error {
|
||||
c.buildActionsReady = false
|
||||
|
||||
if !c.dependenciesReady {
|
||||
|
@ -614,7 +609,7 @@ func (c *Context) initSpecialVariables() {
|
|||
c.requiredNinjaMicro = 0
|
||||
}
|
||||
|
||||
func (c *Context) generateModuleBuildActions(config Config,
|
||||
func (c *Context) generateModuleBuildActions(config interface{},
|
||||
liveGlobals *liveTracker) []error {
|
||||
|
||||
visited := make(map[Module]bool)
|
||||
|
@ -662,7 +657,7 @@ func (c *Context) generateModuleBuildActions(config Config,
|
|||
return errs
|
||||
}
|
||||
|
||||
func (c *Context) generateSingletonBuildActions(config Config,
|
||||
func (c *Context) generateSingletonBuildActions(config interface{},
|
||||
liveGlobals *liveTracker) []error {
|
||||
|
||||
var errs []error
|
||||
|
|
|
@ -181,20 +181,20 @@ func (v *staticVariable) fullName(pkgNames map[*pkg]string) string {
|
|||
return packageNamespacePrefix(pkgNames[v.pkg_]) + v.name_
|
||||
}
|
||||
|
||||
func (v *staticVariable) value(Config) (*ninjaString, error) {
|
||||
func (v *staticVariable) value(interface{}) (*ninjaString, error) {
|
||||
return parseNinjaString(v.pkg_.scope, v.value_)
|
||||
}
|
||||
|
||||
type variableFunc struct {
|
||||
pkg_ *pkg
|
||||
name_ string
|
||||
value_ func(Config) (string, error)
|
||||
value_ func(interface{}) (string, error)
|
||||
}
|
||||
|
||||
// VariableFunc returns a Variable whose value is determined by a function that
|
||||
// takes a Config object as input and returns either the variable value or an
|
||||
// takes a interface{} object as input and returns either the variable value or an
|
||||
// error.
|
||||
func VariableFunc(name string, f func(Config) (string, error)) Variable {
|
||||
func VariableFunc(name string, f func(interface{}) (string, error)) Variable {
|
||||
err := validateNinjaName(name)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -212,7 +212,7 @@ func VariableFunc(name string, f func(Config) (string, error)) Variable {
|
|||
}
|
||||
|
||||
// VariableConfigMethod returns a Variable whose value is determined by calling
|
||||
// a method on the Config object. The method must take no arguments and return
|
||||
// a method on the interface{} object. The method must take no arguments and return
|
||||
// a single string that will be the variable's value.
|
||||
func VariableConfigMethod(name string, method interface{}) Variable {
|
||||
err := validateNinjaName(name)
|
||||
|
@ -225,7 +225,7 @@ func VariableConfigMethod(name string, method interface{}) Variable {
|
|||
methodValue := reflect.ValueOf(method)
|
||||
validateVariableMethod(name, methodValue)
|
||||
|
||||
fun := func(config Config) (string, error) {
|
||||
fun := func(config interface{}) (string, error) {
|
||||
result := methodValue.Call([]reflect.Value{reflect.ValueOf(config)})
|
||||
resultStr := result[0].Interface().(string)
|
||||
return resultStr, nil
|
||||
|
@ -252,7 +252,7 @@ func (v *variableFunc) fullName(pkgNames map[*pkg]string) string {
|
|||
return packageNamespacePrefix(pkgNames[v.pkg_]) + v.name_
|
||||
}
|
||||
|
||||
func (v *variableFunc) value(config Config) (*ninjaString, error) {
|
||||
func (v *variableFunc) value(config interface{}) (*ninjaString, error) {
|
||||
value, err := v.value_(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -301,7 +301,7 @@ func (v *argVariable) fullName(pkgNames map[*pkg]string) string {
|
|||
return v.name_
|
||||
}
|
||||
|
||||
func (v *argVariable) value(config Config) (*ninjaString, error) {
|
||||
func (v *argVariable) value(config interface{}) (*ninjaString, error) {
|
||||
return nil, errVariableIsArg
|
||||
}
|
||||
|
||||
|
@ -340,7 +340,7 @@ func (p *staticPool) fullName(pkgNames map[*pkg]string) string {
|
|||
return packageNamespacePrefix(pkgNames[p.pkg_]) + p.name_
|
||||
}
|
||||
|
||||
func (p *staticPool) def(config Config) (*poolDef, error) {
|
||||
func (p *staticPool) def(config interface{}) (*poolDef, error) {
|
||||
def, err := parsePoolParams(p.pkg_.scope, &p.params)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("error parsing PoolParams for %s: %s", p.name_, err))
|
||||
|
@ -351,10 +351,10 @@ func (p *staticPool) def(config Config) (*poolDef, error) {
|
|||
type poolFunc struct {
|
||||
pkg_ *pkg
|
||||
name_ string
|
||||
paramsFunc func(Config) (PoolParams, error)
|
||||
paramsFunc func(interface{}) (PoolParams, error)
|
||||
}
|
||||
|
||||
func PoolFunc(name string, f func(Config) (PoolParams, error)) Pool {
|
||||
func PoolFunc(name string, f func(interface{}) (PoolParams, error)) Pool {
|
||||
err := validateNinjaName(name)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -383,7 +383,7 @@ func (p *poolFunc) fullName(pkgNames map[*pkg]string) string {
|
|||
return packageNamespacePrefix(pkgNames[p.pkg_]) + p.name_
|
||||
}
|
||||
|
||||
func (p *poolFunc) def(config Config) (*poolDef, error) {
|
||||
func (p *poolFunc) def(config interface{}) (*poolDef, error) {
|
||||
params, err := p.paramsFunc(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -444,7 +444,7 @@ func (r *staticRule) fullName(pkgNames map[*pkg]string) string {
|
|||
return packageNamespacePrefix(pkgNames[r.pkg_]) + r.name_
|
||||
}
|
||||
|
||||
func (r *staticRule) def(Config) (*ruleDef, error) {
|
||||
func (r *staticRule) def(interface{}) (*ruleDef, error) {
|
||||
def, err := parseRuleParams(r.scope(), &r.params)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("error parsing RuleParams for %s: %s", r.name_, err))
|
||||
|
@ -469,12 +469,12 @@ func (r *staticRule) isArg(argName string) bool {
|
|||
type ruleFunc struct {
|
||||
pkg_ *pkg
|
||||
name_ string
|
||||
paramsFunc func(Config) (RuleParams, error)
|
||||
paramsFunc func(interface{}) (RuleParams, error)
|
||||
argNames map[string]bool
|
||||
scope_ *scope
|
||||
}
|
||||
|
||||
func RuleFunc(name string, f func(Config) (RuleParams, error),
|
||||
func RuleFunc(name string, f func(interface{}) (RuleParams, error),
|
||||
argNames ...string) Rule {
|
||||
|
||||
pkg := callerPackage()
|
||||
|
@ -517,7 +517,7 @@ func (r *ruleFunc) fullName(pkgNames map[*pkg]string) string {
|
|||
return packageNamespacePrefix(pkgNames[r.pkg_]) + r.name_
|
||||
}
|
||||
|
||||
func (r *ruleFunc) def(config Config) (*ruleDef, error) {
|
||||
func (r *ruleFunc) def(config interface{}) (*ruleDef, error) {
|
||||
params, err := r.paramsFunc(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -560,7 +560,7 @@ func (r *builtinRule) fullName(pkgNames map[*pkg]string) string {
|
|||
return r.name_
|
||||
}
|
||||
|
||||
func (r *builtinRule) def(config Config) (*ruleDef, error) {
|
||||
func (r *builtinRule) def(config interface{}) (*ruleDef, error) {
|
||||
return nil, errRuleIsBuiltin
|
||||
}
|
||||
|
||||
|
|
|
@ -5,14 +5,14 @@ package blueprint
|
|||
// definition. When an entity is made live its value is computed based on the
|
||||
// configuration.
|
||||
type liveTracker struct {
|
||||
config Config // Used to evaluate variable, rule, and pool values.
|
||||
config interface{} // Used to evaluate variable, rule, and pool values.
|
||||
|
||||
variables map[Variable]*ninjaString
|
||||
pools map[Pool]*poolDef
|
||||
rules map[Rule]*ruleDef
|
||||
}
|
||||
|
||||
func newLiveTracker(config Config) *liveTracker {
|
||||
func newLiveTracker(config interface{}) *liveTracker {
|
||||
return &liveTracker{
|
||||
config: config,
|
||||
variables: make(map[Variable]*ninjaString),
|
||||
|
|
|
@ -12,7 +12,7 @@ type Module interface {
|
|||
type ModuleContext interface {
|
||||
ModuleName() string
|
||||
ModuleDir() string
|
||||
Config() Config
|
||||
Config() interface{}
|
||||
|
||||
ModuleErrorf(fmt string, args ...interface{})
|
||||
PropertyErrorf(property, fmt string, args ...interface{})
|
||||
|
@ -29,7 +29,7 @@ var _ ModuleContext = (*moduleContext)(nil)
|
|||
|
||||
type moduleContext struct {
|
||||
context *Context
|
||||
config Config
|
||||
config interface{}
|
||||
module Module
|
||||
scope *localScope
|
||||
info *moduleInfo
|
||||
|
@ -47,7 +47,7 @@ func (m *moduleContext) ModuleDir() string {
|
|||
return filepath.Dir(m.info.relBlueprintFile)
|
||||
}
|
||||
|
||||
func (m *moduleContext) Config() Config {
|
||||
func (m *moduleContext) Config() interface{} {
|
||||
return m.config
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ type Variable interface {
|
|||
pkg() *pkg
|
||||
name() string // "foo"
|
||||
fullName(pkgNames map[*pkg]string) string // "pkg.foo" or "path/to/pkg.foo"
|
||||
value(config Config) (*ninjaString, error)
|
||||
value(config interface{}) (*ninjaString, error)
|
||||
}
|
||||
|
||||
// A Pool represents a Ninja pool that will be written to the output .ninja
|
||||
|
@ -23,7 +23,7 @@ type Pool interface {
|
|||
pkg() *pkg
|
||||
name() string // "foo"
|
||||
fullName(pkgNames map[*pkg]string) string // "pkg.foo" or "path/to/pkg.foo"
|
||||
def(config Config) (*poolDef, error)
|
||||
def(config interface{}) (*poolDef, error)
|
||||
}
|
||||
|
||||
// A Rule represents a Ninja build rule that will be written to the output
|
||||
|
@ -32,7 +32,7 @@ type Rule interface {
|
|||
pkg() *pkg
|
||||
name() string // "foo"
|
||||
fullName(pkgNames map[*pkg]string) string // "pkg.foo" or "path/to/pkg.foo"
|
||||
def(config Config) (*ruleDef, error)
|
||||
def(config interface{}) (*ruleDef, error)
|
||||
scope() *scope
|
||||
isArg(argName string) bool
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ func (l *localVariable) fullName(pkgNames map[*pkg]string) string {
|
|||
return l.namePrefix + l.name_
|
||||
}
|
||||
|
||||
func (l *localVariable) value(Config) (*ninjaString, error) {
|
||||
func (l *localVariable) value(interface{}) (*ninjaString, error) {
|
||||
return l.value_, nil
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ func (l *localRule) fullName(pkgNames map[*pkg]string) string {
|
|||
return l.namePrefix + l.name_
|
||||
}
|
||||
|
||||
func (l *localRule) def(Config) (*ruleDef, error) {
|
||||
func (l *localRule) def(interface{}) (*ruleDef, error) {
|
||||
return l.def_, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ type Singleton interface {
|
|||
}
|
||||
|
||||
type SingletonContext interface {
|
||||
Config() Config
|
||||
Config() interface{}
|
||||
|
||||
ModuleName(module Module) string
|
||||
ModuleDir(module Module) string
|
||||
|
@ -38,7 +38,7 @@ var _ SingletonContext = (*singletonContext)(nil)
|
|||
|
||||
type singletonContext struct {
|
||||
context *Context
|
||||
config Config
|
||||
config interface{}
|
||||
scope *localScope
|
||||
|
||||
errs []error
|
||||
|
@ -46,7 +46,7 @@ type singletonContext struct {
|
|||
actionDefs localBuildActions
|
||||
}
|
||||
|
||||
func (s *singletonContext) Config() Config {
|
||||
func (s *singletonContext) Config() interface{} {
|
||||
return s.config
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue