diff options
Diffstat (limited to 'java')
| -rwxr-xr-x | java/app.go | 7 | ||||
| -rw-r--r-- | java/app_import.go | 2 | ||||
| -rw-r--r-- | java/app_import_test.go | 18 | ||||
| -rw-r--r-- | java/droiddoc.go | 51 | ||||
| -rw-r--r-- | java/sdk_library.go | 11 |
5 files changed, 22 insertions, 67 deletions
diff --git a/java/app.go b/java/app.go index 249313c35..574472c1b 100755 --- a/java/app.go +++ b/java/app.go @@ -905,6 +905,8 @@ func AndroidAppFactory() android.Module { &module.appProperties, &module.overridableAppProperties) + module.usesLibrary.enforce = true + android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibCommon) android.InitDefaultableModule(module) android.InitOverridableModule(module, &module.appProperties.Overrides) @@ -1175,6 +1177,9 @@ type UsesLibraryProperties struct { // with knowledge of their shared libraries. type usesLibrary struct { usesLibraryProperties UsesLibraryProperties + + // Whether to enforce verify_uses_library check. + enforce bool } func (u *usesLibrary) addLib(lib string, optional bool) { @@ -1241,7 +1246,7 @@ func (u *usesLibrary) classLoaderContextForUsesLibDeps(ctx android.ModuleContext func (u *usesLibrary) enforceUsesLibraries() bool { defaultEnforceUsesLibs := len(u.usesLibraryProperties.Uses_libs) > 0 || len(u.usesLibraryProperties.Optional_uses_libs) > 0 - return BoolDefault(u.usesLibraryProperties.Enforce_uses_libs, defaultEnforceUsesLibs) + return BoolDefault(u.usesLibraryProperties.Enforce_uses_libs, u.enforce || defaultEnforceUsesLibs) } // Freeze the value of `enforce_uses_libs` based on the current values of `uses_libs` and `optional_uses_libs`. diff --git a/java/app_import.go b/java/app_import.go index 2054785f5..df940f1ff 100644 --- a/java/app_import.go +++ b/java/app_import.go @@ -430,6 +430,8 @@ func AndroidAppImportFactory() android.Module { android.InitDefaultableModule(module) android.InitSingleSourcePrebuiltModule(module, &module.properties, "Apk") + module.usesLibrary.enforce = true + return module } diff --git a/java/app_import_test.go b/java/app_import_test.go index 3b55c814a..344d23b55 100644 --- a/java/app_import_test.go +++ b/java/app_import_test.go @@ -182,31 +182,31 @@ func TestAndroidAppImport_DpiVariants(t *testing.T) { name: "no preferred", aaptPreferredConfig: nil, aaptPrebuiltDPI: []string{}, - expected: "prebuilts/apk/app.apk", + expected: "verify_uses_libraries/apk/app.apk", }, { name: "AAPTPreferredConfig matches", aaptPreferredConfig: proptools.StringPtr("xhdpi"), aaptPrebuiltDPI: []string{"xxhdpi", "ldpi"}, - expected: "prebuilts/apk/app_xhdpi.apk", + expected: "verify_uses_libraries/apk/app_xhdpi.apk", }, { name: "AAPTPrebuiltDPI matches", aaptPreferredConfig: proptools.StringPtr("mdpi"), aaptPrebuiltDPI: []string{"xxhdpi", "xhdpi"}, - expected: "prebuilts/apk/app_xxhdpi.apk", + expected: "verify_uses_libraries/apk/app_xxhdpi.apk", }, { name: "non-first AAPTPrebuiltDPI matches", aaptPreferredConfig: proptools.StringPtr("mdpi"), aaptPrebuiltDPI: []string{"ldpi", "xhdpi"}, - expected: "prebuilts/apk/app_xhdpi.apk", + expected: "verify_uses_libraries/apk/app_xhdpi.apk", }, { name: "no matches", aaptPreferredConfig: proptools.StringPtr("mdpi"), aaptPrebuiltDPI: []string{"ldpi", "xxxhdpi"}, - expected: "prebuilts/apk/app.apk", + expected: "verify_uses_libraries/apk/app.apk", }, } @@ -225,7 +225,7 @@ func TestAndroidAppImport_DpiVariants(t *testing.T) { if len(matches) != 2 { t.Errorf("failed to extract the src apk path from %q", jniRuleCommand) } - if test.expected != matches[1] { + if strings.HasSuffix(matches[1], test.expected) { t.Errorf("wrong src apk, expected: %q got: %q", test.expected, matches[1]) } } @@ -302,7 +302,7 @@ func TestAndroidAppImport_ArchVariants(t *testing.T) { }, } `, - expected: "prebuilts/apk/app_arm64.apk", + expected: "verify_uses_libraries/apk/app_arm64.apk", }, { name: "no matching arch", @@ -321,7 +321,7 @@ func TestAndroidAppImport_ArchVariants(t *testing.T) { }, } `, - expected: "prebuilts/apk/app.apk", + expected: "verify_uses_libraries/apk/app.apk", }, { name: "no matching arch without default", @@ -359,7 +359,7 @@ func TestAndroidAppImport_ArchVariants(t *testing.T) { if len(matches) != 2 { t.Errorf("failed to extract the src apk path from %q", jniRuleCommand) } - if test.expected != matches[1] { + if strings.HasSuffix(matches[1], test.expected) { t.Errorf("wrong src apk, expected: %q got: %q", test.expected, matches[1]) } } diff --git a/java/droiddoc.go b/java/droiddoc.go index cbca12a76..c74009ea4 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -192,24 +192,6 @@ type DroidstubsProperties struct { Current ApiToCheck - // The java_sdk_library module generates references to modules (i.e. filegroups) - // from which information about the latest API version can be obtained. As those - // modules may not exist (e.g. because a previous version has not been released) it - // sets ignore_missing_latest_api=true on the droidstubs modules it creates so - // that droidstubs can ignore those references if the modules do not yet exist. - // - // If true then this will ignore module references for modules that do not exist - // in properties that supply the previous version of the API. - // - // There are two sets of those: - // * Api_file, Removed_api_file in check_api.last_released - // * New_since in check_api.api_lint.new_since - // - // The first two must be set as a pair, so either they should both exist or neither - // should exist - in which case when this property is true they are ignored. If one - // exists and the other does not then it is an error. - Ignore_missing_latest_api *bool `blueprint:"mutated"` - Api_lint struct { Enabled *bool @@ -304,25 +286,6 @@ func apiCheckEnabled(ctx android.ModuleContext, apiToCheck ApiToCheck, apiVersio return false } -func ignoreMissingModules(ctx android.BottomUpMutatorContext, apiToCheck *ApiToCheck) { - apiFile := String(apiToCheck.Api_file) - removedApiFile := String(apiToCheck.Removed_api_file) - - apiModule := android.SrcIsModule(apiFile) - removedApiModule := android.SrcIsModule(removedApiFile) - - if apiModule == "" || removedApiModule == "" { - return - } - - if ctx.OtherModuleExists(apiModule) || ctx.OtherModuleExists(removedApiModule) { - return - } - - apiToCheck.Api_file = nil - apiToCheck.Removed_api_file = nil -} - // Used by xsd_config type ApiFilePath interface { ApiFilePath() android.Path @@ -1079,20 +1042,6 @@ func (d *Droidstubs) StubsSrcJar() android.Path { func (d *Droidstubs) DepsMutator(ctx android.BottomUpMutatorContext) { d.Javadoc.addDeps(ctx) - // If requested clear any properties that provide information about the latest version - // of an API and which reference non-existent modules. - if Bool(d.properties.Check_api.Ignore_missing_latest_api) { - ignoreMissingModules(ctx, &d.properties.Check_api.Last_released) - - // If the new_since references a module, e.g. :module-latest-api and the module - // does not exist then clear it. - newSinceSrc := d.properties.Check_api.Api_lint.New_since - newSinceSrcModule := android.SrcIsModule(proptools.String(newSinceSrc)) - if newSinceSrcModule != "" && !ctx.OtherModuleExists(newSinceSrcModule) { - d.properties.Check_api.Api_lint.New_since = nil - } - } - if len(d.properties.Merge_annotations_dirs) != 0 { for _, mergeAnnotationsDir := range d.properties.Merge_annotations_dirs { ctx.AddDependency(ctx.Module(), metalavaMergeAnnotationsDirTag, mergeAnnotationsDir) diff --git a/java/sdk_library.go b/java/sdk_library.go index f279b95b6..1a655a627 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1271,10 +1271,10 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC Merge_annotations_dirs []string Merge_inclusion_annotations_dirs []string Generate_stubs *bool + Previous_api *string Check_api struct { - Current ApiToCheck - Last_released ApiToCheck - Ignore_missing_latest_api *bool + Current ApiToCheck + Last_released ApiToCheck Api_lint struct { Enabled *bool @@ -1357,12 +1357,11 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC // check against the not-yet-release API props.Check_api.Current.Api_file = proptools.StringPtr(currentApiFileName) props.Check_api.Current.Removed_api_file = proptools.StringPtr(removedApiFileName) - // TODO(b/176092454): change true to module.sdkLibraryProperties.Unsafe_ignore_missing_latest_api - props.Check_api.Ignore_missing_latest_api = proptools.BoolPtr(true) - if !apiScope.unstable { + if !(apiScope.unstable || module.sdkLibraryProperties.Unsafe_ignore_missing_latest_api) { // check against the latest released API latestApiFilegroupName := proptools.StringPtr(module.latestApiFilegroupName(apiScope)) + props.Previous_api = latestApiFilegroupName props.Check_api.Last_released.Api_file = latestApiFilegroupName props.Check_api.Last_released.Removed_api_file = proptools.StringPtr( module.latestRemovedApiFilegroupName(apiScope)) |