Merge "VNDK listing contains device modules only" am: 977dc2281f

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1325680

Change-Id: I430a134ba684708db98a26d41cca52e7bb708447
This commit is contained in:
Yo Chiang 2020-06-18 10:00:12 +00:00 committed by Automerger Merge Worker
commit b869828466
3 changed files with 54 additions and 11 deletions

View file

@ -835,6 +835,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
}

View file

@ -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 {

View file

@ -340,16 +340,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
}
@ -383,11 +391,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
}