Merge changes from topic "enable-hidden-api" into main
* changes: Enable hiddenapi check for from-text stub build Utilize module lib and test api superset module in hiddenapi
This commit is contained in:
@@ -316,6 +316,60 @@ func TestBootclasspathFragment_StubLibs(t *testing.T) {
|
|||||||
android.AssertPathsRelativeToTopEquals(t, "widest dex stubs jar", expectedWidestPaths, info.TransitiveStubDexJarsByScope.StubDexJarsForWidestAPIScope())
|
android.AssertPathsRelativeToTopEquals(t, "widest dex stubs jar", expectedWidestPaths, info.TransitiveStubDexJarsByScope.StubDexJarsForWidestAPIScope())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFromTextWidestApiScope(t *testing.T) {
|
||||||
|
result := android.GroupFixturePreparers(
|
||||||
|
prepareForTestWithBootclasspathFragment,
|
||||||
|
PrepareForTestWithJavaSdkLibraryFiles,
|
||||||
|
android.FixtureModifyConfig(func(config android.Config) {
|
||||||
|
config.SetBuildFromTextStub(true)
|
||||||
|
}),
|
||||||
|
FixtureWithLastReleaseApis("mysdklibrary", "android-non-updatable"),
|
||||||
|
FixtureConfigureApexBootJars("someapex:mysdklibrary"),
|
||||||
|
).RunTestWithBp(t, `
|
||||||
|
bootclasspath_fragment {
|
||||||
|
name: "myfragment",
|
||||||
|
contents: ["mysdklibrary"],
|
||||||
|
additional_stubs: [
|
||||||
|
"android-non-updatable",
|
||||||
|
],
|
||||||
|
hidden_api: {
|
||||||
|
split_packages: ["*"],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
java_sdk_library {
|
||||||
|
name: "mysdklibrary",
|
||||||
|
srcs: ["a.java"],
|
||||||
|
shared_library: false,
|
||||||
|
public: {enabled: true},
|
||||||
|
system: {enabled: true},
|
||||||
|
}
|
||||||
|
java_sdk_library {
|
||||||
|
name: "android-non-updatable",
|
||||||
|
srcs: ["b.java"],
|
||||||
|
compile_dex: true,
|
||||||
|
public: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
system: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
test: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
module_lib: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
fragment := result.ModuleForTests("myfragment", "android_common")
|
||||||
|
dependencyStubDexFlag := "--dependency-stub-dex=out/soong/.intermediates/default/java/android-non-updatable.stubs.test_module_lib/android_common/dex/android-non-updatable.stubs.test_module_lib.jar"
|
||||||
|
stubFlagsCommand := fragment.Output("modular-hiddenapi/stub-flags.csv").RuleParams.Command
|
||||||
|
android.AssertStringDoesContain(t,
|
||||||
|
"Stub flags generating command does not include the expected dependency stub dex file",
|
||||||
|
stubFlagsCommand, dependencyStubDexFlag)
|
||||||
|
}
|
||||||
|
|
||||||
func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) {
|
func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) {
|
||||||
result := android.GroupFixturePreparers(
|
result := android.GroupFixturePreparers(
|
||||||
prepareForTestWithBootclasspathFragment,
|
prepareForTestWithBootclasspathFragment,
|
||||||
|
@@ -38,10 +38,14 @@ type HiddenAPIScope struct {
|
|||||||
// The option needed to passed to "hiddenapi list".
|
// The option needed to passed to "hiddenapi list".
|
||||||
hiddenAPIListOption string
|
hiddenAPIListOption string
|
||||||
|
|
||||||
// The name sof the source stub library modules that contain the API provided by the platform,
|
// The names of the source stub library modules that contain the API provided by the platform,
|
||||||
// i.e. by modules that are not in an APEX.
|
// i.e. by modules that are not in an APEX.
|
||||||
nonUpdatableSourceModule string
|
nonUpdatableSourceModule string
|
||||||
|
|
||||||
|
// The names of from-text stub library modules that contain the API provided by the platform,
|
||||||
|
// i.e. by modules that are not in an APEX.
|
||||||
|
nonUpdatableFromTextModule string
|
||||||
|
|
||||||
// The names of the prebuilt stub library modules that contain the API provided by the platform,
|
// The names of the prebuilt stub library modules that contain the API provided by the platform,
|
||||||
// i.e. by modules that are not in an APEX.
|
// i.e. by modules that are not in an APEX.
|
||||||
nonUpdatablePrebuiltModule string
|
nonUpdatablePrebuiltModule string
|
||||||
@@ -86,6 +90,9 @@ func (l *HiddenAPIScope) scopeSpecificStubModule(ctx android.BaseModuleContext,
|
|||||||
if ctx.Config().AlwaysUsePrebuiltSdks() {
|
if ctx.Config().AlwaysUsePrebuiltSdks() {
|
||||||
return l.nonUpdatablePrebuiltModule
|
return l.nonUpdatablePrebuiltModule
|
||||||
} else {
|
} else {
|
||||||
|
if l.nonUpdatableFromTextModule != "" && ctx.Config().BuildFromTextStub() {
|
||||||
|
return l.nonUpdatableFromTextModule
|
||||||
|
}
|
||||||
return l.nonUpdatableSourceModule
|
return l.nonUpdatableSourceModule
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -119,6 +126,7 @@ var (
|
|||||||
ModuleLibHiddenAPIScope = initHiddenAPIScope(&HiddenAPIScope{
|
ModuleLibHiddenAPIScope = initHiddenAPIScope(&HiddenAPIScope{
|
||||||
name: "module-lib",
|
name: "module-lib",
|
||||||
sdkKind: android.SdkModule,
|
sdkKind: android.SdkModule,
|
||||||
|
nonUpdatableFromTextModule: "android-non-updatable.stubs.test_module_lib",
|
||||||
})
|
})
|
||||||
CorePlatformHiddenAPIScope = initHiddenAPIScope(&HiddenAPIScope{
|
CorePlatformHiddenAPIScope = initHiddenAPIScope(&HiddenAPIScope{
|
||||||
name: "core-platform",
|
name: "core-platform",
|
||||||
@@ -647,7 +655,7 @@ func (s StubDexJarsByModule) addStubDexJar(ctx android.ModuleContext, module and
|
|||||||
// public version is provided by the art.module.public.api module. In those cases it is necessary
|
// public version is provided by the art.module.public.api module. In those cases it is necessary
|
||||||
// to treat all those modules as they were the same name, otherwise it will result in multiple
|
// to treat all those modules as they were the same name, otherwise it will result in multiple
|
||||||
// definitions of a single class being passed to hidden API processing which will cause an error.
|
// definitions of a single class being passed to hidden API processing which will cause an error.
|
||||||
if name == scope.nonUpdatablePrebuiltModule || name == scope.nonUpdatableSourceModule {
|
if name == scope.nonUpdatablePrebuiltModule || name == scope.nonUpdatableSourceModule || name == scope.nonUpdatableFromTextModule {
|
||||||
// Treat all *android-non-updatable* modules as if they were part of an android-non-updatable
|
// Treat all *android-non-updatable* modules as if they were part of an android-non-updatable
|
||||||
// java_sdk_library.
|
// java_sdk_library.
|
||||||
// TODO(b/192067200): Remove once android-non-updatable is a java_sdk_library or equivalent.
|
// TODO(b/192067200): Remove once android-non-updatable is a java_sdk_library or equivalent.
|
||||||
|
@@ -491,6 +491,7 @@ func gatherRequiredDepsForTest() string {
|
|||||||
"android-non-updatable.stubs.system.from-text": systemDroidstubs,
|
"android-non-updatable.stubs.system.from-text": systemDroidstubs,
|
||||||
"android-non-updatable.stubs.test.from-text": testDroidstubs,
|
"android-non-updatable.stubs.test.from-text": testDroidstubs,
|
||||||
"android-non-updatable.stubs.module_lib.from-text": moduleLibDroidstubs,
|
"android-non-updatable.stubs.module_lib.from-text": moduleLibDroidstubs,
|
||||||
|
"android-non-updatable.stubs.test_module_lib": moduleLibDroidstubs,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, droidstubs := range droidstubsStructs {
|
for _, droidstubs := range droidstubsStructs {
|
||||||
|
@@ -472,11 +472,6 @@ func NewConfig(ctx Context, args ...string) Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ret.BuildFromTextStub() {
|
|
||||||
// TODO(b/271443071): support hidden api check for from-text stub build
|
|
||||||
ret.environ.Set("UNSAFE_DISABLE_HIDDENAPI_FLAGS", "true")
|
|
||||||
}
|
|
||||||
|
|
||||||
bpd := ret.BazelMetricsDir()
|
bpd := ret.BazelMetricsDir()
|
||||||
if err := os.RemoveAll(bpd); err != nil {
|
if err := os.RemoveAll(bpd); err != nil {
|
||||||
ctx.Fatalf("Unable to remove bazel profile directory %q: %v", bpd, err)
|
ctx.Fatalf("Unable to remove bazel profile directory %q: %v", bpd, err)
|
||||||
|
Reference in New Issue
Block a user