From bf1b63f90a2bcde850b34f04e6869bb5d7044880 Mon Sep 17 00:00:00 2001 From: Inseob Kim Date: Fri, 21 Jan 2022 18:12:48 +0900 Subject: [PATCH] Don't install static snapshot to device Static snapshots are wrongly being installed to the device, due to installFile call. Bug: 215081717 Test: manually create modules and see result Android.mk Change-Id: I9229278c801b1ed11b3fd2803e531a97e9dc9a90 --- cc/androidmk.go | 10 +++++++++- cc/snapshot_prebuilt.go | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cc/androidmk.go b/cc/androidmk.go index 800b58f33..fc17312d8 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -15,6 +15,8 @@ package cc import ( + "github.com/google/blueprint/proptools" + "fmt" "io" "path/filepath" @@ -532,7 +534,13 @@ func (c *snapshotLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entrie c.libraryDecorator.androidMkWriteExportedFlags(entries) if c.shared() || c.static() { - path, file := filepath.Split(c.path.String()) + src := c.path.String() + // For static libraries which aren't installed, directly use Src to extract filename. + // This is safe: generated snapshot modules have a real path as Src, not a module + if c.static() { + src = proptools.String(c.properties.Src) + } + path, file := filepath.Split(src) stem, suffix, ext := android.SplitFileExt(file) entries.SetString("LOCAL_BUILT_MODULE_STEM", "$(LOCAL_MODULE)"+ext) entries.SetString("LOCAL_MODULE_SUFFIX", suffix) diff --git a/cc/snapshot_prebuilt.go b/cc/snapshot_prebuilt.go index 253a11bb6..753d74c75 100644 --- a/cc/snapshot_prebuilt.go +++ b/cc/snapshot_prebuilt.go @@ -506,7 +506,7 @@ func (p *snapshotLibraryDecorator) link(ctx ModuleContext, flags Flags, deps Pat } func (p *snapshotLibraryDecorator) install(ctx ModuleContext, file android.Path) { - if p.MatchesWithDevice(ctx.DeviceConfig()) && (p.shared() || p.static()) { + if p.MatchesWithDevice(ctx.DeviceConfig()) && p.shared() { p.baseInstaller.install(ctx, file) } }