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 bba545e039)
This commit is contained in:
Yo Chiang
2020-06-09 16:15:37 +08:00
committed by Yi-yo Chiang
parent 8d6286befe
commit 97c74da17b
3 changed files with 54 additions and 11 deletions

View File

@@ -819,6 +819,10 @@ func (m *ModuleBase) Host() bool {
return m.Os().Class == Host || m.Os().Class == HostCross return m.Os().Class == Host || m.Os().Class == HostCross
} }
func (m *ModuleBase) Device() bool {
return m.Os().Class == Device
}
func (m *ModuleBase) Arch() Arch { func (m *ModuleBase) Arch() Arch {
return m.Target().Arch return m.Target().Arch
} }

View File

@@ -430,6 +430,40 @@ func TestVndk(t *testing.T) {
checkVndkLibrariesOutput(t, ctx, "vndkcorevariant.libraries.txt", nil) 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) { func TestVndkLibrariesTxtAndroidMk(t *testing.T) {
bp := ` bp := `
vndk_libraries_txt { vndk_libraries_txt {

View File

@@ -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() { if !m.Enabled() {
return false return true
} }
if !m.Device() {
if !mctx.Device() { // Skip non-device modules
return false return true
} }
if m.Target().NativeBridge == android.NativeBridgeEnabled { 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 return false
} }
@@ -377,11 +385,8 @@ func VndkMutator(mctx android.BottomUpMutatorContext) {
if !ok { if !ok {
return return
} }
if !m.Enabled() {
return if shouldSkipVndkMutator(m) {
}
if m.Target().NativeBridge == android.NativeBridgeEnabled {
// Skip native_bridge modules
return return
} }