summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2024-08-27 20:13:19 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-08-27 20:13:19 +0000
commita5762dd78bc9984fa78eaa07d7b3d2aa7708c410 (patch)
treeed54883ccdd6070f9f28a50d141978ad0b4b19c5
parenta6f4b6b1044326d5beb3f563b1bf7918669d8820 (diff)
parent46e4fad202f1bf18f2a1ee33ff70f61dd0e804a3 (diff)
Merge "Add a property to rust_ffi targets to exclude them from APEXes." into main
-rw-r--r--apex/apex.go8
-rw-r--r--rust/library.go9
-rw-r--r--rust/rust.go13
3 files changed, 30 insertions, 0 deletions
diff --git a/apex/apex.go b/apex/apex.go
index 6286be348..2feaaeee1 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2230,6 +2230,10 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
addAconfigFiles(vctx, ctx, child)
return true // track transitive dependencies
} else if rm, ok := child.(*rust.Module); ok {
+ if !android.IsDepInSameApex(ctx, am, am) {
+ return false
+ }
+
af := apexFileForRustLibrary(ctx, rm)
af.transitiveDep = true
vctx.filesInfo = append(vctx.filesInfo, af)
@@ -2249,6 +2253,10 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext,
}
} else if rust.IsDylibDepTag(depTag) {
if rustm, ok := child.(*rust.Module); ok && rustm.IsInstallableToApex() {
+ if !android.IsDepInSameApex(ctx, am, am) {
+ return false
+ }
+
af := apexFileForRustLibrary(ctx, rustm)
af.transitiveDep = true
vctx.filesInfo = append(vctx.filesInfo, af)
diff --git a/rust/library.go b/rust/library.go
index 50d5a72ae..7db8f3691 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -70,6 +70,10 @@ type LibraryCompilerProperties struct {
// Whether this library is part of the Rust toolchain sysroot.
Sysroot *bool
+
+ // Exclude this rust_ffi target from being included in APEXes.
+ // TODO(b/362509506): remove this once stubs are properly supported by rust_ffi targets.
+ Apex_exclude *bool
}
type LibraryMutatedProperties struct {
@@ -122,6 +126,7 @@ type libraryInterface interface {
shared() bool
sysroot() bool
source() bool
+ apexExclude() bool
// Returns true if the build options for the module have selected a particular build type
buildRlib() bool
@@ -186,6 +191,10 @@ func (library *libraryDecorator) source() bool {
return library.MutatedProperties.VariantIsSource
}
+func (library *libraryDecorator) apexExclude() bool {
+ return Bool(library.Properties.Apex_exclude)
+}
+
func (library *libraryDecorator) buildRlib() bool {
return library.MutatedProperties.BuildRlib && BoolDefault(library.Properties.Rlib.Enabled, true)
}
diff --git a/rust/rust.go b/rust/rust.go
index 3402adcc5..5a973c4e7 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -294,6 +294,15 @@ func (mod *Module) StaticExecutable() bool {
return mod.StaticallyLinked()
}
+func (mod *Module) ApexExclude() bool {
+ if mod.compiler != nil {
+ if library, ok := mod.compiler.(libraryInterface); ok {
+ return library.apexExclude()
+ }
+ }
+ return false
+}
+
func (mod *Module) Object() bool {
// Rust has no modules which produce only object files.
return false
@@ -1863,6 +1872,10 @@ func (mod *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Mo
return false
}
+ if rustDep, ok := dep.(*Module); ok && rustDep.ApexExclude() {
+ return false
+ }
+
return true
}