Add attribute to disable last-api compat tracking
Setting this to true by default is dangerous as it can mask bugs. Create a dedicated attribute for java_sdk_library to enable this behavior instead. The default will be flipped in a future CL when all the current offenders have been fixed. Fix all the tests to have the right API files. Bug: 176092454 Test: m nothing Change-Id: Ieab94bcb74abf8d018365a56fb447fe3dbd46957
This commit is contained in:
parent
69c43e40ad
commit
dff2c78a20
|
@ -259,6 +259,7 @@ func testApexContext(_ *testing.T, bp string, handlers ...testCustomizer) (*andr
|
||||||
java.RegisterSystemModulesBuildComponents(ctx)
|
java.RegisterSystemModulesBuildComponents(ctx)
|
||||||
java.RegisterAppBuildComponents(ctx)
|
java.RegisterAppBuildComponents(ctx)
|
||||||
java.RegisterSdkLibraryBuildComponents(ctx)
|
java.RegisterSdkLibraryBuildComponents(ctx)
|
||||||
|
java.RegisterPrebuiltApisBuildComponents(ctx)
|
||||||
ctx.RegisterSingletonType("apex_keys_text", apexKeysTextFactory)
|
ctx.RegisterSingletonType("apex_keys_text", apexKeysTextFactory)
|
||||||
ctx.RegisterModuleType("bpf", bpf.BpfFactory)
|
ctx.RegisterModuleType("bpf", bpf.BpfFactory)
|
||||||
|
|
||||||
|
@ -4994,6 +4995,11 @@ var filesForSdkLibrary = map[string][]byte{
|
||||||
"api/test-current.txt": nil,
|
"api/test-current.txt": nil,
|
||||||
"api/test-removed.txt": nil,
|
"api/test-removed.txt": nil,
|
||||||
|
|
||||||
|
"100/public/api/foo.txt": nil,
|
||||||
|
"100/public/api/foo-removed.txt": nil,
|
||||||
|
"100/system/api/foo.txt": nil,
|
||||||
|
"100/system/api/foo-removed.txt": nil,
|
||||||
|
|
||||||
// For java_sdk_library_import
|
// For java_sdk_library_import
|
||||||
"a.jar": nil,
|
"a.jar": nil,
|
||||||
}
|
}
|
||||||
|
@ -5018,6 +5024,11 @@ func TestJavaSDKLibrary(t *testing.T) {
|
||||||
api_packages: ["foo"],
|
api_packages: ["foo"],
|
||||||
apex_available: [ "myapex" ],
|
apex_available: [ "myapex" ],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prebuilt_apis {
|
||||||
|
name: "sdk",
|
||||||
|
api_dirs: ["100"],
|
||||||
|
}
|
||||||
`, withFiles(filesForSdkLibrary))
|
`, withFiles(filesForSdkLibrary))
|
||||||
|
|
||||||
// java_sdk_library installs both impl jar and permission XML
|
// java_sdk_library installs both impl jar and permission XML
|
||||||
|
@ -5061,6 +5072,11 @@ func TestJavaSDKLibrary_WithinApex(t *testing.T) {
|
||||||
sdk_version: "none",
|
sdk_version: "none",
|
||||||
system_modules: "none",
|
system_modules: "none",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prebuilt_apis {
|
||||||
|
name: "sdk",
|
||||||
|
api_dirs: ["100"],
|
||||||
|
}
|
||||||
`, withFiles(filesForSdkLibrary))
|
`, withFiles(filesForSdkLibrary))
|
||||||
|
|
||||||
// java_sdk_library installs both impl jar and permission XML
|
// java_sdk_library installs both impl jar and permission XML
|
||||||
|
@ -5107,6 +5123,11 @@ func TestJavaSDKLibrary_CrossBoundary(t *testing.T) {
|
||||||
sdk_version: "none",
|
sdk_version: "none",
|
||||||
system_modules: "none",
|
system_modules: "none",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prebuilt_apis {
|
||||||
|
name: "sdk",
|
||||||
|
api_dirs: ["100"],
|
||||||
|
}
|
||||||
`, withFiles(filesForSdkLibrary))
|
`, withFiles(filesForSdkLibrary))
|
||||||
|
|
||||||
// java_sdk_library installs both impl jar and permission XML
|
// java_sdk_library installs both impl jar and permission XML
|
||||||
|
@ -5123,7 +5144,11 @@ func TestJavaSDKLibrary_CrossBoundary(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestJavaSDKLibrary_ImportPreferred(t *testing.T) {
|
func TestJavaSDKLibrary_ImportPreferred(t *testing.T) {
|
||||||
ctx, _ := testApex(t, ``,
|
ctx, _ := testApex(t, `
|
||||||
|
prebuilt_apis {
|
||||||
|
name: "sdk",
|
||||||
|
api_dirs: ["100"],
|
||||||
|
}`,
|
||||||
withFiles(map[string][]byte{
|
withFiles(map[string][]byte{
|
||||||
"apex/a.java": nil,
|
"apex/a.java": nil,
|
||||||
"apex/apex_manifest.json": nil,
|
"apex/apex_manifest.json": nil,
|
||||||
|
@ -5190,7 +5215,7 @@ func TestJavaSDKLibrary_ImportPreferred(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
`),
|
`),
|
||||||
}),
|
}), withFiles(filesForSdkLibrary),
|
||||||
)
|
)
|
||||||
|
|
||||||
// java_sdk_library installs both impl jar and permission XML
|
// java_sdk_library installs both impl jar and permission XML
|
||||||
|
|
|
@ -83,12 +83,11 @@ func testContext(config android.Config) *android.TestContext {
|
||||||
ctx.RegisterModuleType("python_binary_host", python.PythonBinaryHostFactory)
|
ctx.RegisterModuleType("python_binary_host", python.PythonBinaryHostFactory)
|
||||||
RegisterDocsBuildComponents(ctx)
|
RegisterDocsBuildComponents(ctx)
|
||||||
RegisterStubsBuildComponents(ctx)
|
RegisterStubsBuildComponents(ctx)
|
||||||
|
RegisterPrebuiltApisBuildComponents(ctx)
|
||||||
RegisterSdkLibraryBuildComponents(ctx)
|
RegisterSdkLibraryBuildComponents(ctx)
|
||||||
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
||||||
ctx.PreArchMutators(android.RegisterComponentsMutator)
|
ctx.PreArchMutators(android.RegisterComponentsMutator)
|
||||||
|
|
||||||
RegisterPrebuiltApisBuildComponents(ctx)
|
|
||||||
|
|
||||||
ctx.PreDepsMutators(python.RegisterPythonPreDepsMutators)
|
ctx.PreDepsMutators(python.RegisterPythonPreDepsMutators)
|
||||||
ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
|
ctx.PostDepsMutators(android.RegisterOverridePostDepsMutators)
|
||||||
ctx.RegisterPreSingletonType("overlay", android.SingletonFactoryAdaptor(ctx.Context, OverlaySingletonFactory))
|
ctx.RegisterPreSingletonType("overlay", android.SingletonFactoryAdaptor(ctx.Context, OverlaySingletonFactory))
|
||||||
|
@ -1813,7 +1812,7 @@ func TestJavaSdkLibrary(t *testing.T) {
|
||||||
func TestJavaSdkLibrary_StubOrImplOnlyLibs(t *testing.T) {
|
func TestJavaSdkLibrary_StubOrImplOnlyLibs(t *testing.T) {
|
||||||
ctx, _ := testJava(t, `
|
ctx, _ := testJava(t, `
|
||||||
java_sdk_library {
|
java_sdk_library {
|
||||||
name: "sdk_lib",
|
name: "sdklib",
|
||||||
srcs: ["a.java"],
|
srcs: ["a.java"],
|
||||||
impl_only_libs: ["foo"],
|
impl_only_libs: ["foo"],
|
||||||
stub_only_libs: ["bar"],
|
stub_only_libs: ["bar"],
|
||||||
|
@ -1830,13 +1829,13 @@ func TestJavaSdkLibrary_StubOrImplOnlyLibs(t *testing.T) {
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
for _, implName := range []string{"sdk_lib", "sdk_lib.impl"} {
|
for _, implName := range []string{"sdklib", "sdklib.impl"} {
|
||||||
implJavacCp := ctx.ModuleForTests(implName, "android_common").Rule("javac").Args["classpath"]
|
implJavacCp := ctx.ModuleForTests(implName, "android_common").Rule("javac").Args["classpath"]
|
||||||
if !strings.Contains(implJavacCp, "/foo.jar") || strings.Contains(implJavacCp, "/bar.jar") {
|
if !strings.Contains(implJavacCp, "/foo.jar") || strings.Contains(implJavacCp, "/bar.jar") {
|
||||||
t.Errorf("%v javac classpath %v does not contain foo and not bar", implName, implJavacCp)
|
t.Errorf("%v javac classpath %v does not contain foo and not bar", implName, implJavacCp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stubName := apiScopePublic.stubsLibraryModuleName("sdk_lib")
|
stubName := apiScopePublic.stubsLibraryModuleName("sdklib")
|
||||||
stubsJavacCp := ctx.ModuleForTests(stubName, "android_common").Rule("javac").Args["classpath"]
|
stubsJavacCp := ctx.ModuleForTests(stubName, "android_common").Rule("javac").Args["classpath"]
|
||||||
if strings.Contains(stubsJavacCp, "/foo.jar") || !strings.Contains(stubsJavacCp, "/bar.jar") {
|
if strings.Contains(stubsJavacCp, "/foo.jar") || !strings.Contains(stubsJavacCp, "/bar.jar") {
|
||||||
t.Errorf("stubs javac classpath %v does not contain bar and not foo", stubsJavacCp)
|
t.Errorf("stubs javac classpath %v does not contain bar and not foo", stubsJavacCp)
|
||||||
|
|
|
@ -453,6 +453,10 @@ type sdkLibraryProperties struct {
|
||||||
// * Removed API specification filegroup -> <dist-stem>-removed.api.<scope>.latest
|
// * Removed API specification filegroup -> <dist-stem>-removed.api.<scope>.latest
|
||||||
Dist_stem *string
|
Dist_stem *string
|
||||||
|
|
||||||
|
// A compatibility mode that allows historical API-tracking files to not exist.
|
||||||
|
// Do not use.
|
||||||
|
Unsafe_ignore_missing_latest_api bool
|
||||||
|
|
||||||
// indicates whether system and test apis should be generated.
|
// indicates whether system and test apis should be generated.
|
||||||
Generate_system_and_test_apis bool `blueprint:"mutated"`
|
Generate_system_and_test_apis bool `blueprint:"mutated"`
|
||||||
|
|
||||||
|
@ -1352,6 +1356,8 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC
|
||||||
// check against the not-yet-release API
|
// check against the not-yet-release API
|
||||||
props.Check_api.Current.Api_file = proptools.StringPtr(currentApiFileName)
|
props.Check_api.Current.Api_file = proptools.StringPtr(currentApiFileName)
|
||||||
props.Check_api.Current.Removed_api_file = proptools.StringPtr(removedApiFileName)
|
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 {
|
||||||
// check against the latest released API
|
// check against the latest released API
|
||||||
|
@ -1359,7 +1365,6 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC
|
||||||
props.Check_api.Last_released.Api_file = latestApiFilegroupName
|
props.Check_api.Last_released.Api_file = latestApiFilegroupName
|
||||||
props.Check_api.Last_released.Removed_api_file = proptools.StringPtr(
|
props.Check_api.Last_released.Removed_api_file = proptools.StringPtr(
|
||||||
module.latestRemovedApiFilegroupName(apiScope))
|
module.latestRemovedApiFilegroupName(apiScope))
|
||||||
props.Check_api.Ignore_missing_latest_api = proptools.BoolPtr(true)
|
|
||||||
|
|
||||||
if proptools.Bool(module.sdkLibraryProperties.Api_lint.Enabled) {
|
if proptools.Bool(module.sdkLibraryProperties.Api_lint.Enabled) {
|
||||||
// Enable api lint.
|
// Enable api lint.
|
||||||
|
|
|
@ -39,57 +39,6 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
|
||||||
"api/test-current.txt": nil,
|
"api/test-current.txt": nil,
|
||||||
"api/test-removed.txt": nil,
|
"api/test-removed.txt": nil,
|
||||||
|
|
||||||
"prebuilts/sdk/14/public/android.jar": nil,
|
|
||||||
"prebuilts/sdk/14/public/framework.aidl": nil,
|
|
||||||
"prebuilts/sdk/14/system/android.jar": nil,
|
|
||||||
"prebuilts/sdk/17/public/android.jar": nil,
|
|
||||||
"prebuilts/sdk/17/public/framework.aidl": nil,
|
|
||||||
"prebuilts/sdk/17/system/android.jar": nil,
|
|
||||||
"prebuilts/sdk/28/public/android.jar": nil,
|
|
||||||
"prebuilts/sdk/28/public/framework.aidl": nil,
|
|
||||||
"prebuilts/sdk/28/system/android.jar": nil,
|
|
||||||
"prebuilts/sdk/29/public/android.jar": nil,
|
|
||||||
"prebuilts/sdk/29/public/framework.aidl": nil,
|
|
||||||
"prebuilts/sdk/29/system/android.jar": nil,
|
|
||||||
"prebuilts/sdk/29/system/foo.jar": nil,
|
|
||||||
"prebuilts/sdk/30/public/android.jar": nil,
|
|
||||||
"prebuilts/sdk/30/public/framework.aidl": nil,
|
|
||||||
"prebuilts/sdk/30/system/android.jar": nil,
|
|
||||||
"prebuilts/sdk/30/system/foo.jar": nil,
|
|
||||||
"prebuilts/sdk/30/module-lib/android.jar": nil,
|
|
||||||
"prebuilts/sdk/30/module-lib/foo.jar": nil,
|
|
||||||
"prebuilts/sdk/30/public/core-for-system-modules.jar": nil,
|
|
||||||
"prebuilts/sdk/current/core/android.jar": nil,
|
|
||||||
"prebuilts/sdk/current/public/android.jar": nil,
|
|
||||||
"prebuilts/sdk/current/public/framework.aidl": nil,
|
|
||||||
"prebuilts/sdk/current/public/core.jar": nil,
|
|
||||||
"prebuilts/sdk/current/public/core-for-system-modules.jar": nil,
|
|
||||||
"prebuilts/sdk/current/system/android.jar": nil,
|
|
||||||
"prebuilts/sdk/current/test/android.jar": nil,
|
|
||||||
"prebuilts/sdk/28/public/api/foo.txt": nil,
|
|
||||||
"prebuilts/sdk/28/system/api/foo.txt": nil,
|
|
||||||
"prebuilts/sdk/28/test/api/foo.txt": nil,
|
|
||||||
"prebuilts/sdk/28/public/api/foo-removed.txt": nil,
|
|
||||||
"prebuilts/sdk/28/system/api/foo-removed.txt": nil,
|
|
||||||
"prebuilts/sdk/28/test/api/foo-removed.txt": nil,
|
|
||||||
"prebuilts/sdk/28/public/api/bar.txt": nil,
|
|
||||||
"prebuilts/sdk/28/system/api/bar.txt": nil,
|
|
||||||
"prebuilts/sdk/28/test/api/bar.txt": nil,
|
|
||||||
"prebuilts/sdk/28/public/api/bar-removed.txt": nil,
|
|
||||||
"prebuilts/sdk/28/system/api/bar-removed.txt": nil,
|
|
||||||
"prebuilts/sdk/28/test/api/bar-removed.txt": nil,
|
|
||||||
"prebuilts/sdk/30/public/api/foo.txt": nil,
|
|
||||||
"prebuilts/sdk/30/system/api/foo.txt": nil,
|
|
||||||
"prebuilts/sdk/30/test/api/foo.txt": nil,
|
|
||||||
"prebuilts/sdk/30/public/api/foo-removed.txt": nil,
|
|
||||||
"prebuilts/sdk/30/system/api/foo-removed.txt": nil,
|
|
||||||
"prebuilts/sdk/30/test/api/foo-removed.txt": nil,
|
|
||||||
"prebuilts/sdk/30/public/api/bar.txt": nil,
|
|
||||||
"prebuilts/sdk/30/system/api/bar.txt": nil,
|
|
||||||
"prebuilts/sdk/30/test/api/bar.txt": nil,
|
|
||||||
"prebuilts/sdk/30/public/api/bar-removed.txt": nil,
|
|
||||||
"prebuilts/sdk/30/system/api/bar-removed.txt": nil,
|
|
||||||
"prebuilts/sdk/30/test/api/bar-removed.txt": nil,
|
|
||||||
"prebuilts/sdk/tools/core-lambda-stubs.jar": nil,
|
"prebuilts/sdk/tools/core-lambda-stubs.jar": nil,
|
||||||
"prebuilts/sdk/Android.bp": []byte(`prebuilt_apis { name: "sdk", api_dirs: ["14", "28", "30", "current"], imports_sdk_version: "none", imports_compile_dex:true,}`),
|
"prebuilts/sdk/Android.bp": []byte(`prebuilt_apis { name: "sdk", api_dirs: ["14", "28", "30", "current"], imports_sdk_version: "none", imports_compile_dex:true,}`),
|
||||||
|
|
||||||
|
@ -104,6 +53,16 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
|
||||||
"api/system-server-removed.txt": nil,
|
"api/system-server-removed.txt": nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
levels := []string{"14", "28", "29", "30", "current"}
|
||||||
|
libs := []string{
|
||||||
|
"android", "foo", "bar", "sdklib", "barney", "betty", "foo-shared_library",
|
||||||
|
"foo-no_shared_library", "core-for-system-modules", "quuz", "qux", "fred",
|
||||||
|
"runtime-library",
|
||||||
|
}
|
||||||
|
for k, v := range prebuiltApisFilesForLibs(levels, libs) {
|
||||||
|
mockFS[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
cc.GatherRequiredFilesForTest(mockFS)
|
cc.GatherRequiredFilesForTest(mockFS)
|
||||||
|
|
||||||
for k, v := range fs {
|
for k, v := range fs {
|
||||||
|
@ -121,6 +80,21 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func prebuiltApisFilesForLibs(apiLevels []string, sdkLibs []string) map[string][]byte {
|
||||||
|
fs := make(map[string][]byte)
|
||||||
|
for _, level := range apiLevels {
|
||||||
|
for _, lib := range sdkLibs {
|
||||||
|
for _, scope := range []string{"public", "system", "module-lib", "system-server", "test"} {
|
||||||
|
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/%s.jar", level, scope, lib)] = nil
|
||||||
|
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s.txt", level, scope, lib)] = nil
|
||||||
|
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s-removed.txt", level, scope, lib)] = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fs[fmt.Sprintf("prebuilts/sdk/%s/public/framework.aidl", level)] = nil
|
||||||
|
}
|
||||||
|
return fs
|
||||||
|
}
|
||||||
|
|
||||||
func GatherRequiredDepsForTest() string {
|
func GatherRequiredDepsForTest() string {
|
||||||
var bp string
|
var bp string
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,14 @@ func testSdkWithJava(t *testing.T, bp string) *testSdkResult {
|
||||||
"api/system-server-removed.txt": nil,
|
"api/system-server-removed.txt": nil,
|
||||||
"build/soong/scripts/gen-java-current-api-files.sh": nil,
|
"build/soong/scripts/gen-java-current-api-files.sh": nil,
|
||||||
"docs/known_doctags": nil,
|
"docs/known_doctags": nil,
|
||||||
|
"100/public/api/myjavalib.txt": nil,
|
||||||
|
"100/public/api/myjavalib-removed.txt": nil,
|
||||||
|
"100/system/api/myjavalib.txt": nil,
|
||||||
|
"100/system/api/myjavalib-removed.txt": nil,
|
||||||
|
"100/module-lib/api/myjavalib.txt": nil,
|
||||||
|
"100/module-lib/api/myjavalib-removed.txt": nil,
|
||||||
|
"100/system-server/api/myjavalib.txt": nil,
|
||||||
|
"100/system-server/api/myjavalib-removed.txt": nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
// for java_sdk_library tests
|
// for java_sdk_library tests
|
||||||
|
@ -84,6 +92,10 @@ java_import {
|
||||||
name: "framework",
|
name: "framework",
|
||||||
sdk_version: "none",
|
sdk_version: "none",
|
||||||
}
|
}
|
||||||
|
prebuilt_apis {
|
||||||
|
name: "sdk",
|
||||||
|
api_dirs: ["100"],
|
||||||
|
}
|
||||||
` + bp
|
` + bp
|
||||||
|
|
||||||
return testSdkWithFs(t, bp, fs)
|
return testSdkWithFs(t, bp, fs)
|
||||||
|
|
|
@ -110,6 +110,7 @@ func testSdkContext(bp string, fs map[string][]byte, extraOsTypes []android.OsTy
|
||||||
java.RegisterJavaBuildComponents(ctx)
|
java.RegisterJavaBuildComponents(ctx)
|
||||||
java.RegisterAppBuildComponents(ctx)
|
java.RegisterAppBuildComponents(ctx)
|
||||||
java.RegisterSdkLibraryBuildComponents(ctx)
|
java.RegisterSdkLibraryBuildComponents(ctx)
|
||||||
|
java.RegisterPrebuiltApisBuildComponents(ctx)
|
||||||
java.RegisterStubsBuildComponents(ctx)
|
java.RegisterStubsBuildComponents(ctx)
|
||||||
java.RegisterSystemModulesBuildComponents(ctx)
|
java.RegisterSystemModulesBuildComponents(ctx)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue