From 65b62244712802432940c74a6b43d0a509b94cb8 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Wed, 25 Nov 2020 12:44:59 +0900 Subject: [PATCH] Clients of PackagingBase can customize dependency tag to use Previously, the dep tag used by PackagingBase was fixed, which prevented some of its clients (e.g. cvd-host-package) from opting in to android.InstallAlwaysNeededDependencyTag. Now, PackagingBase.AddDeps accepts the dependency tag to use. Also, dependencies toward rust dylib, rlib, and proc_macro are configured to return true on InstallDepNeeded. This is required to install shared_lib dependencies of the rust modules when they are depended on by a rust binary. Exempt-From-Owner-Approval: a trivial change after +2 from the owner. This has to land ASAP as many users are affected by acloud being unavailable. Bug: N/A Test: m Test: acloud create --local-instance --local-image Change-Id: If22aee7c6f314fcb03b9d4fe6901a2557f1e899c --- android/packaging.go | 9 +++------ android/packaging_test.go | 4 +++- filesystem/filesystem.go | 6 +++++- rust/rust.go | 8 ++++++++ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/android/packaging.go b/android/packaging.go index 512e4ba53..a10699715 100644 --- a/android/packaging.go +++ b/android/packaging.go @@ -45,7 +45,8 @@ type PackageModule interface { packagingBase() *PackagingBase // AddDeps adds dependencies to the `deps` modules. This should be called in DepsMutator. - AddDeps(ctx BottomUpMutatorContext) + // When adding the dependencies, depTag is used as the tag. + AddDeps(ctx BottomUpMutatorContext, depTag blueprint.DependencyTag) // CopyDepsToZip zips the built artifacts of the dependencies into the given zip file and // returns zip entries in it. This is expected to be called in GenerateAndroidBuildActions, @@ -82,10 +83,6 @@ type PackagingProperties struct { Multilib packagingMultilibProperties `android:"arch_variant"` } -type packagingDependencyTag struct{ blueprint.BaseDependencyTag } - -var depTag = packagingDependencyTag{} - func InitPackageModule(p PackageModule) { base := p.packagingBase() p.AddProperties(&base.properties) @@ -134,7 +131,7 @@ func (p *PackagingBase) getSupportedTargets(ctx BaseModuleContext) []Target { } // See PackageModule.AddDeps -func (p *PackagingBase) AddDeps(ctx BottomUpMutatorContext) { +func (p *PackagingBase) AddDeps(ctx BottomUpMutatorContext, depTag blueprint.DependencyTag) { for _, t := range p.getSupportedTargets(ctx) { for _, dep := range p.getDepsForArch(ctx, t.Arch.ArchType) { if p.IgnoreMissingDependencies && !ctx.OtherModuleExists(dep) { diff --git a/android/packaging_test.go b/android/packaging_test.go index 7710c7fd8..2acd15c01 100644 --- a/android/packaging_test.go +++ b/android/packaging_test.go @@ -17,6 +17,8 @@ package android import ( "reflect" "testing" + + "github.com/google/blueprint" ) // Module to be packaged @@ -61,7 +63,7 @@ func packageTestModuleFactory() Module { } func (m *packageTestModule) DepsMutator(ctx BottomUpMutatorContext) { - m.AddDeps(ctx) + m.AddDeps(ctx, struct{ blueprint.BaseDependencyTag }{}) } func (m *packageTestModule) GenerateAndroidBuildActions(ctx ModuleContext) { diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index a1605b449..ecbfbab09 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -18,6 +18,8 @@ import ( "fmt" "android/soong/android" + + "github.com/google/blueprint" ) func init() { @@ -36,8 +38,10 @@ func filesystemFactory() android.Module { return module } +var dependencyTag = struct{ blueprint.BaseDependencyTag }{} + func (f *filesystem) DepsMutator(ctx android.BottomUpMutatorContext) { - f.AddDeps(ctx) + f.AddDeps(ctx, dependencyTag) } var pctx = android.NewPackageContext("android/soong/filesystem") diff --git a/rust/rust.go b/rust/rust.go index 5b9404504..bd81c1754 100644 --- a/rust/rust.go +++ b/rust/rust.go @@ -685,6 +685,14 @@ type dependencyTag struct { proc_macro bool } +// InstallDepNeeded returns true for rlibs, dylibs, and proc macros so that they or their transitive +// dependencies (especially C/C++ shared libs) are installed as dependencies of a rust binary. +func (d dependencyTag) InstallDepNeeded() bool { + return d.library || d.proc_macro +} + +var _ android.InstallNeededDependencyTag = dependencyTag{} + var ( customBindgenDepTag = dependencyTag{name: "customBindgenTag"} rlibDepTag = dependencyTag{name: "rlibTag", library: true}