Merge changes Id806633d,I05e945f3,Ieac84040,I18eb8cc0,If11c298e am: 17ae970a92

am: 70898c5f45

Change-Id: Iabd137dc87d3123530239cda8e7aba191b2a873a
This commit is contained in:
Colin Cross 2017-10-24 21:34:14 +00:00 committed by android-build-merger
commit cee7bf36c3
34 changed files with 465 additions and 298 deletions

View file

@ -67,6 +67,7 @@ bootstrap_go_package {
"android/expand_test.go",
"android/paths_test.go",
"android/prebuilt_test.go",
"android/util_test.go",
"android/variable_test.go",
],
}

View file

@ -131,7 +131,7 @@ func defaultsDepsMutator(ctx BottomUpMutatorContext) {
func defaultsMutator(ctx TopDownMutatorContext) {
if defaultable, ok := ctx.Module().(Defaultable); ok && len(defaultable.defaults().Defaults) > 0 {
var defaultsList []Defaults
ctx.WalkDeps(func(module, parent blueprint.Module) bool {
ctx.WalkDeps(func(module, parent Module) bool {
if ctx.OtherModuleDependencyTag(module) == DefaultsDepTag {
if defaults, ok := module.(Defaults); ok {
defaultsList = append(defaultsList, defaults)

View file

@ -32,7 +32,7 @@ var (
HostExecutable = "host_executable"
)
type ModuleBuildParams struct {
type BuildParams struct {
Rule blueprint.Rule
Deps blueprint.Deps
Depfile WritablePath
@ -50,6 +50,8 @@ type ModuleBuildParams struct {
Args map[string]string
}
type ModuleBuildParams BuildParams
type androidBaseContext interface {
Target() Target
TargetPrimary() bool
@ -72,11 +74,10 @@ type BaseContext interface {
}
type ModuleContext interface {
blueprint.ModuleContext
androidBaseContext
blueprint.BaseModuleContext
// Similar to Build, but takes Paths instead of []string,
// and performs more verification.
// Deprecated: use ModuleContext.Build instead.
ModuleBuild(pctx blueprint.PackageContext, params ModuleBuildParams)
ExpandSources(srcFiles, excludes []string) Paths
@ -94,6 +95,36 @@ type ModuleContext interface {
InstallInSanitizerDir() bool
RequiredModuleNames() []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
GetDirectDepWithTag(name string, tag blueprint.DependencyTag) blueprint.Module
GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
ModuleSubDir() string
VisitDirectDeps(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)
Variable(pctx blueprint.PackageContext, name, value string)
Rule(pctx blueprint.PackageContext, name string, params blueprint.RuleParams, argNames ...string) blueprint.Rule
// Similar to blueprint.ModuleContext.Build, but takes Paths instead of []string,
// and performs more verification.
Build(pctx blueprint.PackageContext, params BuildParams)
PrimaryModule() blueprint.Module
FinalModule() blueprint.Module
VisitAllModuleVariants(visit func(blueprint.Module))
GetMissingDependencies() []string
}
type Module interface {
@ -116,7 +147,7 @@ type Module interface {
AddProperties(props ...interface{})
GetProperties() []interface{}
BuildParamsForTests() []ModuleBuildParams
BuildParamsForTests() []BuildParams
}
type nameProperties struct {
@ -302,7 +333,7 @@ type ModuleBase struct {
registerProps []interface{}
// For tests
buildParams []ModuleBuildParams
buildParams []BuildParams
}
func (a *ModuleBase) AddProperties(props ...interface{}) {
@ -313,7 +344,7 @@ func (a *ModuleBase) GetProperties() []interface{} {
return a.registerProps
}
func (a *ModuleBase) BuildParamsForTests() []ModuleBuildParams {
func (a *ModuleBase) BuildParamsForTests() []BuildParams {
return a.buildParams
}
@ -558,7 +589,7 @@ type androidModuleContext struct {
module Module
// For tests
buildParams []ModuleBuildParams
buildParams []BuildParams
}
func (a *androidModuleContext) ninjaError(desc string, outputs []string, err error) {
@ -574,19 +605,11 @@ func (a *androidModuleContext) ninjaError(desc string, outputs []string, err err
return
}
func (a *androidModuleContext) Build(pctx blueprint.PackageContext, params blueprint.BuildParams) {
if a.missingDeps != nil {
a.ninjaError(params.Description, params.Outputs,
fmt.Errorf("module %s missing dependencies: %s\n",
a.ModuleName(), strings.Join(a.missingDeps, ", ")))
return
}
params.Optional = true
a.ModuleContext.Build(pctx, params)
func (a *androidModuleContext) ModuleBuild(pctx blueprint.PackageContext, params ModuleBuildParams) {
a.Build(pctx, BuildParams(params))
}
func (a *androidModuleContext) ModuleBuild(pctx blueprint.PackageContext, params ModuleBuildParams) {
func (a *androidModuleContext) Build(pctx blueprint.PackageContext, params BuildParams) {
if a.config.captureBuild {
a.buildParams = append(a.buildParams, params)
}
@ -640,9 +663,89 @@ func (a *androidModuleContext) GetMissingDependencies() []string {
func (a *androidModuleContext) AddMissingDependencies(deps []string) {
if deps != nil {
a.missingDeps = append(a.missingDeps, deps...)
a.missingDeps = FirstUniqueStrings(a.missingDeps)
}
}
func (a *androidModuleContext) validateAndroidModule(module blueprint.Module) Module {
aModule, _ := module.(Module)
if aModule == nil {
a.ModuleErrorf("module %q not an android module", a.OtherModuleName(aModule))
return nil
}
if !aModule.Enabled() {
if a.AConfig().AllowMissingDependencies() {
a.AddMissingDependencies([]string{a.OtherModuleName(aModule)})
} else {
a.ModuleErrorf("depends on disabled module %q", a.OtherModuleName(aModule))
}
return nil
}
return aModule
}
func (a *androidModuleContext) VisitDirectDeps(visit func(Module)) {
a.ModuleContext.VisitDirectDeps(func(module blueprint.Module) {
if aModule := a.validateAndroidModule(module); aModule != nil {
visit(aModule)
}
})
}
func (a *androidModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
a.ModuleContext.VisitDirectDepsIf(
// pred
func(module blueprint.Module) bool {
if aModule := a.validateAndroidModule(module); aModule != nil {
return pred(aModule)
} else {
return false
}
},
// visit
func(module blueprint.Module) {
visit(module.(Module))
})
}
func (a *androidModuleContext) VisitDepsDepthFirst(visit func(Module)) {
a.ModuleContext.VisitDepsDepthFirst(func(module blueprint.Module) {
if aModule := a.validateAndroidModule(module); aModule != nil {
visit(aModule)
}
})
}
func (a *androidModuleContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
a.ModuleContext.VisitDepsDepthFirstIf(
// pred
func(module blueprint.Module) bool {
if aModule := a.validateAndroidModule(module); aModule != nil {
return pred(aModule)
} else {
return false
}
},
// visit
func(module blueprint.Module) {
visit(module.(Module))
})
}
func (a *androidModuleContext) WalkDeps(visit func(Module, Module) bool) {
a.ModuleContext.WalkDeps(func(child, parent blueprint.Module) bool {
childAndroidModule := a.validateAndroidModule(child)
parentAndroidModule := a.validateAndroidModule(parent)
if childAndroidModule != nil && parentAndroidModule != nil {
return visit(childAndroidModule, parentAndroidModule)
} else {
return false
}
})
}
func (a *androidBaseContextImpl) Target() Target {
return a.target
}
@ -754,7 +857,7 @@ func (a *androidModuleContext) installFile(installPath OutputPath, name string,
orderOnlyDeps = deps
}
a.ModuleBuild(pctx, ModuleBuildParams{
a.Build(pctx, BuildParams{
Rule: rule,
Description: "install " + fullInstallPath.Base(),
Output: fullInstallPath,
@ -776,7 +879,7 @@ func (a *androidModuleContext) InstallSymlink(installPath OutputPath, name strin
if !a.skipInstall(fullInstallPath) {
a.ModuleBuild(pctx, ModuleBuildParams{
a.Build(pctx, BuildParams{
Rule: Symlink,
Description: "install symlink " + fullInstallPath.Base(),
Output: fullInstallPath,
@ -879,6 +982,10 @@ func (ctx *androidModuleContext) ExpandSourcesSubDir(srcFiles, excludes []string
for _, s := range srcFiles {
if m := SrcIsModule(s); m != "" {
module := ctx.GetDirectDepWithTag(m, SourceDepTag)
if module == nil {
// Error will have been handled by ExtractSourcesDeps
continue
}
if srcProducer, ok := module.(SourceFileProducer); ok {
expandedSrcFiles = append(expandedSrcFiles, srcProducer.Srcs()...)
} else {

View file

@ -107,8 +107,27 @@ func PostDepsMutators(f RegisterMutatorFunc) {
type AndroidTopDownMutator func(TopDownMutatorContext)
type TopDownMutatorContext interface {
blueprint.TopDownMutatorContext
blueprint.BaseModuleContext
androidBaseContext
OtherModuleExists(name string) bool
Rename(name string)
Module() blueprint.Module
OtherModuleName(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))
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)
}
type androidTopDownMutatorContext struct {
@ -172,3 +191,63 @@ func depsMutator(ctx BottomUpMutatorContext) {
m.DepsMutator(ctx)
}
}
func (a *androidTopDownMutatorContext) VisitDirectDeps(visit func(Module)) {
a.TopDownMutatorContext.VisitDirectDeps(func(module blueprint.Module) {
if aModule, _ := module.(Module); aModule != nil {
visit(aModule)
}
})
}
func (a *androidTopDownMutatorContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
a.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 (a *androidTopDownMutatorContext) VisitDepsDepthFirst(visit func(Module)) {
a.TopDownMutatorContext.VisitDepsDepthFirst(func(module blueprint.Module) {
if aModule, _ := module.(Module); aModule != nil {
visit(aModule)
}
})
}
func (a *androidTopDownMutatorContext) VisitDepsDepthFirstIf(pred func(Module) bool, visit func(Module)) {
a.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 (a *androidTopDownMutatorContext) WalkDeps(visit func(Module, Module) bool) {
a.TopDownMutatorContext.WalkDeps(func(child, parent blueprint.Module) bool {
childAndroidModule, _ := child.(Module)
parentAndroidModule, _ := parent.(Module)
if childAndroidModule != nil && parentAndroidModule != nil {
return visit(childAndroidModule, parentAndroidModule)
} else {
return false
}
})
}

View file

@ -286,8 +286,8 @@ func (p Paths) Strings() []string {
return ret
}
// FirstUniqueElements returns all unique elements of a slice, keeping the first copy of each
// modifies the slice contents in place, and returns a subslice of the original slice
// FirstUniquePaths returns all unique elements of a Paths, keeping the first copy of each. It
// modifies the Paths slice contents in place, and returns a subslice of the original slice.
func FirstUniquePaths(list Paths) Paths {
k := 0
outer:
@ -303,6 +303,24 @@ outer:
return list[:k]
}
// LastUniquePaths returns all unique elements of a Paths, keeping the last copy of each. It
// modifies the Paths slice contents in place, and returns a subslice of the original slice.
func LastUniquePaths(list Paths) Paths {
totalSkip := 0
for i := len(list) - 1; i >= totalSkip; i-- {
skip := 0
for j := i - 1; j >= totalSkip; j-- {
if list[i] == list[j] {
skip++
} else {
list[j+skip] = list[j]
}
}
totalSkip += skip
}
return list[totalSkip:]
}
func indexPathList(s Path, list []Path) int {
for i, l := range list {
if l == s {

View file

@ -109,7 +109,7 @@ func PrebuiltSelectModuleMutator(ctx TopDownMutatorContext) {
p.properties.UsePrebuilt = p.usePrebuilt(ctx, nil)
}
} else if s, ok := ctx.Module().(Module); ok {
ctx.VisitDirectDeps(func(m blueprint.Module) {
ctx.VisitDirectDeps(func(m Module) {
if ctx.OtherModuleDependencyTag(m) == prebuiltDepTag {
p := m.(PrebuiltInterface).Prebuilt()
if p.usePrebuilt(ctx, s) {

View file

@ -86,7 +86,7 @@ func (m TestingModule) Module() Module {
return m.module
}
func (m TestingModule) Rule(rule string) ModuleBuildParams {
func (m TestingModule) Rule(rule string) BuildParams {
for _, p := range m.module.BuildParamsForTests() {
if strings.Contains(p.Rule.String(), rule) {
return p
@ -95,7 +95,7 @@ func (m TestingModule) Rule(rule string) ModuleBuildParams {
panic(fmt.Errorf("couldn't find rule %q", rule))
}
func (m TestingModule) Description(desc string) ModuleBuildParams {
func (m TestingModule) Description(desc string) BuildParams {
for _, p := range m.module.BuildParamsForTests() {
if p.Description == desc {
return p
@ -104,7 +104,7 @@ func (m TestingModule) Description(desc string) ModuleBuildParams {
panic(fmt.Errorf("couldn't find description %q", desc))
}
func (m TestingModule) Output(file string) ModuleBuildParams {
func (m TestingModule) Output(file string) BuildParams {
for _, p := range m.module.BuildParamsForTests() {
outputs := append(WritablePaths(nil), p.Outputs...)
if p.Output != nil {

View file

@ -77,6 +77,41 @@ func prefixInList(s string, list []string) bool {
return false
}
// FirstUniqueStrings returns all unique elements of a slice of strings, keeping the first copy of
// each. It modifies the slice contents in place, and returns a subslice of the original slice.
func FirstUniqueStrings(list []string) []string {
k := 0
outer:
for i := 0; i < len(list); i++ {
for j := 0; j < k; j++ {
if list[i] == list[j] {
continue outer
}
}
list[k] = list[i]
k++
}
return list[:k]
}
// LastUniqueStrings returns all unique elements of a slice of strings, keeping the last copy of
// each. It modifies the slice contents in place, and returns a subslice of the original slice.
func LastUniqueStrings(list []string) []string {
totalSkip := 0
for i := len(list) - 1; i >= totalSkip; i-- {
skip := 0
for j := i - 1; j >= totalSkip; j-- {
if list[i] == list[j] {
skip++
} else {
list[j+skip] = list[j]
}
}
totalSkip += skip
}
return list[totalSkip:]
}
// checkCalledFromInit panics if a Go package's init function is not on the
// call stack.
func checkCalledFromInit() {

120
android/util_test.go Normal file
View file

@ -0,0 +1,120 @@
// Copyright 2017 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 (
"reflect"
"testing"
)
var firstUniqueStringsTestCases = []struct {
in []string
out []string
}{
{
in: []string{"a"},
out: []string{"a"},
},
{
in: []string{"a", "b"},
out: []string{"a", "b"},
},
{
in: []string{"a", "a"},
out: []string{"a"},
},
{
in: []string{"a", "b", "a"},
out: []string{"a", "b"},
},
{
in: []string{"b", "a", "a"},
out: []string{"b", "a"},
},
{
in: []string{"a", "a", "b"},
out: []string{"a", "b"},
},
{
in: []string{"a", "b", "a", "b"},
out: []string{"a", "b"},
},
{
in: []string{"liblog", "libdl", "libc++", "libdl", "libc", "libm"},
out: []string{"liblog", "libdl", "libc++", "libc", "libm"},
},
}
func TestFirstUniqueStrings(t *testing.T) {
for _, testCase := range firstUniqueStringsTestCases {
out := FirstUniqueStrings(testCase.in)
if !reflect.DeepEqual(out, testCase.out) {
t.Errorf("incorrect output:")
t.Errorf(" input: %#v", testCase.in)
t.Errorf(" expected: %#v", testCase.out)
t.Errorf(" got: %#v", out)
}
}
}
var lastUniqueStringsTestCases = []struct {
in []string
out []string
}{
{
in: []string{"a"},
out: []string{"a"},
},
{
in: []string{"a", "b"},
out: []string{"a", "b"},
},
{
in: []string{"a", "a"},
out: []string{"a"},
},
{
in: []string{"a", "b", "a"},
out: []string{"b", "a"},
},
{
in: []string{"b", "a", "a"},
out: []string{"b", "a"},
},
{
in: []string{"a", "a", "b"},
out: []string{"a", "b"},
},
{
in: []string{"a", "b", "a", "b"},
out: []string{"a", "b"},
},
{
in: []string{"liblog", "libdl", "libc++", "libdl", "libc", "libm"},
out: []string{"liblog", "libc++", "libdl", "libc", "libm"},
},
}
func TestLastUniqueStrings(t *testing.T) {
for _, testCase := range lastUniqueStringsTestCases {
out := LastUniqueStrings(testCase.in)
if !reflect.DeepEqual(out, testCase.out) {
t.Errorf("incorrect output:")
t.Errorf(" input: %#v", testCase.in)
t.Errorf(" expected: %#v", testCase.out)
t.Errorf(" got: %#v", out)
}
}
}

View file

@ -341,7 +341,7 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
switch srcFile.Ext() {
case ".asm":
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: yasm,
Description: "yasm " + srcFile.Rel(),
Output: objFile,
@ -353,7 +353,7 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
})
continue
case ".rc":
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: windres,
Description: "windres " + srcFile.Rel(),
Output: objFile,
@ -420,7 +420,7 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
coverageFiles = append(coverageFiles, gcnoFile)
}
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: cc,
Description: ccDesc + " " + srcFile.Rel(),
Output: objFile,
@ -437,7 +437,7 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
tidyFile := android.ObjPathWithExt(ctx, subdir, srcFile, "tidy")
tidyFiles = append(tidyFiles, tidyFile)
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: clangTidy,
Description: "clang-tidy " + srcFile.Rel(),
Output: tidyFile,
@ -456,7 +456,7 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
sAbiDumpFile := android.ObjPathWithExt(ctx, subdir, srcFile, "sdump")
sAbiDumpFiles = append(sAbiDumpFiles, sAbiDumpFile)
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: sAbiDump,
Description: "header-abi-dumper " + srcFile.Rel(),
Output: sAbiDumpFile,
@ -494,7 +494,7 @@ func TransformObjToStaticLib(ctx android.ModuleContext, objFiles android.Paths,
arFlags += " " + flags.arFlags
}
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: ar,
Description: "static link " + outputFile.Base(),
Output: outputFile,
@ -520,14 +520,14 @@ func transformDarwinObjToStaticLib(ctx android.ModuleContext, objFiles android.P
dummy := android.PathForModuleOut(ctx, "dummy"+objectExtension)
dummyAr := android.PathForModuleOut(ctx, "dummy"+staticLibraryExtension)
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: emptyFile,
Description: "empty object file",
Output: dummy,
Implicits: deps,
})
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: darwinAr,
Description: "empty static archive",
Output: dummyAr,
@ -537,7 +537,7 @@ func transformDarwinObjToStaticLib(ctx android.ModuleContext, objFiles android.P
},
})
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: darwinAppendAr,
Description: "static link " + outputFile.Base(),
Output: outputFile,
@ -565,7 +565,7 @@ func transformDarwinObjToStaticLib(ctx android.ModuleContext, objFiles android.P
out = android.PathForModuleOut(ctx, outputFile.Base()+strconv.Itoa(i))
}
build := android.ModuleBuildParams{
build := android.BuildParams{
Rule: darwinAr,
Description: "static link " + out.Base(),
Output: out,
@ -579,7 +579,7 @@ func transformDarwinObjToStaticLib(ctx android.ModuleContext, objFiles android.P
build.Rule = darwinAppendAr
build.Args["inAr"] = in.String()
}
ctx.ModuleBuild(pctx, build)
ctx.Build(pctx, build)
}
}
@ -639,7 +639,7 @@ func TransformObjToDynamicBinary(ctx android.ModuleContext,
deps = append(deps, crtBegin.Path(), crtEnd.Path())
}
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: ld,
Description: "link " + outputFile.Base(),
Output: outputFile,
@ -669,7 +669,7 @@ func TransformDumpToLinkedDump(ctx android.ModuleContext, sAbiDumps android.Path
linkedDumpDep = soFile
symbolFilterStr = "-so " + soFile.String()
}
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: sAbiLink,
Description: "header-abi-linker " + outputFile.Base(),
Output: outputFile,
@ -687,7 +687,7 @@ func TransformDumpToLinkedDump(ctx android.ModuleContext, sAbiDumps android.Path
func UnzipRefDump(ctx android.ModuleContext, zippedRefDump android.Path, baseName string) android.Path {
outputFile := android.PathForModuleOut(ctx, baseName+"_ref.lsdump")
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: unzipRefSAbiDump,
Description: "gunzip" + outputFile.Base(),
Output: outputFile,
@ -699,7 +699,7 @@ func UnzipRefDump(ctx android.ModuleContext, zippedRefDump android.Path, baseNam
func SourceAbiDiff(ctx android.ModuleContext, inputDump android.Path, referenceDump android.Path,
baseName string) android.OptionalPath {
outputFile := android.PathForModuleOut(ctx, baseName+".abidiff")
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: sAbiDiff,
Description: "header-abi-diff " + outputFile.Base(),
Output: outputFile,
@ -720,7 +720,7 @@ func TransformSharedObjectToToc(ctx android.ModuleContext, inputFile android.Pat
crossCompile := gccCmd(flags.toolchain, "")
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: toc,
Description: "generate toc " + inputFile.Base(),
Output: outputFile,
@ -742,7 +742,7 @@ func TransformObjsToObj(ctx android.ModuleContext, objFiles android.Paths,
ldCmd = gccCmd(flags.toolchain, "g++")
}
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: partialLd,
Description: "link " + outputFile.Base(),
Output: outputFile,
@ -760,7 +760,7 @@ func TransformBinaryPrefixSymbols(ctx android.ModuleContext, prefix string, inpu
objcopyCmd := gccCmd(flags.toolchain, "objcopy")
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: prefixSymbols,
Description: "prefix symbols " + outputFile.Base(),
Output: outputFile,
@ -787,7 +787,7 @@ func TransformStrip(ctx android.ModuleContext, inputFile android.Path,
args += " --keep-symbols"
}
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: strip,
Description: "strip " + outputFile.Base(),
Output: outputFile,
@ -802,7 +802,7 @@ func TransformStrip(ctx android.ModuleContext, inputFile android.Path,
func TransformDarwinStrip(ctx android.ModuleContext, inputFile android.Path,
outputFile android.WritablePath) {
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: darwinStrip,
Description: "strip " + outputFile.Base(),
Output: outputFile,
@ -827,7 +827,7 @@ func TransformCoverageFilesToLib(ctx android.ModuleContext,
func CopyGccLib(ctx android.ModuleContext, libName string,
flags builderFlags, outputFile android.WritablePath) {
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: copyGccLib,
Description: "copy gcc library " + libName,
Output: outputFile,

View file

@ -561,7 +561,7 @@ func orderDeps(directDeps []android.Path, transitiveDeps map[android.Path][]andr
orderedAllDeps = append(orderedAllDeps, transitiveDeps[dep]...)
}
orderedAllDeps = lastUniquePaths(orderedAllDeps)
orderedAllDeps = android.LastUniquePaths(orderedAllDeps)
// We don't want to add any new dependencies into directDeps (to allow the caller to
// intentionally exclude or replace any unwanted transitive dependencies), so we limit the
@ -763,12 +763,12 @@ func (c *Module) deps(ctx DepsContext) Deps {
deps = feature.deps(ctx, deps)
}
deps.WholeStaticLibs = lastUniqueElements(deps.WholeStaticLibs)
deps.StaticLibs = lastUniqueElements(deps.StaticLibs)
deps.LateStaticLibs = lastUniqueElements(deps.LateStaticLibs)
deps.SharedLibs = lastUniqueElements(deps.SharedLibs)
deps.LateSharedLibs = lastUniqueElements(deps.LateSharedLibs)
deps.HeaderLibs = lastUniqueElements(deps.HeaderLibs)
deps.WholeStaticLibs = android.LastUniqueStrings(deps.WholeStaticLibs)
deps.StaticLibs = android.LastUniqueStrings(deps.StaticLibs)
deps.LateStaticLibs = android.LastUniqueStrings(deps.LateStaticLibs)
deps.SharedLibs = android.LastUniqueStrings(deps.SharedLibs)
deps.LateSharedLibs = android.LastUniqueStrings(deps.LateSharedLibs)
deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs)
for _, lib := range deps.ReexportSharedLibHeaders {
if !inList(lib, deps.SharedLibs) {
@ -1037,16 +1037,10 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
directStaticDeps := []*Module{}
ctx.VisitDirectDeps(func(dep blueprint.Module) {
ctx.VisitDirectDeps(func(dep android.Module) {
depName := ctx.OtherModuleName(dep)
depTag := ctx.OtherModuleDependencyTag(dep)
aDep, _ := dep.(android.Module)
if aDep == nil {
ctx.ModuleErrorf("module %q not an android module", depName)
return
}
ccDep, _ := dep.(*Module)
if ccDep == nil {
// handling for a few module types that aren't cc Module but that are also supported
@ -1096,20 +1090,11 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
return
}
// some validation
if !aDep.Enabled() {
if ctx.AConfig().AllowMissingDependencies() {
ctx.AddMissingDependencies([]string{depName})
} else {
ctx.ModuleErrorf("depends on disabled module %q", depName)
}
return
}
if aDep.Target().Os != ctx.Os() {
if dep.Target().Os != ctx.Os() {
ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
return
}
if aDep.Target().Arch.ArchType != ctx.Arch().ArchType {
if dep.Target().Arch.ArchType != ctx.Arch().ArchType {
ctx.ModuleErrorf("Arch mismatch between %q and %q", ctx.ModuleName(), depName)
return
}
@ -1249,13 +1234,13 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
depPaths.StaticLibs = append(depPaths.StaticLibs, orderStaticModuleDeps(c, directStaticDeps)...)
// Dedup exported flags from dependencies
depPaths.Flags = firstUniqueElements(depPaths.Flags)
depPaths.Flags = android.FirstUniqueStrings(depPaths.Flags)
depPaths.GeneratedHeaders = android.FirstUniquePaths(depPaths.GeneratedHeaders)
depPaths.ReexportedFlags = firstUniqueElements(depPaths.ReexportedFlags)
depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags)
depPaths.ReexportedFlagsDeps = android.FirstUniquePaths(depPaths.ReexportedFlagsDeps)
if c.sabi != nil {
c.sabi.Properties.ReexportedIncludeFlags = firstUniqueElements(c.sabi.Properties.ReexportedIncludeFlags)
c.sabi.Properties.ReexportedIncludeFlags = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludeFlags)
}
return depPaths
@ -1438,58 +1423,6 @@ func vendorMutator(mctx android.BottomUpMutatorContext) {
}
}
// firstUniqueElements returns all unique elements of a slice, keeping the first copy of each
// modifies the slice contents in place, and returns a subslice of the original slice
func firstUniqueElements(list []string) []string {
k := 0
outer:
for i := 0; i < len(list); i++ {
for j := 0; j < k; j++ {
if list[i] == list[j] {
continue outer
}
}
list[k] = list[i]
k++
}
return list[:k]
}
// lastUniqueElements returns all unique elements of a slice, keeping the last copy of each.
// It modifies the slice contents in place, and returns a subslice of the original slice
func lastUniqueElements(list []string) []string {
totalSkip := 0
for i := len(list) - 1; i >= totalSkip; i-- {
skip := 0
for j := i - 1; j >= totalSkip; j-- {
if list[i] == list[j] {
skip++
} else {
list[j+skip] = list[j]
}
}
totalSkip += skip
}
return list[totalSkip:]
}
// lastUniquePaths is the same as lastUniqueElements but uses Path structs
func lastUniquePaths(list []android.Path) []android.Path {
totalSkip := 0
for i := len(list) - 1; i >= totalSkip; i-- {
skip := 0
for j := i - 1; j >= totalSkip; j-- {
if list[i] == list[j] {
skip++
} else {
list[j+skip] = list[j]
}
}
totalSkip += skip
}
return list[totalSkip:]
}
func getCurrentNdkPrebuiltVersion(ctx DepsContext) string {
if ctx.AConfig().PlatformSdkVersionInt() > config.NdkMaxPrebuiltVersionInt {
return strconv.Itoa(config.NdkMaxPrebuiltVersionInt)

View file

@ -156,106 +156,6 @@ func TestVendorSrc(t *testing.T) {
}
}
var firstUniqueElementsTestCases = []struct {
in []string
out []string
}{
{
in: []string{"a"},
out: []string{"a"},
},
{
in: []string{"a", "b"},
out: []string{"a", "b"},
},
{
in: []string{"a", "a"},
out: []string{"a"},
},
{
in: []string{"a", "b", "a"},
out: []string{"a", "b"},
},
{
in: []string{"b", "a", "a"},
out: []string{"b", "a"},
},
{
in: []string{"a", "a", "b"},
out: []string{"a", "b"},
},
{
in: []string{"a", "b", "a", "b"},
out: []string{"a", "b"},
},
{
in: []string{"liblog", "libdl", "libc++", "libdl", "libc", "libm"},
out: []string{"liblog", "libdl", "libc++", "libc", "libm"},
},
}
func TestFirstUniqueElements(t *testing.T) {
for _, testCase := range firstUniqueElementsTestCases {
out := firstUniqueElements(testCase.in)
if !reflect.DeepEqual(out, testCase.out) {
t.Errorf("incorrect output:")
t.Errorf(" input: %#v", testCase.in)
t.Errorf(" expected: %#v", testCase.out)
t.Errorf(" got: %#v", out)
}
}
}
var lastUniqueElementsTestCases = []struct {
in []string
out []string
}{
{
in: []string{"a"},
out: []string{"a"},
},
{
in: []string{"a", "b"},
out: []string{"a", "b"},
},
{
in: []string{"a", "a"},
out: []string{"a"},
},
{
in: []string{"a", "b", "a"},
out: []string{"b", "a"},
},
{
in: []string{"b", "a", "a"},
out: []string{"b", "a"},
},
{
in: []string{"a", "a", "b"},
out: []string{"a", "b"},
},
{
in: []string{"a", "b", "a", "b"},
out: []string{"a", "b"},
},
{
in: []string{"liblog", "libdl", "libc++", "libdl", "libc", "libm"},
out: []string{"liblog", "libc++", "libdl", "libc", "libm"},
},
}
func TestLastUniqueElements(t *testing.T) {
for _, testCase := range lastUniqueElementsTestCases {
out := lastUniqueElements(testCase.in)
if !reflect.DeepEqual(out, testCase.out) {
t.Errorf("incorrect output:")
t.Errorf(" input: %#v", testCase.in)
t.Errorf(" expected: %#v", testCase.out)
t.Errorf(" got: %#v", out)
}
}
}
var (
str11 = "01234567891"
str10 = str11[:10]

View file

@ -16,8 +16,6 @@ package cc
import (
"android/soong/android"
"github.com/google/blueprint"
)
type CoverageProperties struct {
@ -61,7 +59,7 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags) Flags {
// For static libraries, the only thing that changes our object files
// are included whole static libraries, so check to see if any of
// those have coverage enabled.
ctx.VisitDirectDeps(func(m blueprint.Module) {
ctx.VisitDirectDeps(func(m android.Module) {
if ctx.OtherModuleDependencyTag(m) != wholeStaticDepTag {
return
}
@ -75,7 +73,7 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags) Flags {
} else {
// For executables and shared libraries, we need to check all of
// our static dependencies.
ctx.VisitDirectDeps(func(m blueprint.Module) {
ctx.VisitDirectDeps(func(m android.Module) {
cc, ok := m.(*Module)
if !ok || cc.coverage == nil {
return

View file

@ -66,7 +66,7 @@ var (
func genYacc(ctx android.ModuleContext, yaccFile android.Path, outFile android.ModuleGenPath, yaccFlags string) (headerFile android.ModuleGenPath) {
headerFile = android.GenPathWithExt(ctx, "yacc", yaccFile, "h")
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: yacc,
Description: "yacc " + yaccFile.Rel(),
Output: outFile,
@ -83,7 +83,7 @@ func genYacc(ctx android.ModuleContext, yaccFile android.Path, outFile android.M
func genAidl(ctx android.ModuleContext, aidlFile android.Path, outFile android.ModuleGenPath, aidlFlags string) android.Paths {
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: aidl,
Description: "aidl " + aidlFile.Rel(),
Output: outFile,
@ -99,7 +99,7 @@ func genAidl(ctx android.ModuleContext, aidlFile android.Path, outFile android.M
}
func genLex(ctx android.ModuleContext, lexFile android.Path, outFile android.ModuleGenPath) {
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: lex,
Description: "lex " + lexFile.Rel(),
Output: outFile,
@ -113,7 +113,7 @@ func genWinMsg(ctx android.ModuleContext, srcFile android.Path, flags builderFla
windmcCmd := gccCmd(flags.toolchain, "windmc")
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: windmc,
Description: "windmc " + srcFile.Rel(),
Output: rcFile,

View file

@ -15,8 +15,6 @@
package cc
import (
"github.com/google/blueprint"
"android/soong/android"
)
@ -104,7 +102,7 @@ func ltoDepsMutator(mctx android.TopDownMutatorContext) {
mctx.PropertyErrorf("LTO", "FullLTO and ThinLTO are mutually exclusive")
}
mctx.VisitDepsDepthFirst(func(m blueprint.Module) {
mctx.VisitDepsDepthFirst(func(m android.Module) {
tag := mctx.OtherModuleDependencyTag(m)
switch tag {
case staticDepTag, staticExportDepTag, lateStaticDepTag, wholeStaticDepTag, objDepTag, reuseObjTag:

View file

@ -237,7 +237,7 @@ func processHeadersWithVersioner(ctx android.ModuleContext, srcDir, outDir andro
}
timestampFile := android.PathForModuleOut(ctx, "versioner.timestamp")
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: preprocessBionicHeaders,
Description: "versioner preprocess " + srcDir.Rel(),
Output: timestampFile,

View file

@ -270,7 +270,7 @@ func compileStubLibrary(ctx ModuleContext, flags Flags, symbolFile, apiLevel, vn
versionScriptPath := android.PathForModuleGen(ctx, "stub.map")
symbolFilePath := android.PathForModuleSrc(ctx, symbolFile)
apiLevelsJson := android.GetApiLevelsJson(ctx)
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: genStubSrc,
Description: "generate stubs " + symbolFilePath.Rel(),
Outputs: []android.WritablePath{stubSrcPath, versionScriptPath},

View file

@ -124,7 +124,7 @@ func (p *prebuiltBinaryLinker) link(ctx ModuleContext,
fileName := p.getStem(ctx) + flags.Toolchain.ExecutableSuffix()
outputFile := android.PathForModuleOut(ctx, fileName)
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: android.CpExecutable,
Description: "prebuilt",
Output: outputFile,

View file

@ -41,7 +41,7 @@ func genProto(ctx android.ModuleContext, protoFile android.Path,
ccFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.cc")
headerFile = android.GenPathWithExt(ctx, "proto", protoFile, "pb.h")
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: proto,
Description: "protoc " + protoFile.Rel(),
Outputs: android.WritablePaths{ccFile, headerFile},

View file

@ -75,7 +75,7 @@ func (p *relocationPacker) needsPacking(ctx ModuleContext) bool {
}
func (p *relocationPacker) pack(ctx ModuleContext, in, out android.ModuleOutPath, flags builderFlags) {
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: relocationPackerRule,
Description: "pack relocations",
Output: out,

View file

@ -64,7 +64,7 @@ func rsGenerateCpp(ctx android.ModuleContext, rsFiles android.Paths, rsFlags str
cppFiles[i] = rsGeneratedCppFile(ctx, rsFile)
}
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: rsCpp,
Description: "llvm-rs-cc",
Output: stampFile,

View file

@ -17,8 +17,6 @@ package cc
import (
"strings"
"github.com/google/blueprint"
"android/soong/android"
"android/soong/cc/config"
)
@ -81,7 +79,7 @@ func sabiDepsMutator(mctx android.TopDownMutatorContext) {
if c, ok := mctx.Module().(*Module); ok &&
((c.isVndk() && c.useVndk()) || inList(c.Name(), llndkLibraries) ||
(c.sabi != nil && c.sabi.Properties.CreateSAbiDumps)) {
mctx.VisitDirectDeps(func(m blueprint.Module) {
mctx.VisitDirectDeps(func(m android.Module) {
tag := mctx.OtherModuleDependencyTag(m)
switch tag {
case staticDepTag, staticExportDepTag, lateStaticDepTag, wholeStaticDepTag:

View file

@ -19,8 +19,6 @@ import (
"io"
"strings"
"github.com/google/blueprint"
"android/soong/android"
"android/soong/cc/config"
)
@ -493,7 +491,7 @@ func (sanitize *sanitize) SetSanitizer(t sanitizerType, b bool) {
func sanitizerDepsMutator(t sanitizerType) func(android.TopDownMutatorContext) {
return func(mctx android.TopDownMutatorContext) {
if c, ok := mctx.Module().(*Module); ok && c.sanitize.Sanitizer(t) {
mctx.VisitDepsDepthFirst(func(module blueprint.Module) {
mctx.VisitDepsDepthFirst(func(module android.Module) {
if d, ok := mctx.Module().(*Module); ok && c.sanitize != nil &&
!c.sanitize.Properties.Sanitize.Never {
d.sanitize.Properties.SanitizeDep = true

View file

@ -157,7 +157,7 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
tools := map[string]android.Path{}
if len(g.properties.Tools) > 0 {
ctx.VisitDirectDeps(func(module blueprint.Module) {
ctx.VisitDirectDeps(func(module android.Module) {
switch ctx.OtherModuleDependencyTag(module) {
case android.SourceDepTag:
// Nothing to do
@ -289,7 +289,7 @@ func (g *Module) generateSourceFile(ctx android.ModuleContext, task generateTask
desc += " " + task.out[0].Base()
}
params := android.ModuleBuildParams{
params := android.BuildParams{
Rule: g.rule,
Description: "generate",
Output: task.out[0],
@ -304,7 +304,7 @@ func (g *Module) generateSourceFile(ctx android.ModuleContext, task generateTask
depfile := android.GenPathWithExt(ctx, "", task.out[0], task.out[0].Ext()+".d")
params.Depfile = depfile
}
ctx.ModuleBuild(pctx, params)
ctx.Build(pctx, params)
for _, outputFile := range task.out {
g.outputFiles = append(g.outputFiles, outputFile)

View file

@ -20,7 +20,6 @@ import (
"path/filepath"
"strings"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/android"
@ -231,7 +230,7 @@ func (a *AndroidApp) aaptFlags(ctx android.ModuleContext) ([]string, android.Pat
aaptFlags = append(aaptFlags, android.JoinWithPrefix(assetDirs.Strings(), "-A "))
aaptFlags = append(aaptFlags, android.JoinWithPrefix(resourceDirs.Strings(), "-S "))
ctx.VisitDirectDeps(func(module blueprint.Module) {
ctx.VisitDirectDeps(func(module android.Module) {
var depFiles android.Paths
if javaDep, ok := module.(Dependency); ok {
if ctx.OtherModuleName(module) == "framework-res" {

View file

@ -82,7 +82,7 @@ func CreateResourceJavaFiles(ctx android.ModuleContext, flags []string,
publicResourcesFile := android.PathForModuleOut(ctx, "public_resources.xml")
proguardOptionsFile := android.PathForModuleOut(ctx, "proguard.options")
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: aaptCreateResourceJavaFile,
Description: "aapt create R.java",
Outputs: android.WritablePaths{publicResourcesFile, proguardOptionsFile, javaFileList},
@ -102,7 +102,7 @@ func CreateResourceJavaFiles(ctx android.ModuleContext, flags []string,
func CreateExportPackage(ctx android.ModuleContext, flags []string, deps android.Paths) android.ModuleOutPath {
outputFile := android.PathForModuleOut(ctx, "package-export.apk")
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: aaptCreateAssetsPackage,
Description: "aapt export package",
Output: outputFile,
@ -120,7 +120,7 @@ func CreateAppPackage(ctx android.ModuleContext, flags []string, jarFile android
resourceApk := android.PathForModuleOut(ctx, "resources.apk")
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: aaptAddResources,
Description: "aapt package",
Output: resourceApk,
@ -137,7 +137,7 @@ func CreateAppPackage(ctx android.ModuleContext, flags []string, jarFile android
certificateArgs = append(certificateArgs, c+".x509.pem", c+".pk8")
}
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: signapk,
Description: "signapk",
Output: outputFile,

View file

@ -181,7 +181,7 @@ func TransformKotlinToClasses(ctx android.ModuleContext, outputFile android.Writ
inputs := append(android.Paths(nil), srcFiles...)
inputs = append(inputs, srcJars...)
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: kotlinc,
Description: "kotlinc",
Output: outputFile,
@ -236,7 +236,7 @@ func TransformJavaToHeaderClasses(ctx android.ModuleContext, outputFile android.
} else {
sourcepath = ""
}
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: turbine,
Description: "turbine",
Output: outputFile,
@ -286,7 +286,7 @@ func transformJavaToClasses(ctx android.ModuleContext, outputFile android.Writab
deps = append(deps, flags.classpath...)
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: rule,
Description: desc,
Output: outputFile,
@ -309,7 +309,7 @@ func transformJavaToClasses(ctx android.ModuleContext, outputFile android.Writab
func TransformResourcesToJar(ctx android.ModuleContext, outputFile android.WritablePath,
jarArgs []string, deps android.Paths) {
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: jar,
Description: "jar",
Output: outputFile,
@ -341,7 +341,7 @@ func TransformJarsToJar(ctx android.ModuleContext, outputFile android.WritablePa
jarArgs = append(jarArgs, "-D")
}
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: combineJar,
Description: desc,
Output: outputFile,
@ -371,7 +371,7 @@ func TransformDesugar(ctx android.ModuleContext, outputFile android.WritablePath
deps = append(deps, flags.bootClasspath...)
deps = append(deps, flags.classpath...)
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: desugar,
Description: "desugar",
Output: outputFile,
@ -393,7 +393,7 @@ func TransformClassesJarToDexJar(ctx android.ModuleContext, outputFile android.W
outDir := android.PathForModuleOut(ctx, "dex")
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: dx,
Description: "dx",
Output: outputFile,
@ -407,7 +407,7 @@ func TransformClassesJarToDexJar(ctx android.ModuleContext, outputFile android.W
func TransformJarJar(ctx android.ModuleContext, outputFile android.WritablePath,
classesJar android.Path, rulesFile android.Path) {
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: jarjar,
Description: "jarjar",
Output: outputFile,

View file

@ -57,7 +57,7 @@ func genAidl(ctx android.ModuleContext, aidlFile android.Path, aidlFlags string)
javaFile := android.GenPathWithExt(ctx, "aidl", aidlFile, "java")
depFile := javaFile.String() + ".d"
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: aidl,
Description: "aidl " + aidlFile.Rel(),
Output: javaFile,
@ -74,7 +74,7 @@ func genAidl(ctx android.ModuleContext, aidlFile android.Path, aidlFlags string)
func genLogtags(ctx android.ModuleContext, logtagsFile android.Path) android.Path {
javaFile := android.GenPathWithExt(ctx, "logtags", logtagsFile, "java")
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: logtags,
Description: "logtags " + logtagsFile.Rel(),
Output: javaFile,

View file

@ -406,25 +406,10 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, sdkDep.aidl)
}
ctx.VisitDirectDeps(func(module blueprint.Module) {
ctx.VisitDirectDeps(func(module android.Module) {
otherName := ctx.OtherModuleName(module)
tag := ctx.OtherModuleDependencyTag(module)
aDep, _ := module.(android.Module)
if aDep == nil {
ctx.ModuleErrorf("module %q not an android module", ctx.OtherModuleName(aDep))
return
}
if !aDep.Enabled() {
if ctx.AConfig().AllowMissingDependencies() {
ctx.AddMissingDependencies([]string{ctx.OtherModuleName(aDep)})
} else {
ctx.ModuleErrorf("depends on disabled module %q", ctx.OtherModuleName(aDep))
}
return
}
dep, _ := module.(Dependency)
if dep == nil {
switch tag {

View file

@ -41,7 +41,7 @@ var (
func genProto(ctx android.ModuleContext, outputSrcJar android.WritablePath,
protoFiles android.Paths, protoFlags string, protoOut, protoOutFlags string) {
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: proto,
Description: "protoc " + protoFiles[0].Rel(),
Output: outputSrcJar,

View file

@ -67,7 +67,7 @@ func TransformJarsToSystemModules(ctx android.ModuleContext, moduleName string,
android.PathForModuleOut(ctx, "system/release"),
}
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: jarsTosystemModules,
Description: "system modules",
Outputs: outputs,
@ -112,7 +112,7 @@ type SystemModulesProperties struct {
func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleContext) {
var jars android.Paths
ctx.VisitDirectDeps(func(module blueprint.Module) {
ctx.VisitDirectDeps(func(module android.Module) {
if ctx.OtherModuleDependencyTag(module) == libTag {
dep, _ := module.(Dependency)
jars = append(jars, dep.HeaderJars()...)

View file

@ -21,8 +21,6 @@ import (
"path/filepath"
"strings"
"github.com/google/blueprint"
"android/soong/android"
)
@ -135,7 +133,7 @@ func (binary *binaryDecorator) bootstrap(ctx android.ModuleContext, actual_versi
var launcher_path android.Path
if embedded_launcher {
ctx.VisitDirectDeps(func(m blueprint.Module) {
ctx.VisitDirectDeps(func(m android.Module) {
if ctx.OtherModuleDependencyTag(m) != launcherTag {
return
}

View file

@ -87,7 +87,7 @@ func registerBuildActionForModuleFileList(ctx android.ModuleContext,
content = append(content, file.String())
}
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: android.WriteFile,
Description: "generate " + fileList.Rel(),
Output: fileList,
@ -140,7 +140,7 @@ func registerBuildActionForParFile(ctx android.ModuleContext, embedded_launcher
// added stub file to the soong_zip args.
parArgs = append(parArgs, `-P "" `+`-C `+strings.TrimSuffix(stub, mainFileName)+` -f `+stub)
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: host_par,
Description: "host python archive",
Output: binFile,
@ -169,7 +169,7 @@ func registerBuildActionForParFile(ctx android.ModuleContext, embedded_launcher
parArgs = append(parArgs, `-P "" `+`-C `+fmt.Sprintf(
"%q", strings.TrimSuffix(entryPoint, entryPointFile))+` -f `+entryPoint)
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
ctx.Build(pctx, android.BuildParams{
Rule: embedded_par,
Description: "embedded python archive",
Output: binFile,

View file

@ -508,7 +508,7 @@ func (p *Module) uniqWholeRunfilesTree(ctx android.ModuleContext) {
}
// visit all its dependencies in depth first.
ctx.VisitDepsDepthFirst(func(module blueprint.Module) {
ctx.VisitDepsDepthFirst(func(module android.Module) {
if ctx.OtherModuleDependencyTag(module) != pythonLibTag {
return
}