Merge changes Ia17b2bcb,Ic71892c3,Id2b23b9e,I435ee7aa,I85112506, ...
* changes: Consolidate *MutatorContext and ModuleContext into BaseModuleContext Add test for missing defaults modules with AllowMissingDependencies Capture missing dependency error rules Share buildDir for android/soong/android tests Reimplement AddMissingDependencies Add GenerateAndroidBuildActions to DefaultsModuleBase
This commit is contained in:
@@ -78,10 +78,12 @@ bootstrap_go_package {
|
|||||||
"android/env.go",
|
"android/env.go",
|
||||||
],
|
],
|
||||||
testSrcs: [
|
testSrcs: [
|
||||||
|
"android/android_test.go",
|
||||||
"android/arch_test.go",
|
"android/arch_test.go",
|
||||||
"android/config_test.go",
|
"android/config_test.go",
|
||||||
"android/expand_test.go",
|
"android/expand_test.go",
|
||||||
"android/module_test.go",
|
"android/module_test.go",
|
||||||
|
"android/mutator_test.go",
|
||||||
"android/namespace_test.go",
|
"android/namespace_test.go",
|
||||||
"android/neverallow_test.go",
|
"android/neverallow_test.go",
|
||||||
"android/onceper_test.go",
|
"android/onceper_test.go",
|
||||||
|
46
android/android_test.go
Normal file
46
android/android_test.go
Normal file
@@ -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
|
return d.defaultableProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *DefaultsModuleBase) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||||
|
}
|
||||||
|
|
||||||
func InitDefaultsModule(module DefaultableModule) {
|
func InitDefaultsModule(module DefaultableModule) {
|
||||||
module.AddProperties(
|
module.AddProperties(
|
||||||
&hostAndDeviceProperties{},
|
&hostAndDeviceProperties{},
|
||||||
|
116
android/defaults_test.go
Normal file
116
android/defaults_test.go
Normal file
@@ -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
|
type ModuleBuildParams BuildParams
|
||||||
|
|
||||||
// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
|
// 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.
|
// about the current module.
|
||||||
type BaseModuleContext interface {
|
type BaseModuleContext interface {
|
||||||
|
Module() Module
|
||||||
ModuleName() string
|
ModuleName() string
|
||||||
ModuleDir() string
|
ModuleDir() string
|
||||||
ModuleType() string
|
ModuleType() string
|
||||||
Config() Config
|
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
|
ContainsProperty(name string) bool
|
||||||
Errorf(pos scanner.Position, fmt string, args ...interface{})
|
Errorf(pos scanner.Position, fmt string, args ...interface{})
|
||||||
ModuleErrorf(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.
|
// file that does not match the pattern is added to a searched directory.
|
||||||
GlobWithDeps(pattern string, excludes []string) ([]string, error)
|
GlobWithDeps(pattern string, excludes []string) ([]string, error)
|
||||||
|
|
||||||
|
Glob(globPattern string, excludes []string) Paths
|
||||||
|
GlobFiles(globPattern string, excludes []string) Paths
|
||||||
|
|
||||||
Fs() pathtools.FileSystem
|
Fs() pathtools.FileSystem
|
||||||
AddNinjaFileDeps(deps ...string)
|
AddNinjaFileDeps(deps ...string)
|
||||||
|
|
||||||
|
AddMissingDependencies(missingDeps []string)
|
||||||
|
|
||||||
Target() Target
|
Target() Target
|
||||||
TargetPrimary() bool
|
TargetPrimary() bool
|
||||||
MultiTargets() []Target
|
MultiTargets() []Target
|
||||||
@@ -114,8 +145,6 @@ type ModuleContext interface {
|
|||||||
ExpandSources(srcFiles, excludes []string) Paths
|
ExpandSources(srcFiles, excludes []string) Paths
|
||||||
ExpandSource(srcFile, prop string) Path
|
ExpandSource(srcFile, prop string) Path
|
||||||
ExpandOptionalSource(srcFile *string, prop string) OptionalPath
|
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
|
InstallExecutable(installPath OutputPath, name string, srcPath Path, deps ...Path) OutputPath
|
||||||
InstallFile(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
|
InstallAbsoluteSymlink(installPath OutputPath, name string, absPath string) OutputPath
|
||||||
CheckbuildFile(srcPath Path)
|
CheckbuildFile(srcPath Path)
|
||||||
|
|
||||||
AddMissingDependencies(deps []string)
|
|
||||||
|
|
||||||
InstallInData() bool
|
InstallInData() bool
|
||||||
InstallInSanitizerDir() bool
|
InstallInSanitizerDir() bool
|
||||||
InstallInRecovery() bool
|
InstallInRecovery() bool
|
||||||
@@ -133,30 +160,8 @@ type ModuleContext interface {
|
|||||||
HostRequiredModuleNames() []string
|
HostRequiredModuleNames() []string
|
||||||
TargetRequiredModuleNames() []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
|
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)
|
Variable(pctx PackageContext, name, value string)
|
||||||
Rule(pctx PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule
|
Rule(pctx PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule
|
||||||
// Similar to blueprint.ModuleContext.Build, but takes Paths instead of []string,
|
// Similar to blueprint.ModuleContext.Build, but takes Paths instead of []string,
|
||||||
@@ -338,6 +343,8 @@ type commonProperties struct {
|
|||||||
SkipInstall bool `blueprint:"mutated"`
|
SkipInstall bool `blueprint:"mutated"`
|
||||||
|
|
||||||
NamespaceExportedToMake bool `blueprint:"mutated"`
|
NamespaceExportedToMake bool `blueprint:"mutated"`
|
||||||
|
|
||||||
|
MissingDeps []string `blueprint:"mutated"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type hostAndDeviceProperties struct {
|
type hostAndDeviceProperties struct {
|
||||||
@@ -837,14 +844,22 @@ func (m *ModuleBase) baseModuleContextFactory(ctx blueprint.BaseModuleContext) b
|
|||||||
func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
|
func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) {
|
||||||
ctx := &moduleContext{
|
ctx := &moduleContext{
|
||||||
module: m.module,
|
module: m.module,
|
||||||
ModuleContext: blueprintCtx,
|
bp: blueprintCtx,
|
||||||
baseModuleContext: m.baseModuleContextFactory(blueprintCtx),
|
baseModuleContext: m.baseModuleContextFactory(blueprintCtx),
|
||||||
installDeps: m.computeInstallDeps(blueprintCtx),
|
installDeps: m.computeInstallDeps(blueprintCtx),
|
||||||
installFiles: m.installFiles,
|
installFiles: m.installFiles,
|
||||||
missingDeps: blueprintCtx.GetMissingDependencies(),
|
|
||||||
variables: make(map[string]string),
|
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 {
|
if ctx.config.captureBuild {
|
||||||
ctx.ruleParams = make(map[blueprint.Rule]blueprint.RuleParams)
|
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)
|
noticePath := filepath.Join(ctx.ModuleDir(), notice)
|
||||||
m.noticeFile = ExistentPathForSource(ctx, noticePath)
|
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() {
|
if m == ctx.FinalModule().(Module).base() {
|
||||||
@@ -923,15 +944,18 @@ type baseModuleContext struct {
|
|||||||
debug bool
|
debug bool
|
||||||
kind moduleKind
|
kind moduleKind
|
||||||
config Config
|
config Config
|
||||||
|
|
||||||
|
walkPath []Module
|
||||||
|
|
||||||
|
strictVisitDeps bool // If true, enforce that all dependencies are enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
type moduleContext struct {
|
type moduleContext struct {
|
||||||
blueprint.ModuleContext
|
bp blueprint.ModuleContext
|
||||||
baseModuleContext
|
baseModuleContext
|
||||||
installDeps Paths
|
installDeps Paths
|
||||||
installFiles Paths
|
installFiles Paths
|
||||||
checkbuildFiles Paths
|
checkbuildFiles Paths
|
||||||
missingDeps []string
|
|
||||||
module Module
|
module Module
|
||||||
|
|
||||||
// For tests
|
// For tests
|
||||||
@@ -940,21 +964,16 @@ type moduleContext struct {
|
|||||||
variables map[string]string
|
variables map[string]string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) ninjaError(desc string, outputs []string, err error) {
|
func (m *moduleContext) ninjaError(params BuildParams, err error) (PackageContext, BuildParams) {
|
||||||
m.ModuleContext.Build(pctx.PackageContext, blueprint.BuildParams{
|
return pctx, BuildParams{
|
||||||
Rule: ErrorRule,
|
Rule: ErrorRule,
|
||||||
Description: desc,
|
Description: params.Description,
|
||||||
Outputs: outputs,
|
Output: params.Output,
|
||||||
Optional: true,
|
Outputs: params.Outputs,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *moduleContext) Config() Config {
|
|
||||||
return m.ModuleContext.Config().(Config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) {
|
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.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,
|
func (m *moduleContext) Rule(pctx PackageContext, name string, params blueprint.RuleParams,
|
||||||
argNames ...string) blueprint.Rule {
|
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 {
|
if m.config.captureBuild {
|
||||||
m.ruleParams[rule] = params
|
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) {
|
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 {
|
if m.config.captureBuild {
|
||||||
m.buildParams = append(m.buildParams, params)
|
m.buildParams = append(m.buildParams, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
bparams := convertBuildParams(params)
|
m.bp.Build(pctx.PackageContext, convertBuildParams(params))
|
||||||
|
}
|
||||||
|
|
||||||
if bparams.Description != "" {
|
func (b *baseModuleContext) Module() Module {
|
||||||
bparams.Description = "${moduleDesc}" + params.Description + "${moduleDescSuffix}"
|
module, _ := b.BaseModuleContext.Module().(Module)
|
||||||
}
|
return module
|
||||||
|
}
|
||||||
|
|
||||||
if m.missingDeps != nil {
|
func (b *baseModuleContext) Config() Config {
|
||||||
m.ninjaError(bparams.Description, bparams.Outputs,
|
return b.BaseModuleContext.Config().(Config)
|
||||||
fmt.Errorf("module %s missing dependencies: %s\n",
|
|
||||||
m.ModuleName(), strings.Join(m.missingDeps, ", ")))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
m.ModuleContext.Build(pctx.PackageContext, bparams)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) GetMissingDependencies() []string {
|
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 {
|
if deps != nil {
|
||||||
m.missingDeps = append(m.missingDeps, deps...)
|
missingDeps := &b.Module().base().commonProperties.MissingDeps
|
||||||
m.missingDeps = FirstUniqueStrings(m.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)
|
aModule, _ := module.(Module)
|
||||||
|
|
||||||
|
if !strict {
|
||||||
|
return aModule
|
||||||
|
}
|
||||||
|
|
||||||
if aModule == nil {
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if !aModule.Enabled() {
|
if !aModule.Enabled() {
|
||||||
if m.Config().AllowMissingDependencies() {
|
if b.Config().AllowMissingDependencies() {
|
||||||
m.AddMissingDependencies([]string{m.OtherModuleName(aModule)})
|
b.AddMissingDependencies([]string{b.OtherModuleName(aModule)})
|
||||||
} else {
|
} else {
|
||||||
m.ModuleErrorf("depends on disabled module %q", m.OtherModuleName(aModule))
|
b.ModuleErrorf("depends on disabled module %q", b.OtherModuleName(aModule))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return aModule
|
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 {
|
type dep struct {
|
||||||
mod blueprint.Module
|
mod blueprint.Module
|
||||||
tag blueprint.DependencyTag
|
tag blueprint.DependencyTag
|
||||||
}
|
}
|
||||||
var deps []dep
|
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 {
|
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 {
|
if tag == nil || returnedTag == tag {
|
||||||
deps = append(deps, dep{aModule, returnedTag})
|
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
|
return deps[0].mod, deps[0].tag
|
||||||
} else if len(deps) >= 2 {
|
} else if len(deps) >= 2 {
|
||||||
panic(fmt.Errorf("Multiple dependencies having same BaseModuleName() %q found from %q",
|
panic(fmt.Errorf("Multiple dependencies having same BaseModuleName() %q found from %q",
|
||||||
name, m.ModuleName()))
|
name, b.ModuleName()))
|
||||||
} else {
|
} else {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module {
|
func (b *baseModuleContext) GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module {
|
||||||
var deps []Module
|
var deps []Module
|
||||||
m.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
b.VisitDirectDepsBlueprint(func(module blueprint.Module) {
|
||||||
if aModule, _ := module.(Module); aModule != nil {
|
if aModule, _ := module.(Module); aModule != nil {
|
||||||
if m.ModuleContext.OtherModuleDependencyTag(aModule) == tag {
|
if b.BaseModuleContext.OtherModuleDependencyTag(aModule) == tag {
|
||||||
deps = append(deps, aModule)
|
deps = append(deps, aModule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1113,37 +1146,37 @@ func (m *moduleContext) GetDirectDepWithTag(name string, tag blueprint.Dependenc
|
|||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag) {
|
func (b *baseModuleContext) GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag) {
|
||||||
return m.getDirectDepInternal(name, nil)
|
return b.getDirectDepInternal(name, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
|
func (b *baseModuleContext) VisitDirectDepsBlueprint(visit func(blueprint.Module)) {
|
||||||
m.ModuleContext.VisitDirectDeps(visit)
|
b.BaseModuleContext.VisitDirectDeps(visit)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) VisitDirectDeps(visit func(Module)) {
|
func (b *baseModuleContext) VisitDirectDeps(visit func(Module)) {
|
||||||
m.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
|
b.BaseModuleContext.VisitDirectDeps(func(module blueprint.Module) {
|
||||||
if aModule := m.validateAndroidModule(module); aModule != nil {
|
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
||||||
visit(aModule)
|
visit(aModule)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
|
func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
|
||||||
m.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
|
b.BaseModuleContext.VisitDirectDeps(func(module blueprint.Module) {
|
||||||
if aModule := m.validateAndroidModule(module); aModule != nil {
|
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
||||||
if m.ModuleContext.OtherModuleDependencyTag(aModule) == tag {
|
if b.BaseModuleContext.OtherModuleDependencyTag(aModule) == tag {
|
||||||
visit(aModule)
|
visit(aModule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
|
func (b *baseModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
|
||||||
m.ModuleContext.VisitDirectDepsIf(
|
b.BaseModuleContext.VisitDirectDepsIf(
|
||||||
// pred
|
// pred
|
||||||
func(module blueprint.Module) bool {
|
func(module blueprint.Module) bool {
|
||||||
if aModule := m.validateAndroidModule(module); aModule != nil {
|
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
||||||
return pred(aModule)
|
return pred(aModule)
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
@@ -1155,19 +1188,19 @@ func (m *moduleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Mod
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) VisitDepsDepthFirst(visit func(Module)) {
|
func (b *baseModuleContext) VisitDepsDepthFirst(visit func(Module)) {
|
||||||
m.ModuleContext.VisitDepsDepthFirst(func(module blueprint.Module) {
|
b.BaseModuleContext.VisitDepsDepthFirst(func(module blueprint.Module) {
|
||||||
if aModule := m.validateAndroidModule(module); aModule != nil {
|
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
||||||
visit(aModule)
|
visit(aModule)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
|
func (b *baseModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
|
||||||
m.ModuleContext.VisitDepsDepthFirstIf(
|
b.BaseModuleContext.VisitDepsDepthFirstIf(
|
||||||
// pred
|
// pred
|
||||||
func(module blueprint.Module) bool {
|
func(module blueprint.Module) bool {
|
||||||
if aModule := m.validateAndroidModule(module); aModule != nil {
|
if aModule := b.validateAndroidModule(module, b.strictVisitDeps); aModule != nil {
|
||||||
return pred(aModule)
|
return pred(aModule)
|
||||||
} else {
|
} else {
|
||||||
return false
|
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) {
|
func (b *baseModuleContext) WalkDepsBlueprint(visit func(blueprint.Module, blueprint.Module) bool) {
|
||||||
m.ModuleContext.WalkDeps(visit)
|
b.BaseModuleContext.WalkDeps(visit)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) WalkDeps(visit func(Module, Module) bool) {
|
func (b *baseModuleContext) WalkDeps(visit func(Module, Module) bool) {
|
||||||
m.ModuleContext.WalkDeps(func(child, parent blueprint.Module) bool {
|
b.walkPath = []Module{b.Module()}
|
||||||
childAndroidModule := m.validateAndroidModule(child)
|
b.BaseModuleContext.WalkDeps(func(child, parent blueprint.Module) bool {
|
||||||
parentAndroidModule := m.validateAndroidModule(parent)
|
childAndroidModule, _ := child.(Module)
|
||||||
|
parentAndroidModule, _ := parent.(Module)
|
||||||
if childAndroidModule != nil && parentAndroidModule != nil {
|
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)
|
return visit(childAndroidModule, parentAndroidModule)
|
||||||
} else {
|
} else {
|
||||||
return false
|
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)) {
|
func (m *moduleContext) VisitAllModuleVariants(visit func(Module)) {
|
||||||
m.ModuleContext.VisitAllModuleVariants(func(module blueprint.Module) {
|
m.bp.VisitAllModuleVariants(func(module blueprint.Module) {
|
||||||
visit(module.(Module))
|
visit(module.(Module))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) PrimaryModule() Module {
|
func (m *moduleContext) PrimaryModule() Module {
|
||||||
return m.ModuleContext.PrimaryModule().(Module)
|
return m.bp.PrimaryModule().(Module)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) FinalModule() 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 {
|
func (b *baseModuleContext) Target() Target {
|
||||||
@@ -1584,20 +1631,20 @@ func (m *moduleContext) TargetRequiredModuleNames() []string {
|
|||||||
return m.module.base().commonProperties.Target_required
|
return m.module.base().commonProperties.Target_required
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) Glob(globPattern string, excludes []string) Paths {
|
func (b *baseModuleContext) Glob(globPattern string, excludes []string) Paths {
|
||||||
ret, err := m.GlobWithDeps(globPattern, excludes)
|
ret, err := b.GlobWithDeps(globPattern, excludes)
|
||||||
if err != nil {
|
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 {
|
func (b *baseModuleContext) GlobFiles(globPattern string, excludes []string) Paths {
|
||||||
ret, err := m.GlobWithDeps(globPattern, excludes)
|
ret, err := b.GlobWithDeps(globPattern, excludes)
|
||||||
if err != nil {
|
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() {
|
func init() {
|
||||||
|
@@ -115,35 +115,14 @@ type TopDownMutator func(TopDownMutatorContext)
|
|||||||
type TopDownMutatorContext interface {
|
type TopDownMutatorContext interface {
|
||||||
BaseModuleContext
|
BaseModuleContext
|
||||||
|
|
||||||
OtherModuleExists(name string) bool
|
|
||||||
Rename(name string)
|
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{})
|
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 {
|
type topDownMutatorContext struct {
|
||||||
blueprint.TopDownMutatorContext
|
bp blueprint.TopDownMutatorContext
|
||||||
baseModuleContext
|
baseModuleContext
|
||||||
walkPath []Module
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type BottomUpMutator func(BottomUpMutatorContext)
|
type BottomUpMutator func(BottomUpMutatorContext)
|
||||||
@@ -151,9 +130,7 @@ type BottomUpMutator func(BottomUpMutatorContext)
|
|||||||
type BottomUpMutatorContext interface {
|
type BottomUpMutatorContext interface {
|
||||||
BaseModuleContext
|
BaseModuleContext
|
||||||
|
|
||||||
OtherModuleExists(name string) bool
|
|
||||||
Rename(name string)
|
Rename(name string)
|
||||||
Module() blueprint.Module
|
|
||||||
|
|
||||||
AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string)
|
AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string)
|
||||||
AddReverseDependency(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 {
|
type bottomUpMutatorContext struct {
|
||||||
blueprint.BottomUpMutatorContext
|
bp blueprint.BottomUpMutatorContext
|
||||||
baseModuleContext
|
baseModuleContext
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +152,7 @@ func (x *registerMutatorsContext) BottomUp(name string, m BottomUpMutator) Mutat
|
|||||||
f := func(ctx blueprint.BottomUpMutatorContext) {
|
f := func(ctx blueprint.BottomUpMutatorContext) {
|
||||||
if a, ok := ctx.Module().(Module); ok {
|
if a, ok := ctx.Module().(Module); ok {
|
||||||
actx := &bottomUpMutatorContext{
|
actx := &bottomUpMutatorContext{
|
||||||
BottomUpMutatorContext: ctx,
|
bp: ctx,
|
||||||
baseModuleContext: a.base().baseModuleContextFactory(ctx),
|
baseModuleContext: a.base().baseModuleContextFactory(ctx),
|
||||||
}
|
}
|
||||||
m(actx)
|
m(actx)
|
||||||
@@ -190,7 +167,7 @@ func (x *registerMutatorsContext) TopDown(name string, m TopDownMutator) Mutator
|
|||||||
f := func(ctx blueprint.TopDownMutatorContext) {
|
f := func(ctx blueprint.TopDownMutatorContext) {
|
||||||
if a, ok := ctx.Module().(Module); ok {
|
if a, ok := ctx.Module().(Module); ok {
|
||||||
actx := &topDownMutatorContext{
|
actx := &topDownMutatorContext{
|
||||||
TopDownMutatorContext: ctx,
|
bp: ctx,
|
||||||
baseModuleContext: a.base().baseModuleContextFactory(ctx),
|
baseModuleContext: a.base().baseModuleContextFactory(ctx),
|
||||||
}
|
}
|
||||||
m(actx)
|
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{}) {
|
func (t *topDownMutatorContext) AppendProperties(props ...interface{}) {
|
||||||
for _, p := range props {
|
for _, p := range props {
|
||||||
err := proptools.AppendMatchingProperties(t.Module().base().customizableProperties,
|
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)
|
||||||
|
}
|
||||||
|
99
android/mutator_test.go
Normal file
99
android/mutator_test.go
Normal file
@@ -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 (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"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) {
|
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)
|
config := TestConfig(buildDir, nil)
|
||||||
|
|
||||||
ctx = NewTestContext()
|
ctx = NewTestContext()
|
||||||
|
@@ -15,8 +15,6 @@
|
|||||||
package android
|
package android
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -183,12 +181,6 @@ var neverallowTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNeverallow(t *testing.T) {
|
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)
|
config := TestConfig(buildDir, nil)
|
||||||
|
|
||||||
for _, test := range neverallowTests {
|
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.
|
// 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
|
// It intended for use in globs that only list files that exist, so it allows '$' in
|
||||||
// filenames.
|
// 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()) + "/"
|
prefix := filepath.Join(ctx.Config().srcDir, ctx.ModuleDir()) + "/"
|
||||||
if prefix == "./" {
|
if prefix == "./" {
|
||||||
prefix = ""
|
prefix = ""
|
||||||
|
@@ -17,8 +17,6 @@ package android
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -758,6 +756,11 @@ func (p *pathForModuleSrcTestModule) GenerateAndroidBuildActions(ctx ModuleConte
|
|||||||
if !p.props.Module_handles_missing_deps {
|
if !p.props.Module_handles_missing_deps {
|
||||||
p.missingDeps = ctx.GetMissingDependencies()
|
p.missingDeps = ctx.GetMissingDependencies()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.Build(pctx, BuildParams{
|
||||||
|
Rule: Touch,
|
||||||
|
Output: PathForModuleOut(ctx, "output"),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type pathForModuleSrcOutputFileProviderModule struct {
|
type pathForModuleSrcOutputFileProviderModule struct {
|
||||||
@@ -875,12 +878,6 @@ func testPathForModuleSrc(t *testing.T, buildDir string, tests []pathForModuleSr
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPathsForModuleSrc(t *testing.T) {
|
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{
|
tests := []pathForModuleSrcTestCase{
|
||||||
{
|
{
|
||||||
name: "path",
|
name: "path",
|
||||||
@@ -961,12 +958,6 @@ func TestPathsForModuleSrc(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPathForModuleSrc(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{
|
tests := []pathForModuleSrcTestCase{
|
||||||
{
|
{
|
||||||
name: "path",
|
name: "path",
|
||||||
@@ -1034,12 +1025,6 @@ func TestPathForModuleSrc(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPathsForModuleSrc_AllowMissingDependencies(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 := TestConfig(buildDir, nil)
|
||||||
config.TestProductVariables.Allow_missing_dependencies = proptools.BoolPtr(true)
|
config.TestProductVariables.Allow_missing_dependencies = proptools.BoolPtr(true)
|
||||||
|
|
||||||
|
@@ -15,16 +15,13 @@
|
|||||||
package android
|
package android
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testPrebuiltEtc(t *testing.T, bp string) (*TestContext, Config) {
|
func testPrebuiltEtc(t *testing.T, bp string) (*TestContext, Config) {
|
||||||
config, buildDir := setUp(t)
|
config := TestArchConfig(buildDir, nil)
|
||||||
defer tearDown(buildDir)
|
|
||||||
ctx := NewTestArchContext()
|
ctx := NewTestArchContext()
|
||||||
ctx.RegisterModuleType("prebuilt_etc", ModuleFactoryAdaptor(PrebuiltEtcFactory))
|
ctx.RegisterModuleType("prebuilt_etc", ModuleFactoryAdaptor(PrebuiltEtcFactory))
|
||||||
ctx.RegisterModuleType("prebuilt_etc_host", ModuleFactoryAdaptor(PrebuiltEtcHostFactory))
|
ctx.RegisterModuleType("prebuilt_etc_host", ModuleFactoryAdaptor(PrebuiltEtcHostFactory))
|
||||||
@@ -51,20 +48,6 @@ func testPrebuiltEtc(t *testing.T, bp string) (*TestContext, Config) {
|
|||||||
return ctx, 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) {
|
func TestPrebuiltEtcVariants(t *testing.T) {
|
||||||
ctx, _ := testPrebuiltEtc(t, `
|
ctx, _ := testPrebuiltEtc(t, `
|
||||||
prebuilt_etc {
|
prebuilt_etc {
|
||||||
|
@@ -16,8 +16,6 @@ package android
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
@@ -127,12 +125,6 @@ var prebuiltsTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPrebuilts(t *testing.T) {
|
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)
|
config := TestConfig(buildDir, nil)
|
||||||
|
|
||||||
for _, test := range prebuiltsTests {
|
for _, test := range prebuiltsTests {
|
||||||
|
@@ -16,8 +16,6 @@ package android
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -418,12 +416,6 @@ func testRuleBuilder_Build(ctx BuilderContext, in Path, out, outDep, outDir Writ
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRuleBuilder_Build(t *testing.T) {
|
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 := `
|
bp := `
|
||||||
rule_builder_test {
|
rule_builder_test {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
|
@@ -1,19 +1,11 @@
|
|||||||
package android
|
package android
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testShBinary(t *testing.T, bp string) (*TestContext, Config) {
|
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)
|
config := TestArchConfig(buildDir, nil)
|
||||||
|
|
||||||
ctx := NewTestArchContext()
|
ctx := NewTestArchContext()
|
||||||
|
@@ -179,7 +179,7 @@ func buildParamsFromRule(provider testBuildProvider, rule string) TestingBuildPa
|
|||||||
|
|
||||||
func maybeBuildParamsFromDescription(provider testBuildProvider, desc string) TestingBuildParams {
|
func maybeBuildParamsFromDescription(provider testBuildProvider, desc string) TestingBuildParams {
|
||||||
for _, p := range provider.BuildParamsForTests() {
|
for _, p := range provider.BuildParamsForTests() {
|
||||||
if p.Description == desc {
|
if strings.Contains(p.Description, desc) {
|
||||||
return newTestingBuildParams(provider, p)
|
return newTestingBuildParams(provider, p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
package android
|
package android
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
@@ -663,12 +661,6 @@ var visibilityTests = []struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestVisibility(t *testing.T) {
|
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 {
|
for _, test := range visibilityTests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
_, errs := testVisibility(buildDir, test.fs)
|
_, errs := testVisibility(buildDir, test.fs)
|
||||||
@@ -759,6 +751,3 @@ func defaultsFactory() Module {
|
|||||||
InitDefaultsModule(m)
|
InitDefaultsModule(m)
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*mockDefaults) GenerateAndroidBuildActions(ctx ModuleContext) {
|
|
||||||
}
|
|
||||||
|
@@ -15,19 +15,11 @@
|
|||||||
package android
|
package android
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func testVtsConfig(test *testing.T, bpFileContents string) *TestContext {
|
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)
|
config := TestArchConfig(buildDir, nil)
|
||||||
defer func() { os.RemoveAll(buildDir) }()
|
|
||||||
|
|
||||||
ctx := NewTestArchContext()
|
ctx := NewTestArchContext()
|
||||||
ctx.RegisterModuleType("vts_config", ModuleFactoryAdaptor(VtsConfigFactory))
|
ctx.RegisterModuleType("vts_config", ModuleFactoryAdaptor(VtsConfigFactory))
|
||||||
|
@@ -1295,9 +1295,6 @@ type Defaults struct {
|
|||||||
android.DefaultsModuleBase
|
android.DefaultsModuleBase
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func defaultsFactory() android.Module {
|
func defaultsFactory() android.Module {
|
||||||
return DefaultsFactory()
|
return DefaultsFactory()
|
||||||
}
|
}
|
||||||
|
3
cc/cc.go
3
cc/cc.go
@@ -2060,9 +2060,6 @@ type Defaults struct {
|
|||||||
android.ApexModuleBase
|
android.ApexModuleBase
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// cc_defaults provides a set of properties that can be inherited by other cc
|
// 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
|
// modules. A module can use the properties from a cc_defaults using
|
||||||
// `defaults: ["<:default_module_name>"]`. Properties of both modules are
|
// `defaults: ["<:default_module_name>"]`. Properties of both modules are
|
||||||
|
@@ -583,9 +583,6 @@ type Defaults struct {
|
|||||||
android.DefaultsModuleBase
|
android.DefaultsModuleBase
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func defaultsFactory() android.Module {
|
func defaultsFactory() android.Module {
|
||||||
return DefaultsFactory()
|
return DefaultsFactory()
|
||||||
}
|
}
|
||||||
|
@@ -1808,9 +1808,6 @@ type DocDefaults struct {
|
|||||||
android.DefaultsModuleBase
|
android.DefaultsModuleBase
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*DocDefaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|
||||||
}
|
|
||||||
|
|
||||||
func DocDefaultsFactory() android.Module {
|
func DocDefaultsFactory() android.Module {
|
||||||
module := &DocDefaults{}
|
module := &DocDefaults{}
|
||||||
|
|
||||||
|
@@ -2131,9 +2131,6 @@ type Defaults struct {
|
|||||||
android.DefaultsModuleBase
|
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.
|
// 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
|
// A module can use the properties from a java_defaults module using `defaults: ["defaults_module_name"]`. Each
|
||||||
|
Reference in New Issue
Block a user