aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYo Chiang <yochiang@google.com>2020-06-09 16:15:37 +0800
committerYi-yo Chiang <yochiang@google.com>2020-06-18 10:02:07 +0000
commit97c74da17b08580c38e099a4482839852531e6fe (patch)
tree0a0bda5521b8b794aa766df6ca7a7261ee137e63
parent8d6286befebf56020edc9bb939272227d8bdf6d2 (diff)
downloadbuild_soong-97c74da17b08580c38e099a4482839852531e6fe.tar.gz
build_soong-97c74da17b08580c38e099a4482839852531e6fe.tar.bz2
build_soong-97c74da17b08580c38e099a4482839852531e6fe.zip
VNDK listing contains device modules only
Fix a bug where host-only modules were incorrectly listed as VNDK. Also refactor VndkMutator() / apexVndkDepsMutator() module skipping logic. Bug: 158543482 Test: Add unit test to cc/cc_test.go Change-Id: I50b09f526cbc081149d8241c2a091e3ee48ef4d7 Merged-In: I50b09f526cbc081149d8241c2a091e3ee48ef4d7 (cherry picked from commit bba545e039419a8eac4c061f2481826391726968)
-rw-r--r--android/module.go4
-rw-r--r--cc/cc_test.go34
-rw-r--r--cc/vndk.go27
3 files changed, 54 insertions, 11 deletions
diff --git a/android/module.go b/android/module.go
index 0bf48d59..5bccb79a 100644
--- a/android/module.go
+++ b/android/module.go
@@ -819,6 +819,10 @@ func (m *ModuleBase) Host() bool {
return m.Os().Class == Host || m.Os().Class == HostCross
}
+func (m *ModuleBase) Device() bool {
+ return m.Os().Class == Device
+}
+
func (m *ModuleBase) Arch() Arch {
return m.Target().Arch
}
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 76b4e38e..f73e0217 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -430,6 +430,40 @@ func TestVndk(t *testing.T) {
checkVndkLibrariesOutput(t, ctx, "vndkcorevariant.libraries.txt", nil)
}
+func TestVndkWithHostSupported(t *testing.T) {
+ ctx := testCc(t, `
+ cc_library {
+ name: "libvndk_host_supported",
+ vendor_available: true,
+ vndk: {
+ enabled: true,
+ },
+ host_supported: true,
+ }
+
+ cc_library {
+ name: "libvndk_host_supported_but_disabled_on_device",
+ vendor_available: true,
+ vndk: {
+ enabled: true,
+ },
+ host_supported: true,
+ enabled: false,
+ target: {
+ host: {
+ enabled: true,
+ }
+ }
+ }
+
+ vndk_libraries_txt {
+ name: "vndkcore.libraries.txt",
+ }
+ `)
+
+ checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", []string{"libvndk_host_supported.so"})
+}
+
func TestVndkLibrariesTxtAndroidMk(t *testing.T) {
bp := `
vndk_libraries_txt {
diff --git a/cc/vndk.go b/cc/vndk.go
index ef33c1a5..a0608696 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -334,16 +334,24 @@ func processVndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
}
}
-func IsForVndkApex(mctx android.BottomUpMutatorContext, m *Module) bool {
+// Sanity check for modules that mustn't be VNDK
+func shouldSkipVndkMutator(m *Module) bool {
if !m.Enabled() {
- return false
+ return true
}
-
- if !mctx.Device() {
- return false
+ if !m.Device() {
+ // Skip non-device modules
+ return true
}
-
if m.Target().NativeBridge == android.NativeBridgeEnabled {
+ // Skip native_bridge modules
+ return true
+ }
+ return false
+}
+
+func IsForVndkApex(mctx android.BottomUpMutatorContext, m *Module) bool {
+ if shouldSkipVndkMutator(m) {
return false
}
@@ -377,11 +385,8 @@ func VndkMutator(mctx android.BottomUpMutatorContext) {
if !ok {
return
}
- if !m.Enabled() {
- return
- }
- if m.Target().NativeBridge == android.NativeBridgeEnabled {
- // Skip native_bridge modules
+
+ if shouldSkipVndkMutator(m) {
return
}