diff options
-rw-r--r-- | android/module.go | 4 | ||||
-rw-r--r-- | android/override_module.go | 29 | ||||
-rw-r--r-- | cc/cc_test.go | 34 | ||||
-rw-r--r-- | cc/vndk.go | 27 | ||||
-rwxr-xr-x | java/app.go | 2 |
5 files changed, 78 insertions, 18 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/android/override_module.go b/android/override_module.go index 7e58890d..90ddf504 100644 --- a/android/override_module.go +++ b/android/override_module.go @@ -42,6 +42,11 @@ type OverrideModule interface { setOverridingProperties(properties []interface{}) getOverrideModuleProperties() *OverrideModuleProperties + + // Internal funcs to handle interoperability between override modules and prebuilts. + // i.e. cases where an overriding module, too, is overridden by a prebuilt module. + setOverriddenByPrebuilt(overridden bool) + getOverriddenByPrebuilt() bool } // Base module struct for override module types @@ -49,6 +54,8 @@ type OverrideModuleBase struct { moduleProperties OverrideModuleProperties overridingProperties []interface{} + + overriddenByPrebuilt bool } type OverrideModuleProperties struct { @@ -74,6 +81,14 @@ func (o *OverrideModuleBase) GetOverriddenModuleName() string { return proptools.String(o.moduleProperties.Base) } +func (o *OverrideModuleBase) setOverriddenByPrebuilt(overridden bool) { + o.overriddenByPrebuilt = overridden +} + +func (o *OverrideModuleBase) getOverriddenByPrebuilt() bool { + return o.overriddenByPrebuilt +} + func InitOverrideModule(m OverrideModule) { m.setOverridingProperties(m.GetProperties()) @@ -208,21 +223,19 @@ var overrideBaseDepTag overrideBaseDependencyTag // next phase. func overrideModuleDepsMutator(ctx BottomUpMutatorContext) { if module, ok := ctx.Module().(OverrideModule); ok { - // Skip this overriding module if there's a prebuilt module that overrides it with prefer flag. - overriddenByPrebuilt := false + // See if there's a prebuilt module that overrides this override module with prefer flag, + // in which case we call SkipInstall on the corresponding variant later. ctx.VisitDirectDepsWithTag(PrebuiltDepTag, func(dep Module) { prebuilt, ok := dep.(PrebuiltInterface) if !ok { panic("PrebuiltDepTag leads to a non-prebuilt module " + dep.Name()) } if prebuilt.Prebuilt().UsePrebuilt() { - overriddenByPrebuilt = true + module.setOverriddenByPrebuilt(true) return } }) - if !overriddenByPrebuilt { - ctx.AddDependency(ctx.Module(), overrideBaseDepTag, *module.getOverrideModuleProperties().Base) - } + ctx.AddDependency(ctx.Module(), overrideBaseDepTag, *module.getOverrideModuleProperties().Base) } } @@ -258,6 +271,10 @@ func performOverrideMutator(ctx BottomUpMutatorContext) { ctx.AliasVariation(variants[0]) for i, o := range overrides { mods[i+1].(OverridableModule).override(ctx, o) + if o.getOverriddenByPrebuilt() { + // The overriding module itself, too, is overridden by a prebuilt. Skip its installation. + mods[i+1].SkipInstall() + } } } else if o, ok := ctx.Module().(OverrideModule); ok { // Create a variant of the overriding module with its own name. This matches the above local 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 { @@ -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 } diff --git a/java/app.go b/java/app.go index 245c586e..e2e3a53d 100755 --- a/java/app.go +++ b/java/app.go @@ -150,7 +150,7 @@ func (as *AndroidAppSet) GenerateAndroidBuildActions(ctx android.ModuleContext) "allow-prereleased": strconv.FormatBool(proptools.Bool(as.properties.Prerelease)), "screen-densities": screenDensities, "sdk-version": ctx.Config().PlatformSdkVersion(), - "stem": ctx.ModuleName(), + "stem": as.BaseModuleName(), }, }) } |