Merge "Transitively add APEX variants for contents of prebuilt_apex/apex_set"
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/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/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