summaryrefslogtreecommitdiff
path: root/genrule
diff options
context:
space:
mode:
author Yu Liu <yudiliu@google.com> 2024-10-10 18:23:52 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-10-10 18:23:52 +0000
commit0636fa36fbc7cbe49c75f0864456a5db155ef956 (patch)
tree3bf5364d702d0d681f64f9e0629a93eab7fcebee /genrule
parent527f3ad099cbe1cf9a25fa1bb901b16f0d2d2d9b (diff)
parentd2a95955426417533b529917d8c1e078d4dbbce9 (diff)
Merge "Add a few module visiting methods that return ModuleProxy." into main
Diffstat (limited to 'genrule')
-rw-r--r--genrule/genrule.go27
1 files changed, 15 insertions, 12 deletions
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 18ec0a40c..8721f15c2 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -112,6 +112,12 @@ func (t hostToolDependencyTag) AllowDisabledModuleDependency(target android.Modu
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 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) {
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 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) {
}
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 @@ func (g *Module) generateCommonBuildActions(ctx android.ModuleContext) {
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
}