Merge "Make all SdkMemberTypes support transitive member deps"
diff --git a/android/paths.go b/android/paths.go
index b934687..5d458cb 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -24,6 +24,7 @@
"strings"
"github.com/google/blueprint"
+ "github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/pathtools"
)
@@ -449,6 +450,12 @@
return outputFiles, nil
} else if tag != "" {
return nil, fmt.Errorf("path dependency %q is not an output file producing module", path)
+ } else if goBinary, ok := module.(bootstrap.GoBinaryTool); ok {
+ if rel, err := filepath.Rel(PathForOutput(ctx).String(), goBinary.InstallPath()); err == nil {
+ return Paths{PathForOutput(ctx, rel).WithoutRel()}, nil
+ } else {
+ return nil, fmt.Errorf("cannot find output path for %q: %w", goBinary.InstallPath(), err)
+ }
} else if srcProducer, ok := module.(SourceFileProducer); ok {
return srcProducer.Srcs(), nil
} else {
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 7830f95..8996352 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -110,6 +110,13 @@
}
}
+// Implements android.DepInInSameApex
+func (p *prebuiltCommon) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
+ tag := ctx.OtherModuleDependencyTag(dep)
+ _, ok := tag.(exportedDependencyTag)
+ return ok
+}
+
// apexInfoMutator marks any modules for which this apex exports a file as requiring an apex
// specific variant and checks that they are supported.
//
@@ -142,34 +149,43 @@
// Collect the list of dependencies.
var dependencies []android.ApexModule
- mctx.VisitDirectDeps(func(m android.Module) {
- tag := mctx.OtherModuleDependencyTag(m)
+ mctx.WalkDeps(func(child, parent android.Module) bool {
+ // If the child is not in the same apex as the parent then exit immediately and do not visit
+ // any of the child's dependencies.
+ if !android.IsDepInSameApex(mctx, parent, child) {
+ return false
+ }
+
+ tag := mctx.OtherModuleDependencyTag(child)
+ depName := mctx.OtherModuleName(child)
if exportedTag, ok := tag.(exportedDependencyTag); ok {
propertyName := exportedTag.name
- depName := mctx.OtherModuleName(m)
// It is an error if the other module is not a prebuilt.
- if _, ok := m.(android.PrebuiltInterface); !ok {
+ if !android.IsModulePrebuilt(child) {
mctx.PropertyErrorf(propertyName, "%q is not a prebuilt module", depName)
- return
+ return false
}
// It is an error if the other module is not an ApexModule.
- if _, ok := m.(android.ApexModule); !ok {
+ if _, ok := child.(android.ApexModule); !ok {
mctx.PropertyErrorf(propertyName, "%q is not usable within an apex", depName)
- return
+ return false
}
-
- // Strip off the prebuilt_ prefix if present before storing content to ensure consistent
- // behavior whether there is a corresponding source module present or not.
- depName = android.RemoveOptionalPrebuiltPrefix(depName)
-
- // Remember that this module was added as a direct dependency.
- contents[depName] = contents[depName].Add(true)
-
- // Add the module to the list of dependencies that need to have an APEX variant.
- dependencies = append(dependencies, m.(android.ApexModule))
}
+
+ // Strip off the prebuilt_ prefix if present before storing content to ensure consistent
+ // behavior whether there is a corresponding source module present or not.
+ depName = android.RemoveOptionalPrebuiltPrefix(depName)
+
+ // Remember if this module was added as a direct dependency.
+ direct := parent == mctx.Module()
+ contents[depName] = contents[depName].Add(direct)
+
+ // Add the module to the list of dependencies that need to have an APEX variant.
+ dependencies = append(dependencies, child.(android.ApexModule))
+
+ return true
})
// Create contents for the prebuilt_apex and store it away for later use.
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index de9dc45..4dd383d 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -55,6 +55,8 @@
ctx.RegisterModuleType("prebuilt_firmware", PrebuiltFirmwareFactory)
ctx.RegisterModuleType("prebuilt_dsp", PrebuiltDSPFactory)
ctx.RegisterModuleType("prebuilt_rfsa", PrebuiltRFSAFactory)
+
+ ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
}
var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
@@ -124,6 +126,7 @@
type PrebuiltEtc struct {
android.ModuleBase
+ android.DefaultableModuleBase
properties prebuiltEtcProperties
subdirProperties prebuiltSubdirProperties
@@ -139,6 +142,11 @@
additionalDependencies *android.Paths
}
+type Defaults struct {
+ android.ModuleBase
+ android.DefaultsModuleBase
+}
+
func (p *PrebuiltEtc) inRamdisk() bool {
return p.ModuleBase.InRamdisk() || p.ModuleBase.InstallInRamdisk()
}
@@ -378,6 +386,25 @@
InitPrebuiltEtcModule(module, "etc")
// This module is device-only
android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibFirst)
+ android.InitDefaultableModule(module)
+ return module
+}
+
+func defaultsFactory() android.Module {
+ return DefaultsFactory()
+}
+
+func DefaultsFactory(props ...interface{}) android.Module {
+ module := &Defaults{}
+
+ module.AddProperties(props...)
+ module.AddProperties(
+ &prebuiltEtcProperties{},
+ &prebuiltSubdirProperties{},
+ )
+
+ android.InitDefaultsModule(module)
+
return module
}
diff --git a/java/java.go b/java/java.go
index cfbe4b0..d74bf68 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1298,9 +1298,10 @@
if ai.ForPrebuiltApex {
if deapexerModule == nil {
// This should never happen as a variant for a prebuilt_apex is only created if the
- // deapxer module has been configured to export the dex implementation jar for this module.
+ // deapexer module has been configured to export the dex implementation jar for this module.
ctx.ModuleErrorf("internal error: module %q does not depend on a `deapexer` module for prebuilt_apex %q",
j.Name(), ai.ApexVariationName)
+ return
}
// Get the path of the dex implementation jar from the `deapexer` module.
diff --git a/python/python.go b/python/python.go
index 4444a70..0f5b788 100644
--- a/python/python.go
+++ b/python/python.go
@@ -444,11 +444,10 @@
var sharedLibs []string
// if embedded launcher is enabled, we need to collect the shared library depenendencies of the
// launcher
- ctx.VisitDirectDeps(func(dep android.Module) {
- if ctx.OtherModuleDependencyTag(dep) == launcherSharedLibTag {
- sharedLibs = append(sharedLibs, ctx.OtherModuleName(dep))
- }
- })
+ for _, dep := range ctx.GetDirectDepsWithTag(launcherSharedLibTag) {
+ sharedLibs = append(sharedLibs, ctx.OtherModuleName(dep))
+ }
+
p.installer.setAndroidMkSharedLibs(sharedLibs)
// Install the par file from installSource