Merge changes Ia17b2bcb,Ic71892c3,Id2b23b9e,I435ee7aa,I85112506, ... am: 72ea641dff
am: 98a6f300fa
Change-Id: I84683c2204afb5792ec11e2c608dca288e9431ec
This commit is contained in:
commit
31de2eaf51
|
@ -78,10 +78,12 @@ bootstrap_go_package {
|
|||
"android/env.go",
|
||||
],
|
||||
testSrcs: [
|
||||
"android/android_test.go",
|
||||
"android/arch_test.go",
|
||||
"android/config_test.go",
|
||||
"android/expand_test.go",
|
||||
"android/module_test.go",
|
||||
"android/mutator_test.go",
|
||||
"android/namespace_test.go",
|
||||
"android/neverallow_test.go",
|
||||
"android/onceper_test.go",
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
// Copyright 2019 Google Inc. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package android
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var buildDir string
|
||||
|
||||
func setUp() {
|
||||
var err error
|
||||
buildDir, err = ioutil.TempDir("", "soong_android_test")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func tearDown() {
|
||||
os.RemoveAll(buildDir)
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
run := func() int {
|
||||
setUp()
|
||||
defer tearDown()
|
||||
|
||||
return m.Run()
|
||||
}
|
||||
|
||||
os.Exit(run())
|
||||
}
|
|
@ -80,6 +80,9 @@ func (d *DefaultsModuleBase) properties() []interface{} {
|
|||
return d.defaultableProperties
|
||||
}
|
||||
|
||||
func (d *DefaultsModuleBase) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||
}
|
||||
|
||||
func InitDefaultsModule(module DefaultableModule) {
|
||||
module.AddProperties(
|
||||
&hostAndDeviceProperties{},
|
||||
|
|
|
@ -0,0 +1,116 @@
|
|||
// Copyright 2019 Google Inc. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package android
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/blueprint/proptools"
|
||||
)
|
||||
|
||||
type defaultsTestProperties struct {
|
||||
Foo []string
|
||||
}
|
||||
|
||||
type defaultsTestModule struct {
|
||||
ModuleBase
|
||||
DefaultableModuleBase
|
||||
properties defaultsTestProperties
|
||||
}
|
||||
|
||||
func (d *defaultsTestModule) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||
ctx.Build(pctx, BuildParams{
|
||||
Rule: Touch,
|
||||
Output: PathForModuleOut(ctx, "out"),
|
||||
})
|
||||
}
|
||||
|
||||
func defaultsTestModuleFactory() Module {
|
||||
module := &defaultsTestModule{}
|
||||
module.AddProperties(&module.properties)
|
||||
InitDefaultableModule(module)
|
||||
InitAndroidModule(module)
|
||||
return module
|
||||
}
|
||||
|
||||
type defaultsTestDefaults struct {
|
||||
ModuleBase
|
||||
DefaultsModuleBase
|
||||
}
|
||||
|
||||
func defaultsTestDefaultsFactory() Module {
|
||||
defaults := &defaultsTestDefaults{}
|
||||
defaults.AddProperties(&defaultsTestProperties{})
|
||||
InitDefaultsModule(defaults)
|
||||
return defaults
|
||||
}
|
||||
|
||||
func TestDefaultsAllowMissingDependencies(t *testing.T) {
|
||||
config := TestConfig(buildDir, nil)
|
||||
config.TestProductVariables.Allow_missing_dependencies = proptools.BoolPtr(true)
|
||||
|
||||
ctx := NewTestContext()
|
||||
ctx.SetAllowMissingDependencies(true)
|
||||
|
||||
ctx.RegisterModuleType("test", ModuleFactoryAdaptor(defaultsTestModuleFactory))
|
||||
ctx.RegisterModuleType("defaults", ModuleFactoryAdaptor(defaultsTestDefaultsFactory))
|
||||
|
||||
ctx.PreArchMutators(RegisterDefaultsPreArchMutators)
|
||||
|
||||
ctx.Register()
|
||||
|
||||
bp := `
|
||||
defaults {
|
||||
name: "defaults",
|
||||
defaults: ["missing"],
|
||||
foo: ["defaults"],
|
||||
}
|
||||
|
||||
test {
|
||||
name: "missing_defaults",
|
||||
defaults: ["missing"],
|
||||
foo: ["module"],
|
||||
}
|
||||
|
||||
test {
|
||||
name: "missing_transitive_defaults",
|
||||
defaults: ["defaults"],
|
||||
foo: ["module"],
|
||||
}
|
||||
`
|
||||
|
||||
ctx.MockFileSystem(map[string][]byte{
|
||||
"Android.bp": []byte(bp),
|
||||
})
|
||||
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
FailIfErrored(t, errs)
|
||||
|
||||
missingDefaults := ctx.ModuleForTests("missing_defaults", "").Output("out")
|
||||
missingTransitiveDefaults := ctx.ModuleForTests("missing_transitive_defaults", "").Output("out")
|
||||
|
||||
if missingDefaults.Rule != ErrorRule {
|
||||
t.Errorf("expected missing_defaults rule to be ErrorRule, got %#v", missingDefaults.Rule)
|
||||
}
|
||||
|
||||
if g, w := missingDefaults.Args["error"], "module missing_defaults missing dependencies: missing\n"; g != w {
|
||||
t.Errorf("want error %q, got %q", w, g)
|
||||
}
|
||||
|
||||
// TODO: missing transitive defaults is currently not handled
|
||||
_ = missingTransitiveDefaults
|
||||
}
|
|
@ -56,14 +56,40 @@ type BuildParams struct {
|
|||
type ModuleBuildParams BuildParams
|
||||
|
||||
// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
|
||||
// a Config instead of an interface{}, plus some extra methods that return Android-specific information
|
||||
// a Config instead of an interface{}, and some methods have been wrapped to use an android.Module
|
||||
// instead of a blueprint.Module, plus some extra methods that return Android-specific information
|
||||
// about the current module.
|
||||
type BaseModuleContext interface {
|
||||
Module() Module
|
||||
ModuleName() string
|
||||
ModuleDir() string
|
||||
ModuleType() string
|
||||
Config() Config
|
||||
|
||||
OtherModuleName(m blueprint.Module) string
|
||||
OtherModuleDir(m blueprint.Module) string
|
||||
OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{})
|
||||
OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag
|
||||
OtherModuleExists(name string) bool
|
||||
|
||||
GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module
|
||||
GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
|
||||
GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
|
||||
|
||||
VisitDirectDepsBlueprint(visit func(blueprint.Module))
|
||||
VisitDirectDeps(visit func(Module))
|
||||
VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
|
||||
VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
|
||||
// Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
|
||||
VisitDepsDepthFirst(visit func(Module))
|
||||
// Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
|
||||
VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
|
||||
WalkDeps(visit func(Module, Module) bool)
|
||||
WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool)
|
||||
// GetWalkPath is supposed to be called in visit function passed in WalkDeps()
|
||||
// and returns a top-down dependency path from a start module to current child module.
|
||||
GetWalkPath() []Module
|
||||
|
||||
ContainsProperty(name string) bool
|
||||
Errorf(pos scanner.Position, fmt string, args ...interface{})
|
||||
ModuleErrorf(fmt string, args ...interface{})
|
||||
|
@ -76,9 +102,14 @@ type BaseModuleContext interface {
|
|||
// file that does not match the pattern is added to a searched directory.
|
||||
GlobWithDeps(pattern string, excludes []string) ([]string, error)
|
||||
|
||||
Glob(globPattern string, excludes []string) Paths
|
||||
GlobFiles(globPattern string, excludes []string) Paths
|
||||
|
||||
Fs() pathtools.FileSystem
|
||||
AddNinjaFileDeps(deps ...string)
|
||||
|
||||
AddMissingDependencies(missingDeps []string)
|
||||
|
||||
Target() Target
|
||||
TargetPrimary() bool
|
||||
MultiTargets() []Target
|
||||
|
@ -114,8 +145,6 @@ type ModuleContext interface {
|
|||
ExpandSources(srcFiles, excludes []string) Paths
|
||||
ExpandSource(srcFile, prop string) Path
|
||||
ExpandOptionalSource(srcFile *string, prop string) OptionalPath
|
||||
Glob(globPattern string, excludes []string) Paths
|
||||
GlobFiles(globPattern string, excludes []string) Paths
|
||||
|
||||
InstallExecutable(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
|
||||
InstallFile(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
|
||||
|
@ -123,8 +152,6 @@ type ModuleContext interface {
|
|||
InstallAbsoluteSymlink(installPath OutputPath, name string, absPath string) OutputPath
|
||||
CheckbuildFile(srcPath Path)
|
||||
|
||||
AddMissingDependencies(deps []string)
|
||||
|
||||
InstallInData() bool
|
||||
InstallInSanitizerDir() bool
|
||||
InstallInRecovery() bool
|
||||
|
@ -133,30 +160,8 @@ type ModuleContext interface {
|
|||
HostRequiredModuleNames() []string
|
||||
TargetRequiredModuleNames() []string
|
||||
|
||||
// android.ModuleContext methods
|
||||
// These are duplicated instead of embedded so that can eventually be wrapped to take an
|
||||
// android.Module instead of a blueprint.Module
|
||||
OtherModuleName(m blueprint.Module) string
|
||||
OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{})
|
||||
OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag
|
||||
|
||||
GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module
|
||||
GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
|
||||
GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
|
||||
|
||||
ModuleSubDir() string
|
||||
|
||||
VisitDirectDepsBlueprint(visit func(blueprint.Module))
|
||||
VisitDirectDeps(visit func(Module))
|
||||
VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
|
||||
VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
|
||||
// Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
|
||||
VisitDepsDepthFirst(visit func(Module))
|
||||
// Deprecated: use WalkDeps instead to support multiple dependency tags on the same module
|
||||
VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
|
||||
WalkDeps(visit func(Module, Module) bool)
|
||||
WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool)
|
||||
|
||||
Variable(pctx PackageContext, name, value string)
|
||||
Rule(pctx PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule
|
||||
// Similar to blueprint.ModuleContext.Build, but takes Paths instead of []string,
|
||||
|
@ -338,6 +343,8 @@ type commonProperties struct {
|
|||
SkipInstall bool `blueprint:"mutated"`
|
||||
|
||||
NamespaceExportedToMake bool `blueprint:"mutated"`
|
||||
|
||||
MissingDeps []string `blueprint:"mutated"`
|
||||
}
|
||||
|
||||
type hostAndDeviceProperties struct {
|
||||
|
@ -837,14 +844,22 @@ func (m *ModuleBase) baseModuleContextFactory(ctx blueprint.BaseModuleContext) b
|
|||
func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
|
||||
ctx := &moduleContext{
|
||||
module: m.module,
|
||||
ModuleContext: blueprintCtx,
|
||||
bp: blueprintCtx,
|
||||
baseModuleContext: m.baseModuleContextFactory(blueprintCtx),
|
||||
installDeps: m.computeInstallDeps(blueprintCtx),
|
||||
installFiles: m.installFiles,
|
||||
missingDeps: blueprintCtx.GetMissingDependencies(),
|
||||
variables: make(map[string]string),
|
||||
}
|
||||
|
||||
// Temporarily continue to call blueprintCtx.GetMissingDependencies() to maintain the previous behavior of never
|
||||
// reporting missing dependency errors in Blueprint when AllowMissingDependencies == true.
|
||||
// TODO: This will be removed once defaults modules handle missing dependency errors
|
||||
blueprintCtx.GetMissingDependencies()
|
||||
|
||||
// For the final GenerateAndroidBuildActions pass, require that all visited dependencies Soong modules and
|
||||
// are enabled.
|
||||
ctx.baseModuleContext.strictVisitDeps = true
|
||||
|
||||
if ctx.config.captureBuild {
|
||||
ctx.ruleParams = make(map[blueprint.Rule]blueprint.RuleParams)
|
||||
}
|
||||
|
@ -901,6 +916,12 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
|
|||
noticePath := filepath.Join(ctx.ModuleDir(), notice)
|
||||
m.noticeFile = ExistentPathForSource(ctx, noticePath)
|
||||
}
|
||||
} else if ctx.Config().AllowMissingDependencies() {
|
||||
// If the module is not enabled it will not create any build rules, nothing will call
|
||||
// ctx.GetMissingDependencies(), and blueprint will consider the missing dependencies to be unhandled
|
||||
// and report them as an error even when AllowMissingDependencies = true. Call
|
||||
// ctx.GetMissingDependencies() here to tell blueprint not to handle them.
|
||||
ctx.GetMissingDependencies()
|
||||
}
|
||||
|
||||
if m == ctx.FinalModule().(Module).base() {
|
||||
|
@ -923,15 +944,18 @@ type baseModuleContext struct {
|
|||
debug bool
|
||||
kind moduleKind
|
||||
config Config
|
||||
|
||||
walkPath []Module
|
||||
|
||||
strictVisitDeps bool // If true, enforce that all dependencies are enabled
|
||||
}
|
||||
|
||||
type moduleContext struct {
|
||||
blueprint.ModuleContext
|
||||
bp blueprint.ModuleContext
|
||||
baseModuleContext
|
||||
installDeps Paths
|
||||
installFiles Paths
|
||||
checkbuildFiles Paths
|
||||
missingDeps []string
|
||||
module Module
|
||||
|
||||
// For tests
|
||||
|
@ -940,21 +964,16 @@ type moduleContext struct {
|
|||
variables map[string]string
|
||||
}
|
||||
|
||||
func (m *moduleContext) ninjaError(desc string, outputs []string, err error) {
|
||||
m.ModuleContext.Build(pctx.PackageContext, blueprint.BuildParams{
|
||||
func (m *moduleContext) ninjaError(params BuildParams, err error) (PackageContext, BuildParams) {
|
||||
return pctx, BuildParams{
|
||||
Rule: ErrorRule,
|
||||
Description: desc,
|
||||
Outputs: outputs,
|
||||
Optional: true,
|
||||
Description: params.Description,
|
||||
Output: params.Output,
|
||||
Outputs: params.Outputs,
|
||||
Args: map[string]string{
|
||||
"error": err.Error(),
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (m *moduleContext) Config() Config {
|
||||
return m.ModuleContext.Config().(Config)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *moduleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) {
|
||||
|
@ -1006,13 +1025,13 @@ func (m *moduleContext) Variable(pctx PackageContext, name, value string) {
|
|||
m.variables[name] = value
|
||||
}
|
||||
|
||||
m.ModuleContext.Variable(pctx.PackageContext, name, value)
|
||||
m.bp.Variable(pctx.PackageContext, name, value)
|
||||
}
|
||||
|
||||
func (m *moduleContext) Rule(pctx PackageContext, name string, params blueprint.RuleParams,
|
||||
argNames ...string) blueprint.Rule {
|
||||
|
||||
rule := m.ModuleContext.Rule(pctx.PackageContext, name, params, argNames...)
|
||||
rule := m.bp.Rule(pctx.PackageContext, name, params, argNames...)
|
||||
|
||||
if m.config.captureBuild {
|
||||
m.ruleParams[rule] = params
|
||||
|
@ -1022,65 +1041,79 @@ func (m *moduleContext) Rule(pctx PackageContext, name string, params blueprint.
|
|||
}
|
||||
|
||||
func (m *moduleContext) Build(pctx PackageContext, params BuildParams) {
|
||||
if params.Description != "" {
|
||||
params.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}"
|
||||
}
|
||||
|
||||
if missingDeps := m.GetMissingDependencies(); len(missingDeps) > 0 {
|
||||
pctx, params = m.ninjaError(params, fmt.Errorf("module %s missing dependencies: %s\n",
|
||||
m.ModuleName(), strings.Join(missingDeps, ", ")))
|
||||
}
|
||||
|
||||
if m.config.captureBuild {
|
||||
m.buildParams = append(m.buildParams, params)
|
||||
}
|
||||
|
||||
bparams := convertBuildParams(params)
|
||||
m.bp.Build(pctx.PackageContext, convertBuildParams(params))
|
||||
}
|
||||
|
||||
if bparams.Description != "" {
|
||||
bparams.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}"
|
||||
}
|
||||
func (b *baseModuleContext) Module() Module {
|
||||
module, _ := b.BaseModuleContext.Module().(Module)
|
||||
return module
|
||||
}
|
||||
|
||||
if m.missingDeps != nil {
|
||||
m.ninjaError(bparams.Description, bparams.Outputs,
|
||||
fmt.Errorf("module %s missing dependencies: %s\n",
|
||||
m.ModuleName(), strings.Join(m.missingDeps, ", ")))
|
||||
return
|
||||
}
|
||||
|
||||
m.ModuleContext.Build(pctx.PackageContext, bparams)
|
||||
func (b *baseModuleContext) Config() Config {
|
||||
return b.BaseModuleContext.Config().(Config)
|
||||
}
|
||||
|
||||
func (m *moduleContext) GetMissingDependencies() []string {
|
||||
return m.missingDeps
|
||||
var missingDeps []string
|
||||
missingDeps = append(missingDeps, m.Module().base().commonProperties.MissingDeps...)
|
||||
missingDeps = append(missingDeps, m.bp.GetMissingDependencies()...)
|
||||
missingDeps = FirstUniqueStrings(missingDeps)
|
||||
return missingDeps
|
||||
}
|
||||
|
||||
func (m *moduleContext) AddMissingDependencies(deps []string) {
|
||||
func (b *baseModuleContext) AddMissingDependencies(deps []string) {
|
||||
if deps != nil {
|
||||
m.missingDeps = append(m.missingDeps, deps...)
|
||||
m.missingDeps = FirstUniqueStrings(m.missingDeps)
|
||||
missingDeps := &b.Module().base().commonProperties.MissingDeps
|
||||
*missingDeps = append(*missingDeps, deps...)
|
||||
*missingDeps = FirstUniqueStrings(*missingDeps)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *moduleContext) validateAndroidModule(module blueprint.Module) Module {
|
||||
func (b *baseModuleContext) validateAndroidModule(module blueprint.Module, strict bool) Module {
|
||||
aModule, _ := module.(Module)
|
||||
|
||||
if !strict {
|
||||
return aModule
|
||||
}
|
||||
|
||||
if aModule == nil {
|
||||
m.ModuleErrorf("module %q not an android module", m.OtherModuleName(aModule))
|
||||
b.ModuleErrorf("module %q not an android module", b.OtherModuleName(module))
|
||||
return nil
|
||||
}
|
||||
|
||||
if !aModule.Enabled() {
|
||||
if m.Config().AllowMissingDependencies() {
|
||||
m.AddMissingDependencies([]string{m.OtherModuleName(aModule)})
|
||||
if b.Config().AllowMissingDependencies() {
|
||||
b.AddMissingDependencies([]string{b.OtherModuleName(aModule)})
|
||||
} else {
|
||||
m.ModuleErrorf("depends on disabled module %q", m.OtherModuleName(aModule))
|
||||
b.ModuleErrorf("depends on disabled module %q", b.OtherModuleName(aModule))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
return aModule
|
||||
}
|
||||
|
||||
func (m *moduleContext) getDirectDepInternal(name string, tag blueprint.DependencyTag) (blueprint.Module, blueprint.DependencyTag) {
|
||||
func (b *baseModuleContext) getDirectDepInternal(name string, tag blueprint.DependencyTag) (blueprint.Module, blueprint.DependencyTag) {
|
||||
type dep struct {
|
||||
mod blueprint.Module
|
||||
tag blueprint.DependencyTag
|
||||
}
|
||||
var deps []dep
|
||||
m.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
||||
b.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
||||
if aModule, _ := module.(Module); aModule != nil && aModule.base().BaseModuleName() == name {
|
||||
returnedTag := m.ModuleContext.OtherModuleDependencyTag(aModule)
|
||||
returnedTag := b.BaseModuleContext.OtherModuleDependencyTag(aModule)
|
||||
if tag == nil || returnedTag == tag {
|
||||
deps = append(deps, dep{aModule, returnedTag})
|
||||
}
|
||||
|
@ -1090,17 +1123,17 @@ func (m *moduleContext) getDirectDepInternal(name string, tag blueprint.Dependen
|
|||
return deps[0].mod, deps[0].tag
|
||||
} else if len(deps) >= 2 {
|
||||
panic(fmt.Errorf("Multiple dependencies having same BaseModuleName() %q found from %q",
|
||||
name, m.ModuleName()))
|
||||
name, b.ModuleName()))
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (m *moduleContext) GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module {
|
||||
func (b *baseModuleContext) GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module {
|
||||
var deps []Module
|
||||
m.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
||||
b.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
||||
if aModule, _ := module.(Module); aModule != nil {
|
||||
if m.ModuleContext.OtherModuleDependencyTag(aModule) == tag {
|
||||
if b.BaseModuleContext.OtherModuleDependencyTag(aModule) == tag {
|
||||
deps = append(deps, aModule)
|
||||
}
|
||||
}
|
||||
|
@ -1113,37 +1146,37 @@ func (m *moduleContext) GetDirectDepWithTag(name string, tag blueprint.Dependenc
|
|||
return module
|
||||
}
|
||||
|
||||
func (m *moduleContext) GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag) {
|
||||
return m.getDirectDepInternal(name, nil)
|
||||
func (b *baseModuleContext) GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag) {
|
||||
return b.getDirectDepInternal(name, nil)
|
||||
}
|
||||
|
||||
func (m *moduleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
|
||||
m.ModuleContext.VisitDirectDeps(visit)
|
||||
func (b *baseModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
|
||||
b.BaseModuleContext.VisitDirectDeps(visit)
|
||||
}
|
||||
|
||||
func (m *moduleContext) VisitDirectDeps(visit func(Module)) {
|
||||
m.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
|
||||
if aModule := m.validateAndroidModule(module); aModule != nil {
|
||||
func (b *baseModuleContext) VisitDirectDeps(visit func(Module)) {
|
||||
b.BaseModuleContext.VisitDirectDeps(func(module blueprint.Module) {
|
||||
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
||||
visit(aModule)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (m *moduleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
|
||||
m.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
|
||||
if aModule := m.validateAndroidModule(module); aModule != nil {
|
||||
if m.ModuleContext.OtherModuleDependencyTag(aModule) == tag {
|
||||
func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
|
||||
b.BaseModuleContext.VisitDirectDeps(func(module blueprint.Module) {
|
||||
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
||||
if b.BaseModuleContext.OtherModuleDependencyTag(aModule) == tag {
|
||||
visit(aModule)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (m *moduleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
|
||||
m.ModuleContext.VisitDirectDepsIf(
|
||||
func (b *baseModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
|
||||
b.BaseModuleContext.VisitDirectDepsIf(
|
||||
// pred
|
||||
func(module blueprint.Module) bool {
|
||||
if aModule := m.validateAndroidModule(module); aModule != nil {
|
||||
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
||||
return pred(aModule)
|
||||
} else {
|
||||
return false
|
||||
|
@ -1155,19 +1188,19 @@ func (m *moduleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Mod
|
|||
})
|
||||
}
|
||||
|
||||
func (m *moduleContext) VisitDepsDepthFirst(visit func(Module)) {
|
||||
m.ModuleContext.VisitDepsDepthFirst(func(module blueprint.Module) {
|
||||
if aModule := m.validateAndroidModule(module); aModule != nil {
|
||||
func (b *baseModuleContext) VisitDepsDepthFirst(visit func(Module)) {
|
||||
b.BaseModuleContext.VisitDepsDepthFirst(func(module blueprint.Module) {
|
||||
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
||||
visit(aModule)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (m *moduleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
|
||||
m.ModuleContext.VisitDepsDepthFirstIf(
|
||||
func (b *baseModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
|
||||
b.BaseModuleContext.VisitDepsDepthFirstIf(
|
||||
// pred
|
||||
func(module blueprint.Module) bool {
|
||||
if aModule := m.validateAndroidModule(module); aModule != nil {
|
||||
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
||||
return pred(aModule)
|
||||
} else {
|
||||
return false
|
||||
|
@ -1179,15 +1212,21 @@ func (m *moduleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func
|
|||
})
|
||||
}
|
||||
|
||||
func (m *moduleContext) WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool) {
|
||||
m.ModuleContext.WalkDeps(visit)
|
||||
func (b *baseModuleContext) WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool) {
|
||||
b.BaseModuleContext.WalkDeps(visit)
|
||||
}
|
||||
|
||||
func (m *moduleContext) WalkDeps(visit func(Module, Module) bool) {
|
||||
m.ModuleContext.WalkDeps(func(child, parent blueprint.Module) bool {
|
||||
childAndroidModule := m.validateAndroidModule(child)
|
||||
parentAndroidModule := m.validateAndroidModule(parent)
|
||||
func (b *baseModuleContext) WalkDeps(visit func(Module, Module) bool) {
|
||||
b.walkPath = []Module{b.Module()}
|
||||
b.BaseModuleContext.WalkDeps(func(child, parent blueprint.Module) bool {
|
||||
childAndroidModule, _ := child.(Module)
|
||||
parentAndroidModule, _ := parent.(Module)
|
||||
if childAndroidModule != nil && parentAndroidModule != nil {
|
||||
// record walkPath before visit
|
||||
for b.walkPath[len(b.walkPath)-1] != parentAndroidModule {
|
||||
b.walkPath = b.walkPath[0 : len(b.walkPath)-1]
|
||||
}
|
||||
b.walkPath = append(b.walkPath, childAndroidModule)
|
||||
return visit(childAndroidModule, parentAndroidModule)
|
||||
} else {
|
||||
return false
|
||||
|
@ -1195,18 +1234,26 @@ func (m *moduleContext) WalkDeps(visit func(Module, Module) bool) {
|
|||
})
|
||||
}
|
||||
|
||||
func (b *baseModuleContext) GetWalkPath() []Module {
|
||||
return b.walkPath
|
||||
}
|
||||
|
||||
func (m *moduleContext) VisitAllModuleVariants(visit func(Module)) {
|
||||
m.ModuleContext.VisitAllModuleVariants(func(module blueprint.Module) {
|
||||
m.bp.VisitAllModuleVariants(func(module blueprint.Module) {
|
||||
visit(module.(Module))
|
||||
})
|
||||
}
|
||||
|
||||
func (m *moduleContext) PrimaryModule() Module {
|
||||
return m.ModuleContext.PrimaryModule().(Module)
|
||||
return m.bp.PrimaryModule().(Module)
|
||||
}
|
||||
|
||||
func (m *moduleContext) FinalModule() Module {
|
||||
return m.ModuleContext.FinalModule().(Module)
|
||||
return m.bp.FinalModule().(Module)
|
||||
}
|
||||
|
||||
func (m *moduleContext) ModuleSubDir() string {
|
||||
return m.bp.ModuleSubDir()
|
||||
}
|
||||
|
||||
func (b *baseModuleContext) Target() Target {
|
||||
|
@ -1584,20 +1631,20 @@ func (m *moduleContext) TargetRequiredModuleNames() []string {
|
|||
return m.module.base().commonProperties.Target_required
|
||||
}
|
||||
|
||||
func (m *moduleContext) Glob(globPattern string, excludes []string) Paths {
|
||||
ret, err := m.GlobWithDeps(globPattern, excludes)
|
||||
func (b *baseModuleContext) Glob(globPattern string, excludes []string) Paths {
|
||||
ret, err := b.GlobWithDeps(globPattern, excludes)
|
||||
if err != nil {
|
||||
m.ModuleErrorf("glob: %s", err.Error())
|
||||
b.ModuleErrorf("glob: %s", err.Error())
|
||||
}
|
||||
return pathsForModuleSrcFromFullPath(m, ret, true)
|
||||
return pathsForModuleSrcFromFullPath(b, ret, true)
|
||||
}
|
||||
|
||||
func (m *moduleContext) GlobFiles(globPattern string, excludes []string) Paths {
|
||||
ret, err := m.GlobWithDeps(globPattern, excludes)
|
||||
func (b *baseModuleContext) GlobFiles(globPattern string, excludes []string) Paths {
|
||||
ret, err := b.GlobWithDeps(globPattern, excludes)
|
||||
if err != nil {
|
||||
m.ModuleErrorf("glob: %s", err.Error())
|
||||
b.ModuleErrorf("glob: %s", err.Error())
|
||||
}
|
||||
return pathsForModuleSrcFromFullPath(m, ret, false)
|
||||
return pathsForModuleSrcFromFullPath(b, ret, false)
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -115,35 +115,14 @@ type TopDownMutator func(TopDownMutatorContext)
|
|||
type TopDownMutatorContext interface {
|
||||
BaseModuleContext
|
||||
|
||||
OtherModuleExists(name string) bool
|
||||
Rename(name string)
|
||||
Module() Module
|
||||
|
||||
OtherModuleName(m blueprint.Module) string
|
||||
OtherModuleDir(m blueprint.Module) string
|
||||
OtherModuleErrorf(m blueprint.Module, fmt string, args ...interface{})
|
||||
OtherModuleDependencyTag(m blueprint.Module) blueprint.DependencyTag
|
||||
|
||||
CreateModule(blueprint.ModuleFactory, ...interface{})
|
||||
|
||||
GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
|
||||
GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
|
||||
|
||||
VisitDirectDeps(visit func(Module))
|
||||
VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
|
||||
VisitDirectDepsIf(pred func(Module) bool, visit func(Module))
|
||||
VisitDepsDepthFirst(visit func(Module))
|
||||
VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module))
|
||||
WalkDeps(visit func(Module, Module) bool)
|
||||
// GetWalkPath is supposed to be called in visit function passed in WalkDeps()
|
||||
// and returns a top-down dependency path from a start module to current child module.
|
||||
GetWalkPath() []Module
|
||||
}
|
||||
|
||||
type topDownMutatorContext struct {
|
||||
blueprint.TopDownMutatorContext
|
||||
bp blueprint.TopDownMutatorContext
|
||||
baseModuleContext
|
||||
walkPath []Module
|
||||
}
|
||||
|
||||
type BottomUpMutator func(BottomUpMutatorContext)
|
||||
|
@ -151,9 +130,7 @@ type BottomUpMutator func(BottomUpMutatorContext)
|
|||
type BottomUpMutatorContext interface {
|
||||
BaseModuleContext
|
||||
|
||||
OtherModuleExists(name string) bool
|
||||
Rename(name string)
|
||||
Module() blueprint.Module
|
||||
|
||||
AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string)
|
||||
AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string)
|
||||
|
@ -167,7 +144,7 @@ type BottomUpMutatorContext interface {
|
|||
}
|
||||
|
||||
type bottomUpMutatorContext struct {
|
||||
blueprint.BottomUpMutatorContext
|
||||
bp blueprint.BottomUpMutatorContext
|
||||
baseModuleContext
|
||||
}
|
||||
|
||||
|
@ -175,8 +152,8 @@ func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) Mutat
|
|||
f := func(ctx blueprint.BottomUpMutatorContext) {
|
||||
if a, ok := ctx.Module().(Module); ok {
|
||||
actx := &bottomUpMutatorContext{
|
||||
BottomUpMutatorContext: ctx,
|
||||
baseModuleContext: a.base().baseModuleContextFactory(ctx),
|
||||
bp: ctx,
|
||||
baseModuleContext: a.base().baseModuleContextFactory(ctx),
|
||||
}
|
||||
m(actx)
|
||||
}
|
||||
|
@ -190,8 +167,8 @@ func (x *registerMutatorsContext) TopDown(name string, m TopDownMutator) Mutator
|
|||
f := func(ctx blueprint.TopDownMutatorContext) {
|
||||
if a, ok := ctx.Module().(Module); ok {
|
||||
actx := &topDownMutatorContext{
|
||||
TopDownMutatorContext: ctx,
|
||||
baseModuleContext: a.base().baseModuleContextFactory(ctx),
|
||||
bp: ctx,
|
||||
baseModuleContext: a.base().baseModuleContextFactory(ctx),
|
||||
}
|
||||
m(actx)
|
||||
}
|
||||
|
@ -216,99 +193,6 @@ func depsMutator(ctx BottomUpMutatorContext) {
|
|||
}
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) Config() Config {
|
||||
return t.config
|
||||
}
|
||||
|
||||
func (b *bottomUpMutatorContext) Config() Config {
|
||||
return b.config
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) Module() Module {
|
||||
module, _ := t.TopDownMutatorContext.Module().(Module)
|
||||
return module
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) VisitDirectDeps(visit func(Module)) {
|
||||
t.TopDownMutatorContext.VisitDirectDeps(func(module blueprint.Module) {
|
||||
if aModule, _ := module.(Module); aModule != nil {
|
||||
visit(aModule)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
|
||||
t.TopDownMutatorContext.VisitDirectDeps(func(module blueprint.Module) {
|
||||
if aModule, _ := module.(Module); aModule != nil {
|
||||
if t.TopDownMutatorContext.OtherModuleDependencyTag(aModule) == tag {
|
||||
visit(aModule)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
|
||||
t.TopDownMutatorContext.VisitDirectDepsIf(
|
||||
// pred
|
||||
func(module blueprint.Module) bool {
|
||||
if aModule, _ := module.(Module); aModule != nil {
|
||||
return pred(aModule)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
},
|
||||
// visit
|
||||
func(module blueprint.Module) {
|
||||
visit(module.(Module))
|
||||
})
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) VisitDepsDepthFirst(visit func(Module)) {
|
||||
t.TopDownMutatorContext.VisitDepsDepthFirst(func(module blueprint.Module) {
|
||||
if aModule, _ := module.(Module); aModule != nil {
|
||||
visit(aModule)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
|
||||
t.TopDownMutatorContext.VisitDepsDepthFirstIf(
|
||||
// pred
|
||||
func(module blueprint.Module) bool {
|
||||
if aModule, _ := module.(Module); aModule != nil {
|
||||
return pred(aModule)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
},
|
||||
// visit
|
||||
func(module blueprint.Module) {
|
||||
visit(module.(Module))
|
||||
})
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) WalkDeps(visit func(Module, Module) bool) {
|
||||
t.walkPath = []Module{t.Module()}
|
||||
t.TopDownMutatorContext.WalkDeps(func(child, parent blueprint.Module) bool {
|
||||
childAndroidModule, _ := child.(Module)
|
||||
parentAndroidModule, _ := parent.(Module)
|
||||
if childAndroidModule != nil && parentAndroidModule != nil {
|
||||
// record walkPath before visit
|
||||
for t.walkPath[len(t.walkPath)-1] != parentAndroidModule {
|
||||
t.walkPath = t.walkPath[0 : len(t.walkPath)-1]
|
||||
}
|
||||
t.walkPath = append(t.walkPath, childAndroidModule)
|
||||
return visit(childAndroidModule, parentAndroidModule)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) GetWalkPath() []Module {
|
||||
return t.walkPath
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) AppendProperties(props ...interface{}) {
|
||||
for _, p := range props {
|
||||
err := proptools.AppendMatchingProperties(t.Module().base().customizableProperties,
|
||||
|
@ -336,3 +220,61 @@ func (t *topDownMutatorContext) PrependProperties(props ...interface{}) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// android.topDownMutatorContext either has to embed blueprint.TopDownMutatorContext, in which case every method that
|
||||
// has an overridden version in android.BaseModuleContext has to be manually forwarded to BaseModuleContext to avoid
|
||||
// ambiguous method errors, or it has to store a blueprint.TopDownMutatorContext non-embedded, in which case every
|
||||
// non-overridden method has to be forwarded. There are fewer non-overridden methods, so use the latter. The following
|
||||
// methods forward to the identical blueprint versions for topDownMutatorContext and bottomUpMutatorContext.
|
||||
|
||||
func (t *topDownMutatorContext) Rename(name string) {
|
||||
t.bp.Rename(name)
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) CreateModule(factory blueprint.ModuleFactory, props ...interface{}) {
|
||||
t.bp.CreateModule(factory, props...)
|
||||
}
|
||||
|
||||
func (b *bottomUpMutatorContext) Rename(name string) {
|
||||
b.bp.Rename(name)
|
||||
}
|
||||
|
||||
func (b *bottomUpMutatorContext) AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) {
|
||||
b.bp.AddDependency(module, tag, name...)
|
||||
}
|
||||
|
||||
func (b *bottomUpMutatorContext) AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string) {
|
||||
b.bp.AddReverseDependency(module, tag, name)
|
||||
}
|
||||
|
||||
func (b *bottomUpMutatorContext) CreateVariations(variations ...string) []blueprint.Module {
|
||||
return b.bp.CreateVariations(variations...)
|
||||
}
|
||||
|
||||
func (b *bottomUpMutatorContext) CreateLocalVariations(variations ...string) []blueprint.Module {
|
||||
return b.bp.CreateLocalVariations(variations...)
|
||||
}
|
||||
|
||||
func (b *bottomUpMutatorContext) SetDependencyVariation(variation string) {
|
||||
b.bp.SetDependencyVariation(variation)
|
||||
}
|
||||
|
||||
func (b *bottomUpMutatorContext) AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag,
|
||||
names ...string) {
|
||||
|
||||
b.bp.AddVariationDependencies(variations, tag, names...)
|
||||
}
|
||||
|
||||
func (b *bottomUpMutatorContext) AddFarVariationDependencies(variations []blueprint.Variation,
|
||||
tag blueprint.DependencyTag, names ...string) {
|
||||
|
||||
b.bp.AddFarVariationDependencies(variations, tag, names...)
|
||||
}
|
||||
|
||||
func (b *bottomUpMutatorContext) AddInterVariantDependency(tag blueprint.DependencyTag, from, to blueprint.Module) {
|
||||
b.bp.AddInterVariantDependency(tag, from, to)
|
||||
}
|
||||
|
||||
func (b *bottomUpMutatorContext) ReplaceDependencies(name string) {
|
||||
b.bp.ReplaceDependencies(name)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package android
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/google/blueprint/proptools"
|
||||
)
|
||||
|
||||
type mutatorTestModule struct {
|
||||
ModuleBase
|
||||
props struct {
|
||||
}
|
||||
|
||||
missingDeps []string
|
||||
}
|
||||
|
||||
func mutatorTestModuleFactory() Module {
|
||||
module := &mutatorTestModule{}
|
||||
module.AddProperties(&module.props)
|
||||
InitAndroidModule(module)
|
||||
return module
|
||||
}
|
||||
|
||||
func (m *mutatorTestModule) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||
ctx.Build(pctx, BuildParams{
|
||||
Rule: Touch,
|
||||
Output: PathForModuleOut(ctx, "output"),
|
||||
})
|
||||
|
||||
m.missingDeps = ctx.GetMissingDependencies()
|
||||
}
|
||||
|
||||
func (m *mutatorTestModule) DepsMutator(ctx BottomUpMutatorContext) {
|
||||
ctx.AddDependency(ctx.Module(), nil, "regular_missing_dep")
|
||||
}
|
||||
|
||||
func addMissingDependenciesMutator(ctx TopDownMutatorContext) {
|
||||
ctx.AddMissingDependencies([]string{"added_missing_dep"})
|
||||
}
|
||||
|
||||
func TestMutatorAddMissingDependencies(t *testing.T) {
|
||||
buildDir, err := ioutil.TempDir("", "soong_mutator_test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(buildDir)
|
||||
|
||||
config := TestConfig(buildDir, nil)
|
||||
config.TestProductVariables.Allow_missing_dependencies = proptools.BoolPtr(true)
|
||||
|
||||
ctx := NewTestContext()
|
||||
ctx.SetAllowMissingDependencies(true)
|
||||
|
||||
ctx.RegisterModuleType("test", ModuleFactoryAdaptor(mutatorTestModuleFactory))
|
||||
ctx.PreDepsMutators(func(ctx RegisterMutatorsContext) {
|
||||
ctx.TopDown("add_missing_dependencies", addMissingDependenciesMutator)
|
||||
})
|
||||
|
||||
bp := `
|
||||
test {
|
||||
name: "foo",
|
||||
}
|
||||
`
|
||||
|
||||
mockFS := map[string][]byte{
|
||||
"Android.bp": []byte(bp),
|
||||
}
|
||||
|
||||
ctx.MockFileSystem(mockFS)
|
||||
|
||||
ctx.Register()
|
||||
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
|
||||
FailIfErrored(t, errs)
|
||||
_, errs = ctx.PrepareBuildActions(config)
|
||||
FailIfErrored(t, errs)
|
||||
|
||||
foo := ctx.ModuleForTests("foo", "").Module().(*mutatorTestModule)
|
||||
|
||||
if g, w := foo.missingDeps, []string{"added_missing_dep", "regular_missing_dep"}; !reflect.DeepEqual(g, w) {
|
||||
t.Errorf("want foo missing deps %q, got %q", w, g)
|
||||
}
|
||||
}
|
|
@ -16,8 +16,6 @@ package android
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
@ -613,12 +611,6 @@ func mockFiles(bps map[string]string) (files map[string][]byte) {
|
|||
}
|
||||
|
||||
func setupTestFromFiles(bps map[string][]byte) (ctx *TestContext, errs []error) {
|
||||
buildDir, err := ioutil.TempDir("", "soong_namespace_test")
|
||||
if err != nil {
|
||||
return nil, []error{err}
|
||||
}
|
||||
defer os.RemoveAll(buildDir)
|
||||
|
||||
config := TestConfig(buildDir, nil)
|
||||
|
||||
ctx = NewTestContext()
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
package android
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -194,12 +192,6 @@ var neverallowTests = []struct {
|
|||
}
|
||||
|
||||
func TestNeverallow(t *testing.T) {
|
||||
buildDir, err := ioutil.TempDir("", "soong_neverallow_test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(buildDir)
|
||||
|
||||
config := TestConfig(buildDir, nil)
|
||||
|
||||
for _, test := range neverallowTests {
|
||||
|
|
|
@ -367,7 +367,7 @@ func expandOneSrcPath(ctx ModuleContext, s string, expandedExcludes []string) (P
|
|||
// each string. If incDirs is false, strip paths with a trailing '/' from the list.
|
||||
// It intended for use in globs that only list files that exist, so it allows '$' in
|
||||
// filenames.
|
||||
func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string, incDirs bool) Paths {
|
||||
func pathsForModuleSrcFromFullPath(ctx BaseModuleContext, paths []string, incDirs bool) Paths {
|
||||
prefix := filepath.Join(ctx.Config().srcDir, ctx.ModuleDir()) + "/"
|
||||
if prefix == "./" {
|
||||
prefix = ""
|
||||
|
|
|
@ -17,8 +17,6 @@ package android
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -758,6 +756,11 @@ func (p *pathForModuleSrcTestModule) GenerateAndroidBuildActions(ctx ModuleConte
|
|||
if !p.props.Module_handles_missing_deps {
|
||||
p.missingDeps = ctx.GetMissingDependencies()
|
||||
}
|
||||
|
||||
ctx.Build(pctx, BuildParams{
|
||||
Rule: Touch,
|
||||
Output: PathForModuleOut(ctx, "output"),
|
||||
})
|
||||
}
|
||||
|
||||
type pathForModuleSrcOutputFileProviderModule struct {
|
||||
|
@ -875,12 +878,6 @@ func testPathForModuleSrc(t *testing.T, buildDir string, tests []pathForModuleSr
|
|||
}
|
||||
|
||||
func TestPathsForModuleSrc(t *testing.T) {
|
||||
buildDir, err := ioutil.TempDir("", "soong_paths_for_module_src_test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(buildDir)
|
||||
|
||||
tests := []pathForModuleSrcTestCase{
|
||||
{
|
||||
name: "path",
|
||||
|
@ -961,12 +958,6 @@ func TestPathsForModuleSrc(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPathForModuleSrc(t *testing.T) {
|
||||
buildDir, err := ioutil.TempDir("", "soong_path_for_module_src_test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(buildDir)
|
||||
|
||||
tests := []pathForModuleSrcTestCase{
|
||||
{
|
||||
name: "path",
|
||||
|
@ -1034,12 +1025,6 @@ func TestPathForModuleSrc(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestPathsForModuleSrc_AllowMissingDependencies(t *testing.T) {
|
||||
buildDir, err := ioutil.TempDir("", "soong_paths_for_module_src_allow_missing_dependencies_test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(buildDir)
|
||||
|
||||
config := TestConfig(buildDir, nil)
|
||||
config.TestProductVariables.Allow_missing_dependencies = proptools.BoolPtr(true)
|
||||
|
||||
|
|
|
@ -15,16 +15,13 @@
|
|||
package android
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func testPrebuiltEtc(t *testing.T, bp string) (*TestContext, Config) {
|
||||
config, buildDir := setUp(t)
|
||||
defer tearDown(buildDir)
|
||||
config := TestArchConfig(buildDir, nil)
|
||||
ctx := NewTestArchContext()
|
||||
ctx.RegisterModuleType("prebuilt_etc", ModuleFactoryAdaptor(PrebuiltEtcFactory))
|
||||
ctx.RegisterModuleType("prebuilt_etc_host", ModuleFactoryAdaptor(PrebuiltEtcHostFactory))
|
||||
|
@ -51,20 +48,6 @@ func testPrebuiltEtc(t *testing.T, bp string) (*TestContext, Config) {
|
|||
return ctx, config
|
||||
}
|
||||
|
||||
func setUp(t *testing.T) (config Config, buildDir string) {
|
||||
buildDir, err := ioutil.TempDir("", "soong_prebuilt_etc_test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
config = TestArchConfig(buildDir, nil)
|
||||
return
|
||||
}
|
||||
|
||||
func tearDown(buildDir string) {
|
||||
os.RemoveAll(buildDir)
|
||||
}
|
||||
|
||||
func TestPrebuiltEtcVariants(t *testing.T) {
|
||||
ctx, _ := testPrebuiltEtc(t, `
|
||||
prebuilt_etc {
|
||||
|
|
|
@ -16,8 +16,6 @@ package android
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
|
@ -127,12 +125,6 @@ var prebuiltsTests = []struct {
|
|||
}
|
||||
|
||||
func TestPrebuilts(t *testing.T) {
|
||||
buildDir, err := ioutil.TempDir("", "soong_prebuilt_test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(buildDir)
|
||||
|
||||
config := TestConfig(buildDir, nil)
|
||||
|
||||
for _, test := range prebuiltsTests {
|
||||
|
|
|
@ -16,8 +16,6 @@ package android
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
@ -418,12 +416,6 @@ func testRuleBuilder_Build(ctx BuilderContext, in Path, out, outDep, outDir Writ
|
|||
}
|
||||
|
||||
func TestRuleBuilder_Build(t *testing.T) {
|
||||
buildDir, err := ioutil.TempDir("", "soong_test_rule_builder")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(buildDir)
|
||||
|
||||
bp := `
|
||||
rule_builder_test {
|
||||
name: "foo",
|
||||
|
|
|
@ -1,19 +1,11 @@
|
|||
package android
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func testShBinary(t *testing.T, bp string) (*TestContext, Config) {
|
||||
buildDir, err := ioutil.TempDir("", "soong_sh_binary_test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(buildDir)
|
||||
|
||||
config := TestArchConfig(buildDir, nil)
|
||||
|
||||
ctx := NewTestArchContext()
|
||||
|
|
|
@ -179,7 +179,7 @@ func buildParamsFromRule(provider testBuildProvider, rule string) TestingBuildPa
|
|||
|
||||
func maybeBuildParamsFromDescription(provider testBuildProvider, desc string) TestingBuildParams {
|
||||
for _, p := range provider.BuildParamsForTests() {
|
||||
if p.Description == desc {
|
||||
if strings.Contains(p.Description, desc) {
|
||||
return newTestingBuildParams(provider, p)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package android
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
|
@ -663,12 +661,6 @@ var visibilityTests = []struct {
|
|||
}
|
||||
|
||||
func TestVisibility(t *testing.T) {
|
||||
buildDir, err := ioutil.TempDir("", "soong_neverallow_test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(buildDir)
|
||||
|
||||
for _, test := range visibilityTests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
_, errs := testVisibility(buildDir, test.fs)
|
||||
|
@ -759,6 +751,3 @@ func defaultsFactory() Module {
|
|||
InitDefaultsModule(m)
|
||||
return m
|
||||
}
|
||||
|
||||
func (*mockDefaults) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||
}
|
||||
|
|
|
@ -15,19 +15,11 @@
|
|||
package android
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func testVtsConfig(test *testing.T, bpFileContents string) *TestContext {
|
||||
buildDir, err := ioutil.TempDir("", "soong_vts_config_test")
|
||||
if err != nil {
|
||||
test.Fatal(err)
|
||||
}
|
||||
|
||||
config := TestArchConfig(buildDir, nil)
|
||||
defer func() { os.RemoveAll(buildDir) }()
|
||||
|
||||
ctx := NewTestArchContext()
|
||||
ctx.RegisterModuleType("vts_config", ModuleFactoryAdaptor(VtsConfigFactory))
|
||||
|
|
|
@ -1295,9 +1295,6 @@ type Defaults struct {
|
|||
android.DefaultsModuleBase
|
||||
}
|
||||
|
||||
func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
|
||||
func defaultsFactory() android.Module {
|
||||
return DefaultsFactory()
|
||||
}
|
||||
|
|
3
cc/cc.go
3
cc/cc.go
|
@ -2060,9 +2060,6 @@ type Defaults struct {
|
|||
android.ApexModuleBase
|
||||
}
|
||||
|
||||
func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
|
||||
// cc_defaults provides a set of properties that can be inherited by other cc
|
||||
// modules. A module can use the properties from a cc_defaults using
|
||||
// `defaults: ["<:default_module_name>"]`. Properties of both modules are
|
||||
|
|
|
@ -583,9 +583,6 @@ type Defaults struct {
|
|||
android.DefaultsModuleBase
|
||||
}
|
||||
|
||||
func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
|
||||
func defaultsFactory() android.Module {
|
||||
return DefaultsFactory()
|
||||
}
|
||||
|
|
|
@ -1808,9 +1808,6 @@ type DocDefaults struct {
|
|||
android.DefaultsModuleBase
|
||||
}
|
||||
|
||||
func (*DocDefaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
|
||||
func DocDefaultsFactory() android.Module {
|
||||
module := &DocDefaults{}
|
||||
|
||||
|
|
|
@ -2131,9 +2131,6 @@ type Defaults struct {
|
|||
android.DefaultsModuleBase
|
||||
}
|
||||
|
||||
func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
|
||||
// java_defaults provides a set of properties that can be inherited by other java or android modules.
|
||||
//
|
||||
// A module can use the properties from a java_defaults module using `defaults: ["defaults_module_name"]`. Each
|
||||
|
|
Loading…
Reference in New Issue