Merge "Remove dependencies on 1-variant fallback" into main
diff --git a/android/base_module_context.go b/android/base_module_context.go
index 670537f..e24ce9d 100644
--- a/android/base_module_context.go
+++ b/android/base_module_context.go
@@ -136,12 +136,14 @@
// multiple direct dependencies on the same module visit will be called multiple times on
// that module and OtherModuleDependencyTag will return a different tag for each.
//
- // The Module passed to the visit function should not be retained outside of the visit function, it may be
+ // The ModuleProxy passed to the visit function should not be retained outside of the visit function, it may be
// invalidated by future mutators.
- VisitDirectDepsProxyAllowDisabled(visit func(proxy Module))
+ VisitDirectDepsProxyAllowDisabled(visit func(proxy ModuleProxy))
VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module))
+ VisitDirectDepsProxyWithTag(tag blueprint.DependencyTag, visit func(proxy ModuleProxy))
+
// VisitDirectDepsIf calls pred for each direct dependency, and if pred returns true calls visit. If there are
// multiple direct dependencies on the same module pred and visit will be called multiple times on that module and
// OtherModuleDependencyTag will return a different tag for each. It skips any
@@ -173,7 +175,7 @@
//
// The Modules passed to the visit function should not be retained outside of the visit function, they may be
// invalidated by future mutators.
- WalkDepsProxy(visit func(child, parent Module) bool)
+ WalkDepsProxy(visit func(child, parent ModuleProxy) 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.
@@ -314,6 +316,7 @@
type AllowDisabledModuleDependency interface {
blueprint.DependencyTag
AllowDisabledModuleDependency(target Module) bool
+ AllowDisabledModuleDependencyProxy(ctx OtherModuleProviderContext, target ModuleProxy) bool
}
type AlwaysAllowDisabledModuleDependencyTag struct{}
@@ -322,6 +325,10 @@
return true
}
+func (t AlwaysAllowDisabledModuleDependencyTag) AllowDisabledModuleDependencyProxy(OtherModuleProviderContext, ModuleProxy) bool {
+ return true
+}
+
func (b *baseModuleContext) validateAndroidModule(module blueprint.Module, tag blueprint.DependencyTag, strict bool) Module {
aModule, _ := module.(Module)
@@ -346,6 +353,28 @@
return aModule
}
+func (b *baseModuleContext) validateAndroidModuleProxy(
+ module blueprint.ModuleProxy, tag blueprint.DependencyTag, strict bool) *ModuleProxy {
+ aModule := ModuleProxy{module: module}
+
+ if !strict {
+ return &aModule
+ }
+
+ if !OtherModuleProviderOrDefault(b, module, CommonPropertiesProviderKey).Enabled {
+ if t, ok := tag.(AllowDisabledModuleDependency); !ok || !t.AllowDisabledModuleDependencyProxy(b, aModule) {
+ if b.Config().AllowMissingDependencies() {
+ b.AddMissingDependencies([]string{b.OtherModuleName(aModule)})
+ } else {
+ b.ModuleErrorf("depends on disabled module %q", b.OtherModuleName(aModule))
+ }
+ }
+ return nil
+ }
+
+ return &aModule
+}
+
type dep struct {
mod blueprint.Module
tag blueprint.DependencyTag
@@ -426,7 +455,7 @@
})
}
-func (b *baseModuleContext) VisitDirectDepsProxyAllowDisabled(visit func(proxy Module)) {
+func (b *baseModuleContext) VisitDirectDepsProxyAllowDisabled(visit func(proxy ModuleProxy)) {
b.bp.VisitDirectDepsProxy(func(module blueprint.ModuleProxy) {
visit(ModuleProxy{
module: module,
@@ -437,13 +466,23 @@
func (b *baseModuleContext) VisitDirectDepsWithTag(tag blueprint.DependencyTag, visit func(Module)) {
b.bp.VisitDirectDeps(func(module blueprint.Module) {
if b.bp.OtherModuleDependencyTag(module) == tag {
- if aModule := b.validateAndroidModule(module, b.bp.OtherModuleDependencyTag(module), b.strictVisitDeps); aModule != nil {
+ if aModule := b.validateAndroidModule(module, tag, b.strictVisitDeps); aModule != nil {
visit(aModule)
}
}
})
}
+func (b *baseModuleContext) VisitDirectDepsProxyWithTag(tag blueprint.DependencyTag, visit func(proxy ModuleProxy)) {
+ b.bp.VisitDirectDepsProxy(func(module blueprint.ModuleProxy) {
+ if b.bp.OtherModuleDependencyTag(module) == tag {
+ if aModule := b.validateAndroidModuleProxy(module, tag, b.strictVisitDeps); aModule != nil {
+ visit(*aModule)
+ }
+ }
+ })
+}
+
func (b *baseModuleContext) VisitDirectDepsIf(pred func(Module) bool, visit func(Module)) {
b.bp.VisitDirectDepsIf(
// pred
@@ -505,7 +544,7 @@
})
}
-func (b *baseModuleContext) WalkDepsProxy(visit func(Module, Module) bool) {
+func (b *baseModuleContext) WalkDepsProxy(visit func(ModuleProxy, ModuleProxy) bool) {
b.walkPath = []Module{ModuleProxy{blueprint.CreateModuleProxy(b.Module())}}
b.tagPath = []blueprint.DependencyTag{}
b.bp.WalkDepsProxy(func(child, parent blueprint.ModuleProxy) bool {
diff --git a/android/prebuilt.go b/android/prebuilt.go
index 017ba76..0b0c517 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -362,10 +362,10 @@
// the right module. This function is only safe to call after all TransitionMutators
// have run, e.g. in GenerateAndroidBuildActions.
func PrebuiltGetPreferred(ctx BaseModuleContext, module Module) Module {
- if !module.IsReplacedByPrebuilt() {
+ if !OtherModuleProviderOrDefault(ctx, module, CommonPropertiesProviderKey).ReplacedByPrebuilt {
return module
}
- if IsModulePrebuilt(module) {
+ if _, ok := OtherModuleProvider(ctx, module, PrebuiltModuleProviderKey); ok {
// If we're given a prebuilt then assume there's no source module around.
return module
}
@@ -373,11 +373,11 @@
sourceModDepFound := false
var prebuiltMod Module
- ctx.WalkDeps(func(child, parent Module) bool {
+ ctx.WalkDepsProxy(func(child, parent ModuleProxy) bool {
if prebuiltMod != nil {
return false
}
- if parent == ctx.Module() {
+ if ctx.EqualModules(parent, ctx.Module()) {
// First level: Only recurse if the module is found as a direct dependency.
sourceModDepFound = child == module
return sourceModDepFound
diff --git a/android/proto.go b/android/proto.go
index 0d8e097..66faa20 100644
--- a/android/proto.go
+++ b/android/proto.go
@@ -74,14 +74,14 @@
flags = append(flags, JoinWithPrefix(rootProtoIncludeDirs.Strings(), "-I"))
}
- ctx.VisitDirectDepsWithTag(ProtoPluginDepTag, func(dep Module) {
- if hostTool, ok := dep.(HostToolProvider); !ok || !hostTool.HostToolPath().Valid() {
+ ctx.VisitDirectDepsProxyWithTag(ProtoPluginDepTag, func(dep ModuleProxy) {
+ if h, ok := OtherModuleProvider(ctx, dep, HostToolProviderKey); !ok || !h.HostToolPath.Valid() {
ctx.PropertyErrorf("proto.plugin", "module %q is not a host tool provider",
ctx.OtherModuleName(dep))
} else {
plugin := String(p.Proto.Plugin)
- deps = append(deps, hostTool.HostToolPath().Path())
- flags = append(flags, "--plugin=protoc-gen-"+plugin+"="+hostTool.HostToolPath().String())
+ deps = append(deps, h.HostToolPath.Path())
+ flags = append(flags, "--plugin=protoc-gen-"+plugin+"="+h.HostToolPath.String())
}
})
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 85fdb02..498ef7c 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -1830,10 +1830,7 @@
type sanitizerLibraryDependencyTag struct {
blueprint.BaseDependencyTag
-}
-
-func (t sanitizerLibraryDependencyTag) AllowDisabledModuleDependency(target android.Module) bool {
- return true
+ android.AlwaysAllowDisabledModuleDependencyTag
}
var _ android.AllowDisabledModuleDependency = (*sanitizerLibraryDependencyTag)(nil)
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 84d4f10..3dd6f9a 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -462,6 +462,12 @@
return target.IsReplacedByPrebuilt()
}
+func (d dex2oatDependencyTag) AllowDisabledModuleDependencyProxy(
+ ctx android.OtherModuleProviderContext, target android.ModuleProxy) bool {
+ return android.OtherModuleProviderOrDefault(
+ ctx, target, android.CommonPropertiesProviderKey).ReplacedByPrebuilt
+}
+
// Dex2oatDepTag represents the dependency onto the dex2oatd module. It is added to any module that
// needs dexpreopting and so it makes no sense for it to be checked for visibility or included in
// the apex.
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index fc6d1f7..fbe24d1 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -78,9 +78,16 @@
Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
// Source files of this prebuilt. Can reference a genrule type module with the ":module" syntax.
- // Mutually exclusive with src. When used, filename_from_src is set to true.
+ // Mutually exclusive with src. When used, filename_from_src is set to true unless dsts is also
+ // set. May use globs in filenames.
Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
+ // Destination files of this prebuilt. Requires srcs to be used and causes srcs not to implicitly
+ // set filename_from_src. This can be used to install each source file to a different directory
+ // and/or change filenames when files are installed. Must be exactly one entry per source file,
+ // which means care must be taken if srcs has globs.
+ Dsts proptools.Configurable[[]string] `android:"path,arch_variant"`
+
// Optional name for the installed file. If unspecified, name of the module is used as the file
// name. Only available when using a single source (src).
Filename *string `android:"arch_variant"`
@@ -166,7 +173,7 @@
// The base install location when soc_specific property is set to true, e.g. "firmware" for
// prebuilt_firmware.
socInstallDirBase string
- installDirPath android.InstallPath
+ installDirPaths []android.InstallPath
additionalDependencies *android.Paths
usedSrcsProperty bool
@@ -279,7 +286,10 @@
}
func (p *PrebuiltEtc) InstallDirPath() android.InstallPath {
- return p.installDirPath
+ if len(p.installDirPaths) != 1 {
+ panic(fmt.Errorf("InstallDirPath not available on multi-source prebuilt %q", p.Name()))
+ }
+ return p.installDirPaths[0]
}
// This allows other derivative modules (e.g. prebuilt_etc_xml) to perform
@@ -338,12 +348,16 @@
if srcProperty.IsPresent() && len(srcsProperty) > 0 {
ctx.PropertyErrorf("src", "src is set. Cannot set srcs")
}
+ dstsProperty := p.properties.Dsts.GetOrDefault(ctx, nil)
+ if len(dstsProperty) > 0 && len(srcsProperty) == 0 {
+ ctx.PropertyErrorf("dsts", "dsts is set. Must use srcs")
+ }
// Check that `sub_dir` and `relative_install_path` are not set at the same time.
if p.subdirProperties.Sub_dir != nil && p.subdirProperties.Relative_install_path != nil {
ctx.PropertyErrorf("sub_dir", "relative_install_path is set. Cannot set sub_dir")
}
- p.installDirPath = android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
+ baseInstallDirPath := android.PathForModuleInstall(ctx, p.installBaseDir(ctx), p.SubDir())
filename := proptools.String(p.properties.Filename)
filenameFromSrc := proptools.Bool(p.properties.Filename_from_src)
@@ -379,10 +393,11 @@
filename: filename,
sourceFilePath: p.sourceFilePaths[0],
outputFilePath: p.outputFilePaths[0],
- installDirPath: p.installDirPath,
+ installDirPath: baseInstallDirPath,
symlinks: p.properties.Symlinks,
}
installs = append(installs, ip)
+ p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
} else if len(srcsProperty) > 0 {
p.usedSrcsProperty = true
if filename != "" {
@@ -392,20 +407,39 @@
ctx.PropertyErrorf("symlinks", "symlinks cannot be set when using srcs")
}
if p.properties.Filename_from_src != nil {
- ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
+ if len(dstsProperty) > 0 {
+ ctx.PropertyErrorf("filename_from_src", "dsts is set. Cannot set filename_from_src")
+ } else {
+ ctx.PropertyErrorf("filename_from_src", "filename_from_src is implicitly set to true when using srcs")
+ }
}
p.sourceFilePaths = android.PathsForModuleSrc(ctx, srcsProperty)
- for _, src := range p.sourceFilePaths {
- filename := src.Base()
+ if len(dstsProperty) > 0 && len(p.sourceFilePaths) != len(dstsProperty) {
+ ctx.PropertyErrorf("dsts", "Must have one entry in dsts per source file")
+ }
+ for i, src := range p.sourceFilePaths {
+ var filename string
+ var installDirPath android.InstallPath
+
+ if len(dstsProperty) > 0 {
+ var dstdir string
+
+ dstdir, filename = filepath.Split(dstsProperty[i])
+ installDirPath = baseInstallDirPath.Join(ctx, dstdir)
+ } else {
+ filename = src.Base()
+ installDirPath = baseInstallDirPath
+ }
output := android.PathForModuleOut(ctx, filename).OutputPath
ip := installProperties{
filename: filename,
sourceFilePath: src,
outputFilePath: output,
- installDirPath: p.installDirPath,
+ installDirPath: installDirPath,
}
p.outputFilePaths = append(p.outputFilePaths, output)
installs = append(installs, ip)
+ p.installDirPaths = append(p.installDirPaths, installDirPath)
}
} else if ctx.Config().AllowMissingDependencies() {
// If no srcs was set and AllowMissingDependencies is enabled then
@@ -421,9 +455,10 @@
filename: filename,
sourceFilePath: p.sourceFilePaths[0],
outputFilePath: p.outputFilePaths[0],
- installDirPath: p.installDirPath,
+ installDirPath: baseInstallDirPath,
}
installs = append(installs, ip)
+ p.installDirPaths = append(p.installDirPaths, baseInstallDirPath)
} else {
ctx.PropertyErrorf("src", "missing prebuilt source file")
return
@@ -493,7 +528,7 @@
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
entries.SetString("LOCAL_MODULE_TAGS", "optional")
- entries.SetString("LOCAL_MODULE_PATH", p.installDirPath.String())
+ entries.SetString("LOCAL_MODULE_PATH", p.installDirPaths[0].String())
entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePaths[0].Base())
if len(p.properties.Symlinks) > 0 {
entries.AddStrings("LOCAL_MODULE_SYMLINKS", p.properties.Symlinks...)
diff --git a/etc/prebuilt_etc_test.go b/etc/prebuilt_etc_test.go
index e739afe..75c6d12 100644
--- a/etc/prebuilt_etc_test.go
+++ b/etc/prebuilt_etc_test.go
@@ -119,6 +119,113 @@
android.AssertStringEquals(t, "output file path", "foo.conf", p.outputFilePaths[2].Base())
}
+func TestPrebuiltEtcDsts(t *testing.T) {
+ result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
+ prebuilt_etc {
+ name: "foo",
+ srcs: ["foo.conf", "bar.conf"],
+ dsts: ["foodir/foo.conf", "bardir/extradir/different.name"],
+ }
+ `)
+
+ p := result.Module("foo", "android_arm64_armv8-a").(*PrebuiltEtc)
+ android.AssertStringEquals(t, "output file path", "foo.conf", p.outputFilePaths[0].Base())
+ android.AssertStringEquals(t, "output file path", "different.name", p.outputFilePaths[1].Base())
+
+ expectedPaths := [...]string{
+ "out/soong/target/product/test_device/system/etc/foodir",
+ "out/soong/target/product/test_device/system/etc/bardir/extradir",
+ }
+ android.AssertPathRelativeToTopEquals(t, "install dir", expectedPaths[0], p.installDirPaths[0])
+ android.AssertPathRelativeToTopEquals(t, "install dir", expectedPaths[1], p.installDirPaths[1])
+}
+
+func TestPrebuiltEtcDstsPlusRelativeInstallPath(t *testing.T) {
+ result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
+ prebuilt_etc {
+ name: "foo",
+ srcs: ["foo.conf", "bar.conf"],
+ dsts: ["foodir/foo.conf", "bardir/extradir/different.name"],
+ relative_install_path: "somewhere",
+ }
+ `)
+
+ p := result.Module("foo", "android_arm64_armv8-a").(*PrebuiltEtc)
+ android.AssertStringEquals(t, "output file path", "foo.conf", p.outputFilePaths[0].Base())
+ android.AssertStringEquals(t, "output file path", "different.name", p.outputFilePaths[1].Base())
+
+ expectedPaths := [...]string{
+ "out/soong/target/product/test_device/system/etc/somewhere/foodir",
+ "out/soong/target/product/test_device/system/etc/somewhere/bardir/extradir",
+ }
+ android.AssertPathRelativeToTopEquals(t, "install dir", expectedPaths[0], p.installDirPaths[0])
+ android.AssertPathRelativeToTopEquals(t, "install dir", expectedPaths[1], p.installDirPaths[1])
+}
+
+func TestPrebuiltEtcDstsSrcGlob(t *testing.T) {
+ result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
+ prebuilt_etc {
+ name: "foo",
+ srcs: ["*.conf"],
+ dsts: ["a.conf", "b.conf", "c.conf"],
+ }
+ `)
+
+ p := result.Module("foo", "android_arm64_armv8-a").(*PrebuiltEtc)
+ android.AssertStringEquals(t, "output file path", "a.conf", p.outputFilePaths[0].Base())
+ android.AssertStringEquals(t, "output file path", "b.conf", p.outputFilePaths[1].Base())
+ android.AssertStringEquals(t, "output file path", "c.conf", p.outputFilePaths[2].Base())
+}
+
+func TestPrebuiltEtcDstsSrcGlobDstsTooShort(t *testing.T) {
+ prepareForPrebuiltEtcTest.
+ ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("Must have one entry in dsts per source file")).
+ RunTestWithBp(t, `
+ prebuilt_etc {
+ name: "foo",
+ srcs: ["*.conf"],
+ dsts: ["a.conf", "b.conf"],
+ }
+ `)
+}
+
+func TestPrebuiltEtcDstsSrcGlobDstsTooLong(t *testing.T) {
+ prepareForPrebuiltEtcTest.
+ ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("Must have one entry in dsts per source file")).
+ RunTestWithBp(t, `
+ prebuilt_etc {
+ name: "foo",
+ srcs: ["*.conf"],
+ dsts: ["a.conf", "b.conf", "c.conf", "d.conf"],
+ }
+ `)
+}
+
+func TestPrebuiltEtcCannotDstsWithSrc(t *testing.T) {
+ prepareForPrebuiltEtcTest.
+ ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("dsts is set. Must use srcs")).
+ RunTestWithBp(t, `
+ prebuilt_etc {
+ name: "foo.conf",
+ src: "foo.conf",
+ dsts: ["a.conf"],
+ }
+ `)
+}
+
+func TestPrebuiltEtcCannotDstsWithFilenameFromSrc(t *testing.T) {
+ prepareForPrebuiltEtcTest.
+ ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern("dsts is set. Cannot set filename_from_src")).
+ RunTestWithBp(t, `
+ prebuilt_etc {
+ name: "foo.conf",
+ srcs: ["foo.conf"],
+ dsts: ["a.conf"],
+ filename_from_src: true,
+ }
+ `)
+}
+
func TestPrebuiltEtcAndroidMk(t *testing.T) {
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, `
prebuilt_etc {
@@ -165,7 +272,7 @@
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
expected := "out/soong/target/product/test_device/system/etc/bar"
- android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
+ android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPaths[0])
}
func TestPrebuiltEtcCannotSetRelativeInstallPathAndSubDir(t *testing.T) {
@@ -231,7 +338,7 @@
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
expected := "out/soong/target/product/test_device/system"
- android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
+ android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPaths[0])
}
func TestPrebuiltRootInstallDirPathValidate(t *testing.T) {
@@ -256,7 +363,7 @@
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
expected := "out/soong/target/product/test_device/root/avb"
- android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
+ android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPaths[0])
}
func TestPrebuiltAvdInstallDirPathValidate(t *testing.T) {
@@ -280,7 +387,7 @@
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
expected := "out/soong/target/product/test_device/system/usr/share/bar"
- android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
+ android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPaths[0])
}
func TestPrebuiltUserShareHostInstallDirPath(t *testing.T) {
@@ -295,7 +402,7 @@
buildOS := result.Config.BuildOS.String()
p := result.Module("foo.conf", buildOS+"_common").(*PrebuiltEtc)
expected := filepath.Join("out/soong/host", result.Config.PrebuiltOS(), "usr", "share", "bar")
- android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
+ android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPaths[0])
}
func TestPrebuiltPrebuiltUserHyphenDataInstallDirPath(t *testing.T) {
@@ -309,7 +416,7 @@
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
expected := "out/soong/target/product/test_device/system/usr/hyphen-data/bar"
- android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
+ android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPaths[0])
}
func TestPrebuiltPrebuiltUserKeyLayoutInstallDirPath(t *testing.T) {
@@ -323,7 +430,7 @@
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
expected := "out/soong/target/product/test_device/system/usr/keylayout/bar"
- android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
+ android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPaths[0])
}
func TestPrebuiltPrebuiltUserKeyCharsInstallDirPath(t *testing.T) {
@@ -337,7 +444,7 @@
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
expected := "out/soong/target/product/test_device/system/usr/keychars/bar"
- android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
+ android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPaths[0])
}
func TestPrebuiltPrebuiltUserIdcInstallDirPath(t *testing.T) {
@@ -351,7 +458,7 @@
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
expected := "out/soong/target/product/test_device/system/usr/idc/bar"
- android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
+ android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPaths[0])
}
func TestPrebuiltFontInstallDirPath(t *testing.T) {
@@ -364,7 +471,7 @@
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
expected := "out/soong/target/product/test_device/system/fonts"
- android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
+ android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPaths[0])
}
func TestPrebuiltOverlayInstallDirPath(t *testing.T) {
@@ -377,7 +484,7 @@
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
expected := "out/soong/target/product/test_device/system/overlay"
- android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPath)
+ android.AssertPathRelativeToTopEquals(t, "install dir", expected, p.installDirPaths[0])
}
func TestPrebuiltFirmwareDirPath(t *testing.T) {
@@ -409,7 +516,7 @@
t.Run(tt.description, func(t *testing.T) {
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, tt.config)
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
- android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath)
+ android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPaths[0])
})
}
}
@@ -443,7 +550,7 @@
t.Run(tt.description, func(t *testing.T) {
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, tt.config)
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
- android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath)
+ android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPaths[0])
})
}
}
@@ -477,7 +584,7 @@
t.Run(tt.description, func(t *testing.T) {
result := prepareForPrebuiltEtcTest.RunTestWithBp(t, tt.config)
p := result.Module("foo.conf", "android_arm64_armv8-a").(*PrebuiltEtc)
- android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPath)
+ android.AssertPathRelativeToTopEquals(t, "install dir", tt.expectedPath, p.installDirPaths[0])
})
}
}
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 18ec0a4..8721f15 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -112,6 +112,12 @@
return target.IsReplacedByPrebuilt()
}
+func (t hostToolDependencyTag) AllowDisabledModuleDependencyProxy(
+ ctx android.OtherModuleProviderContext, target android.ModuleProxy) bool {
+ return android.OtherModuleProviderOrDefault(
+ ctx, target, android.CommonPropertiesProviderKey).ReplacedByPrebuilt
+}
+
var _ android.AllowDisabledModuleDependency = (*hostToolDependencyTag)(nil)
type generatorProperties struct {
@@ -315,21 +321,18 @@
var packagedTools []android.PackagingSpec
if len(g.properties.Tools) > 0 {
seenTools := make(map[string]bool)
-
- ctx.VisitDirectDepsAllowDisabled(func(module android.Module) {
- switch tag := ctx.OtherModuleDependencyTag(module).(type) {
+ ctx.VisitDirectDepsProxyAllowDisabled(func(proxy android.ModuleProxy) {
+ switch tag := ctx.OtherModuleDependencyTag(proxy).(type) {
case hostToolDependencyTag:
- tool := ctx.OtherModuleName(module)
// Necessary to retrieve any prebuilt replacement for the tool, since
// toolDepsMutator runs too late for the prebuilt mutators to have
// replaced the dependency.
- module = android.PrebuiltGetPreferred(ctx, module)
-
- switch t := module.(type) {
- case android.HostToolProvider:
+ module := android.PrebuiltGetPreferred(ctx, proxy)
+ tool := ctx.OtherModuleName(module)
+ if h, ok := android.OtherModuleProvider(ctx, module, android.HostToolProviderKey); ok {
// A HostToolProvider provides the path to a tool, which will be copied
// into the sandbox.
- if !t.(android.Module).Enabled(ctx) {
+ if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonPropertiesProviderKey).Enabled {
if ctx.Config().AllowMissingDependencies() {
ctx.AddMissingDependencies([]string{tool})
} else {
@@ -337,13 +340,13 @@
}
return
}
- path := t.HostToolPath()
+ path := h.HostToolPath
if !path.Valid() {
ctx.ModuleErrorf("host tool %q missing output file", tool)
return
}
if specs := android.OtherModuleProviderOrDefault(
- ctx, t, android.InstallFilesProvider).TransitivePackagingSpecs.ToList(); specs != nil {
+ ctx, module, android.InstallFilesProvider).TransitivePackagingSpecs.ToList(); specs != nil {
// If the HostToolProvider has PackgingSpecs, which are definitions of the
// required relative locations of the tool and its dependencies, use those
// instead. They will be copied to those relative locations in the sbox
@@ -365,7 +368,7 @@
tools = append(tools, path.Path())
addLocationLabel(tag.label, toolLocation{android.Paths{path.Path()}})
}
- default:
+ } else {
ctx.ModuleErrorf("%q is not a host tool provider", tool)
return
}