Loading android/allowlists/allowlists.go +3 −1 Original line number Diff line number Diff line Loading @@ -350,6 +350,8 @@ var ( "packages/modules/NetworkStack/common/captiveportal": Bp2BuildDefaultTrue, "packages/modules/NeuralNetworks/apex": Bp2BuildDefaultTrue, "packages/modules/NeuralNetworks/apex/testing": Bp2BuildDefaultTrue, "packages/modules/SdkExtensions/gen_sdk": Bp2BuildDefaultTrue, "packages/modules/common/proto": Bp2BuildDefaultTrue, "packages/providers/MediaProvider/tools/dialogs": Bp2BuildDefaultFalse, // TODO(b/242834374) "packages/screensavers/Basic": Bp2BuildDefaultTrue, "packages/services/Car/tests/SampleRearViewCamera": Bp2BuildDefaultFalse, // TODO(b/242834321) Loading Loading @@ -1088,7 +1090,7 @@ var ( "versioner", // TODO(b/228313961): depends on prebuilt shared library libclang-cpp_host as a shared library, which does not supply expected providers for a shared library // requires host tools for apexer "apexer_test", "apexer_test_host_tools", "host_apex_verifier", "apexer_test", "apexer_test_host_tools", "host_apex_verifier", "host-apex-verifier", // java bugs "libbase_ndk", // TODO(b/186826477): fails to link libctscamera2_jni for device (required for CtsCameraTestCases) Loading bp2build/sh_test_conversion_test.go +196 −42 Original line number Diff line number Diff line Loading @@ -22,11 +22,18 @@ import ( ) func TestShTestSimple(t *testing.T) { RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{ RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) }, Bp2buildTestCase{ Description: "sh_test test", ModuleTypeUnderTest: "sh_test", StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"}, ModuleTypeUnderTestFactory: sh.ShTestFactory, Blueprint: `sh_test{ Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") + simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") + simpleModule("filegroup", "libc++") + simpleModule("filegroup", "libcrypto") + `sh_test{ name: "sts-rootcanal-sidebins", src: "empty.sh", test_suites: [ Loading @@ -48,27 +55,36 @@ func TestShTestSimple(t *testing.T) { ExpectedBazelTargets: []string{ MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{ "srcs": `["empty.sh"]`, "runs_on": `["device"]`, "data": `[ "android.hardware.bluetooth@1.1-service.sim.rc", "android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ":libc++", ":libcrypto", ]`, "data_bins": `[ ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ]`, "test_config": `"art-gtests-target-install-apex.xml"`, "test_config_template": `":art-run-test-target-template"`, "auto_gen_config": "False", "tags": `["no-remote"]`, })}, }) } func TestShTestHostSimple(t *testing.T) { RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{ RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) }, Bp2buildTestCase{ Description: "sh_test_host test", ModuleTypeUnderTest: "sh_test_host", StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"}, ModuleTypeUnderTestFactory: sh.ShTestHostFactory, Blueprint: `sh_test_host{ Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") + simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") + simpleModule("filegroup", "libc++") + simpleModule("filegroup", "libcrypto") + `sh_test_host{ name: "sts-rootcanal-sidebins", src: "empty.sh", test_suites: [ Loading @@ -90,17 +106,19 @@ func TestShTestHostSimple(t *testing.T) { ExpectedBazelTargets: []string{ MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{ "srcs": `["empty.sh"]`, "runs_on": `["host_without_device"]`, "data": `[ "android.hardware.bluetooth@1.1-service.sim.rc", "android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ":libc++", ":libcrypto", ]`, "data_bins": `[ ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ]`, "tags": `["no-remote"]`, "test_config": `"art-gtests-target-install-apex.xml"`, "test_config_template": `":art-run-test-target-template"`, "auto_gen_config": "False", "target_compatible_with": `select({ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"], "//conditions:default": [], Loading @@ -109,12 +127,20 @@ func TestShTestHostSimple(t *testing.T) { }) } func TestShTestSimpleUnset(t *testing.T) { RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{ func TestShTestAutogen(t *testing.T) { RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) }, Bp2buildTestCase{ Description: "sh_test test", ModuleTypeUnderTest: "sh_test", StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", "art-run-test-target-template"}, ModuleTypeUnderTestFactory: sh.ShTestFactory, Blueprint: `sh_test{ Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") + simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") + simpleModule("filegroup", "libc++") + simpleModule("filegroup", "libcrypto") + simpleModule("filegroup", "art-run-test-target-template") + `sh_test{ name: "sts-rootcanal-sidebins", src: "empty.sh", test_suites: [ Loading @@ -127,18 +153,134 @@ func TestShTestSimpleUnset(t *testing.T) { ], data: ["android.hardware.bluetooth@1.1-service.sim.rc"], data_libs: ["libc++","libcrypto"], test_config: "art-gtests-target-install-apex.xml", test_config_template: ":art-run-test-target-template", auto_gen_config: true, test_options:{tags: ["no-remote"], }, }`, ExpectedBazelTargets: []string{ MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{ "srcs": `["empty.sh"]`, "runs_on": `["device"]`, "auto_generate_test_config": "True", "target_compatible_with": `["//build/bazel/platforms/os:android"]`, "template_test_config": `":art-run-test-target-template"`, "data": `[ "android.hardware.bluetooth@1.1-service.sim.rc", ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ":libc++", ":libcrypto", ]`, "data_bins": `[ ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ]`, "tags": `["no-remote"]`, })}, }) } func TestShTestHostAutogen(t *testing.T) { RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) }, Bp2buildTestCase{ Description: "sh_test_host test", ModuleTypeUnderTest: "sh_test_host", StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", "art-run-test-target-template"}, ModuleTypeUnderTestFactory: sh.ShTestHostFactory, Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") + simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") + simpleModule("filegroup", "libc++") + simpleModule("filegroup", "libcrypto") + simpleModule("filegroup", "art-run-test-target-template") + `sh_test_host{ name: "sts-rootcanal-sidebins", src: "empty.sh", test_suites: [ "sts", "sts-lite", ], data_bins: [ "android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", "android.hardware.bluetooth@1.1-impl-sim" ], data: ["android.hardware.bluetooth@1.1-service.sim.rc"], data_libs: ["libc++","libcrypto"], test_config: "art-gtests-target-install-apex.xml", test_config_template: ":art-run-test-target-template", auto_gen_config: true, test_options:{tags: ["no-remote"], }, }`, ExpectedBazelTargets: []string{ MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{ "srcs": `["empty.sh"]`, "runs_on": `["host_without_device"]`, "auto_generate_test_config": "True", "target_compatible_with": `select({ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"], "//conditions:default": [], })`, "template_test_config": `":art-run-test-target-template"`, "data": `[ "android.hardware.bluetooth@1.1-service.sim.rc", ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ":libc++", ":libcrypto", ]`, "data_bins": `[ ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ]`, "tags": `["no-remote"]`, })}, }) } func TestShTestSimpleUnset(t *testing.T) { RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) }, Bp2buildTestCase{ Description: "sh_test test", ModuleTypeUnderTest: "sh_test", StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"}, ModuleTypeUnderTestFactory: sh.ShTestFactory, Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") + simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") + simpleModule("filegroup", "libc++") + simpleModule("filegroup", "libcrypto") + `sh_test{ name: "sts-rootcanal-sidebins", src: "empty.sh", test_suites: [ "sts", "sts-lite", ], data_bins: [ "android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim" ], data: ["android.hardware.bluetooth@1.1-service.sim.rc"], data_libs: ["libc++","libcrypto"], test_options:{tags: ["no-remote"], }, }`, ExpectedBazelTargets: []string{ MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{ "srcs": `["empty.sh"]`, "runs_on": `["device"]`, "data": `[ "android.hardware.bluetooth@1.1-service.sim.rc", ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ":libc++", ":libcrypto", ]`, "data_bins": `[ ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ]`, "tags": `["no-remote"]`, })}, Loading @@ -146,11 +288,18 @@ func TestShTestSimpleUnset(t *testing.T) { } func TestShTestHostSimpleUnset(t *testing.T) { RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{ RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) }, Bp2buildTestCase{ Description: "sh_test_host test", ModuleTypeUnderTest: "sh_test_host", ModuleTypeUnderTestFactory: sh.ShTestHostFactory, Blueprint: `sh_test_host{ StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"}, Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") + simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") + simpleModule("filegroup", "libc++") + simpleModule("filegroup", "libcrypto") + `sh_test_host{ name: "sts-rootcanal-sidebins", src: "empty.sh", test_suites: [ Loading @@ -169,12 +318,17 @@ func TestShTestHostSimpleUnset(t *testing.T) { ExpectedBazelTargets: []string{ MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{ "srcs": `["empty.sh"]`, "runs_on": `["host_without_device"]`, "data": `[ "android.hardware.bluetooth@1.1-service.sim.rc", "android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ":libc++", ":libcrypto", ]`, "data_bins": `[ ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ]`, "tags": `["no-remote"]`, "target_compatible_with": `select({ Loading cc/afdo.go +1 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ func (afdo *afdo) flags(ctx ModuleContext, flags Flags) Flags { // 3. Make the profile searchable by the build system. So it's used the next time the binary // is built. flags.Local.CFlags = append([]string{"-funique-internal-linkage-names"}, flags.Local.CFlags...) flags.Local.CFlags = append([]string{"-mllvm", "-enable-fs-discriminator=true"}, flags.Local.CFlags...) } if path := afdo.Properties.FdoProfilePath; path != nil { // The flags are prepended to allow overriding. Loading java/java.go +28 −8 Original line number Diff line number Diff line Loading @@ -1689,6 +1689,12 @@ type JavaApiLibraryProperties struct { // Version of previously released API file for compatibility check. Previous_api *string `android:"path"` // java_system_modules module providing the jar to be added to the // bootclasspath when compiling the stubs. // The jar will also be passed to metalava as a classpath to // generate compilable stubs. System_modules *string } func ApiLibraryFactory() android.Module { Loading @@ -1708,7 +1714,8 @@ func (al *ApiLibrary) StubsJar() android.Path { } func metalavaStubCmd(ctx android.ModuleContext, rule *android.RuleBuilder, srcs android.Paths, homeDir android.WritablePath) *android.RuleBuilderCommand { srcs android.Paths, homeDir android.WritablePath, classpath android.Paths) *android.RuleBuilderCommand { rule.Command().Text("rm -rf").Flag(homeDir.String()) rule.Command().Text("mkdir -p").Flag(homeDir.String()) Loading Loading @@ -1747,12 +1754,17 @@ func metalavaStubCmd(ctx android.ModuleContext, rule *android.RuleBuilder, FlagWithArg("--hide ", "InvalidNullabilityOverride"). FlagWithArg("--hide ", "ChangedDefault") if len(classpath) == 0 { // The main purpose of the `--api-class-resolution api` option is to force metalava to ignore // classes on the classpath when an API file contains missing classes. However, as this command // does not specify `--classpath` this is not needed for that. However, this is also used as a // signal to the special metalava code for generating stubs from text files that it needs to add // some additional items into the API (e.g. default constructors). cmd.FlagWithArg("--api-class-resolution ", "api") } else { cmd.FlagWithArg("--api-class-resolution ", "api:classpath") cmd.FlagWithInputList("--classpath ", classpath, ":") } return cmd } Loading Loading @@ -1815,6 +1827,9 @@ func (al *ApiLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { if al.properties.Full_api_surface_stub != nil { ctx.AddVariationDependencies(nil, depApiSrcsTag, String(al.properties.Full_api_surface_stub)) } if al.properties.System_modules != nil { ctx.AddVariationDependencies(nil, systemModulesTag, String(al.properties.System_modules)) } } // Map where key is the api scope name and value is the int value Loading Loading @@ -1854,6 +1869,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { var classPaths android.Paths var staticLibs android.Paths var depApiSrcsStubsJar android.Path var systemModulesPaths android.Paths ctx.VisitDirectDeps(func(dep android.Module) { tag := ctx.OtherModuleDependencyTag(dep) switch tag { Loading @@ -1872,6 +1888,9 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { case depApiSrcsTag: provider := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo) depApiSrcsStubsJar = provider.HeaderJars[0] case systemModulesTag: module := dep.(SystemModulesProvider) systemModulesPaths = append(systemModulesPaths, module.HeaderJars()...) } }) Loading @@ -1885,7 +1904,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { ctx.ModuleErrorf("Error: %s has an empty api file.", ctx.ModuleName()) } cmd := metalavaStubCmd(ctx, rule, srcFiles, homeDir) cmd := metalavaStubCmd(ctx, rule, srcFiles, homeDir, systemModulesPaths) al.stubsFlags(ctx, cmd, stubsDir) Loading Loading @@ -1917,6 +1936,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { flags.javaVersion = getStubsJavaVersion() flags.javacFlags = strings.Join(al.properties.Javacflags, " ") flags.classpath = classpath(classPaths) flags.bootClasspath = classpath(systemModulesPaths) annoSrcJar := android.PathForModuleOut(ctx, ctx.ModuleName(), "anno.srcjar") Loading java/java_test.go +36 −0 Original line number Diff line number Diff line Loading @@ -2447,3 +2447,39 @@ func TestJavaApiLibraryApiFilesSorting(t *testing.T) { "default/java/api/module-lib-current.txt default/java/api/system-server-current.txt" android.AssertStringDoesContain(t, "source text files not in api scope order", manifestCommand, sourceFilesFlag) } func TestSdkLibraryProvidesSystemModulesToApiLibrary(t *testing.T) { result := android.GroupFixturePreparers( prepareForJavaTest, PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("foo"), android.FixtureModifyConfig(func(config android.Config) { config.SetApiLibraries([]string{"foo"}) }), android.FixtureMergeMockFs( map[string][]byte{ "A.java": nil, }, ), ).RunTestWithBp(t, ` java_library { name: "bar", srcs: ["a.java"], } java_system_modules { name: "baz", libs: ["bar"], } java_sdk_library { name: "foo", srcs: ["A.java"], system_modules: "baz", } `) m := result.ModuleForTests(apiScopePublic.apiLibraryModuleName("foo"), "android_common") manifest := m.Output("metalava.sbox.textproto") sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest) manifestCommand := sboxProto.Commands[0].GetCommand() classPathFlag := "--classpath __SBOX_SANDBOX_DIR__/out/.intermediates/bar/android_common/turbine-combined/bar.jar" android.AssertStringDoesContain(t, "command expected to contain classpath flag", manifestCommand, classPathFlag) } Loading
android/allowlists/allowlists.go +3 −1 Original line number Diff line number Diff line Loading @@ -350,6 +350,8 @@ var ( "packages/modules/NetworkStack/common/captiveportal": Bp2BuildDefaultTrue, "packages/modules/NeuralNetworks/apex": Bp2BuildDefaultTrue, "packages/modules/NeuralNetworks/apex/testing": Bp2BuildDefaultTrue, "packages/modules/SdkExtensions/gen_sdk": Bp2BuildDefaultTrue, "packages/modules/common/proto": Bp2BuildDefaultTrue, "packages/providers/MediaProvider/tools/dialogs": Bp2BuildDefaultFalse, // TODO(b/242834374) "packages/screensavers/Basic": Bp2BuildDefaultTrue, "packages/services/Car/tests/SampleRearViewCamera": Bp2BuildDefaultFalse, // TODO(b/242834321) Loading Loading @@ -1088,7 +1090,7 @@ var ( "versioner", // TODO(b/228313961): depends on prebuilt shared library libclang-cpp_host as a shared library, which does not supply expected providers for a shared library // requires host tools for apexer "apexer_test", "apexer_test_host_tools", "host_apex_verifier", "apexer_test", "apexer_test_host_tools", "host_apex_verifier", "host-apex-verifier", // java bugs "libbase_ndk", // TODO(b/186826477): fails to link libctscamera2_jni for device (required for CtsCameraTestCases) Loading
bp2build/sh_test_conversion_test.go +196 −42 Original line number Diff line number Diff line Loading @@ -22,11 +22,18 @@ import ( ) func TestShTestSimple(t *testing.T) { RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{ RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) }, Bp2buildTestCase{ Description: "sh_test test", ModuleTypeUnderTest: "sh_test", StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"}, ModuleTypeUnderTestFactory: sh.ShTestFactory, Blueprint: `sh_test{ Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") + simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") + simpleModule("filegroup", "libc++") + simpleModule("filegroup", "libcrypto") + `sh_test{ name: "sts-rootcanal-sidebins", src: "empty.sh", test_suites: [ Loading @@ -48,27 +55,36 @@ func TestShTestSimple(t *testing.T) { ExpectedBazelTargets: []string{ MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{ "srcs": `["empty.sh"]`, "runs_on": `["device"]`, "data": `[ "android.hardware.bluetooth@1.1-service.sim.rc", "android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ":libc++", ":libcrypto", ]`, "data_bins": `[ ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ]`, "test_config": `"art-gtests-target-install-apex.xml"`, "test_config_template": `":art-run-test-target-template"`, "auto_gen_config": "False", "tags": `["no-remote"]`, })}, }) } func TestShTestHostSimple(t *testing.T) { RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{ RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) }, Bp2buildTestCase{ Description: "sh_test_host test", ModuleTypeUnderTest: "sh_test_host", StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"}, ModuleTypeUnderTestFactory: sh.ShTestHostFactory, Blueprint: `sh_test_host{ Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") + simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") + simpleModule("filegroup", "libc++") + simpleModule("filegroup", "libcrypto") + `sh_test_host{ name: "sts-rootcanal-sidebins", src: "empty.sh", test_suites: [ Loading @@ -90,17 +106,19 @@ func TestShTestHostSimple(t *testing.T) { ExpectedBazelTargets: []string{ MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{ "srcs": `["empty.sh"]`, "runs_on": `["host_without_device"]`, "data": `[ "android.hardware.bluetooth@1.1-service.sim.rc", "android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ":libc++", ":libcrypto", ]`, "data_bins": `[ ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ]`, "tags": `["no-remote"]`, "test_config": `"art-gtests-target-install-apex.xml"`, "test_config_template": `":art-run-test-target-template"`, "auto_gen_config": "False", "target_compatible_with": `select({ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"], "//conditions:default": [], Loading @@ -109,12 +127,20 @@ func TestShTestHostSimple(t *testing.T) { }) } func TestShTestSimpleUnset(t *testing.T) { RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{ func TestShTestAutogen(t *testing.T) { RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) }, Bp2buildTestCase{ Description: "sh_test test", ModuleTypeUnderTest: "sh_test", StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", "art-run-test-target-template"}, ModuleTypeUnderTestFactory: sh.ShTestFactory, Blueprint: `sh_test{ Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") + simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") + simpleModule("filegroup", "libc++") + simpleModule("filegroup", "libcrypto") + simpleModule("filegroup", "art-run-test-target-template") + `sh_test{ name: "sts-rootcanal-sidebins", src: "empty.sh", test_suites: [ Loading @@ -127,18 +153,134 @@ func TestShTestSimpleUnset(t *testing.T) { ], data: ["android.hardware.bluetooth@1.1-service.sim.rc"], data_libs: ["libc++","libcrypto"], test_config: "art-gtests-target-install-apex.xml", test_config_template: ":art-run-test-target-template", auto_gen_config: true, test_options:{tags: ["no-remote"], }, }`, ExpectedBazelTargets: []string{ MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{ "srcs": `["empty.sh"]`, "runs_on": `["device"]`, "auto_generate_test_config": "True", "target_compatible_with": `["//build/bazel/platforms/os:android"]`, "template_test_config": `":art-run-test-target-template"`, "data": `[ "android.hardware.bluetooth@1.1-service.sim.rc", ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ":libc++", ":libcrypto", ]`, "data_bins": `[ ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ]`, "tags": `["no-remote"]`, })}, }) } func TestShTestHostAutogen(t *testing.T) { RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) }, Bp2buildTestCase{ Description: "sh_test_host test", ModuleTypeUnderTest: "sh_test_host", StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", "art-run-test-target-template"}, ModuleTypeUnderTestFactory: sh.ShTestHostFactory, Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") + simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") + simpleModule("filegroup", "libc++") + simpleModule("filegroup", "libcrypto") + simpleModule("filegroup", "art-run-test-target-template") + `sh_test_host{ name: "sts-rootcanal-sidebins", src: "empty.sh", test_suites: [ "sts", "sts-lite", ], data_bins: [ "android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", "android.hardware.bluetooth@1.1-impl-sim" ], data: ["android.hardware.bluetooth@1.1-service.sim.rc"], data_libs: ["libc++","libcrypto"], test_config: "art-gtests-target-install-apex.xml", test_config_template: ":art-run-test-target-template", auto_gen_config: true, test_options:{tags: ["no-remote"], }, }`, ExpectedBazelTargets: []string{ MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{ "srcs": `["empty.sh"]`, "runs_on": `["host_without_device"]`, "auto_generate_test_config": "True", "target_compatible_with": `select({ "//build/bazel/platforms/os:android": ["@platforms//:incompatible"], "//conditions:default": [], })`, "template_test_config": `":art-run-test-target-template"`, "data": `[ "android.hardware.bluetooth@1.1-service.sim.rc", ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ":libc++", ":libcrypto", ]`, "data_bins": `[ ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ]`, "tags": `["no-remote"]`, })}, }) } func TestShTestSimpleUnset(t *testing.T) { RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) }, Bp2buildTestCase{ Description: "sh_test test", ModuleTypeUnderTest: "sh_test", StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"}, ModuleTypeUnderTestFactory: sh.ShTestFactory, Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") + simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") + simpleModule("filegroup", "libc++") + simpleModule("filegroup", "libcrypto") + `sh_test{ name: "sts-rootcanal-sidebins", src: "empty.sh", test_suites: [ "sts", "sts-lite", ], data_bins: [ "android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim" ], data: ["android.hardware.bluetooth@1.1-service.sim.rc"], data_libs: ["libc++","libcrypto"], test_options:{tags: ["no-remote"], }, }`, ExpectedBazelTargets: []string{ MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{ "srcs": `["empty.sh"]`, "runs_on": `["device"]`, "data": `[ "android.hardware.bluetooth@1.1-service.sim.rc", ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ":libc++", ":libcrypto", ]`, "data_bins": `[ ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ]`, "tags": `["no-remote"]`, })}, Loading @@ -146,11 +288,18 @@ func TestShTestSimpleUnset(t *testing.T) { } func TestShTestHostSimpleUnset(t *testing.T) { RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, Bp2buildTestCase{ RunBp2BuildTestCase(t, func(ctx android.RegistrationContext) { ctx.RegisterModuleType("filegroup", android.FileGroupFactory) }, Bp2buildTestCase{ Description: "sh_test_host test", ModuleTypeUnderTest: "sh_test_host", ModuleTypeUnderTestFactory: sh.ShTestHostFactory, Blueprint: `sh_test_host{ StubbedBuildDefinitions: []string{"android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto"}, Blueprint: simpleModule("filegroup", "android.hardware.bluetooth@1.1-service.sim") + simpleModule("filegroup", "android.hardware.bluetooth@1.1-impl-sim") + simpleModule("filegroup", "libc++") + simpleModule("filegroup", "libcrypto") + `sh_test_host{ name: "sts-rootcanal-sidebins", src: "empty.sh", test_suites: [ Loading @@ -169,12 +318,17 @@ func TestShTestHostSimpleUnset(t *testing.T) { ExpectedBazelTargets: []string{ MakeBazelTarget("sh_test", "sts-rootcanal-sidebins", AttrNameToString{ "srcs": `["empty.sh"]`, "runs_on": `["host_without_device"]`, "data": `[ "android.hardware.bluetooth@1.1-service.sim.rc", "android.hardware.bluetooth@1.1-service.sim", "android.hardware.bluetooth@1.1-impl-sim", "libc++", "libcrypto", ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ":libc++", ":libcrypto", ]`, "data_bins": `[ ":android.hardware.bluetooth@1.1-service.sim", ":android.hardware.bluetooth@1.1-impl-sim", ]`, "tags": `["no-remote"]`, "target_compatible_with": `select({ Loading
cc/afdo.go +1 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,7 @@ func (afdo *afdo) flags(ctx ModuleContext, flags Flags) Flags { // 3. Make the profile searchable by the build system. So it's used the next time the binary // is built. flags.Local.CFlags = append([]string{"-funique-internal-linkage-names"}, flags.Local.CFlags...) flags.Local.CFlags = append([]string{"-mllvm", "-enable-fs-discriminator=true"}, flags.Local.CFlags...) } if path := afdo.Properties.FdoProfilePath; path != nil { // The flags are prepended to allow overriding. Loading
java/java.go +28 −8 Original line number Diff line number Diff line Loading @@ -1689,6 +1689,12 @@ type JavaApiLibraryProperties struct { // Version of previously released API file for compatibility check. Previous_api *string `android:"path"` // java_system_modules module providing the jar to be added to the // bootclasspath when compiling the stubs. // The jar will also be passed to metalava as a classpath to // generate compilable stubs. System_modules *string } func ApiLibraryFactory() android.Module { Loading @@ -1708,7 +1714,8 @@ func (al *ApiLibrary) StubsJar() android.Path { } func metalavaStubCmd(ctx android.ModuleContext, rule *android.RuleBuilder, srcs android.Paths, homeDir android.WritablePath) *android.RuleBuilderCommand { srcs android.Paths, homeDir android.WritablePath, classpath android.Paths) *android.RuleBuilderCommand { rule.Command().Text("rm -rf").Flag(homeDir.String()) rule.Command().Text("mkdir -p").Flag(homeDir.String()) Loading Loading @@ -1747,12 +1754,17 @@ func metalavaStubCmd(ctx android.ModuleContext, rule *android.RuleBuilder, FlagWithArg("--hide ", "InvalidNullabilityOverride"). FlagWithArg("--hide ", "ChangedDefault") if len(classpath) == 0 { // The main purpose of the `--api-class-resolution api` option is to force metalava to ignore // classes on the classpath when an API file contains missing classes. However, as this command // does not specify `--classpath` this is not needed for that. However, this is also used as a // signal to the special metalava code for generating stubs from text files that it needs to add // some additional items into the API (e.g. default constructors). cmd.FlagWithArg("--api-class-resolution ", "api") } else { cmd.FlagWithArg("--api-class-resolution ", "api:classpath") cmd.FlagWithInputList("--classpath ", classpath, ":") } return cmd } Loading Loading @@ -1815,6 +1827,9 @@ func (al *ApiLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { if al.properties.Full_api_surface_stub != nil { ctx.AddVariationDependencies(nil, depApiSrcsTag, String(al.properties.Full_api_surface_stub)) } if al.properties.System_modules != nil { ctx.AddVariationDependencies(nil, systemModulesTag, String(al.properties.System_modules)) } } // Map where key is the api scope name and value is the int value Loading Loading @@ -1854,6 +1869,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { var classPaths android.Paths var staticLibs android.Paths var depApiSrcsStubsJar android.Path var systemModulesPaths android.Paths ctx.VisitDirectDeps(func(dep android.Module) { tag := ctx.OtherModuleDependencyTag(dep) switch tag { Loading @@ -1872,6 +1888,9 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { case depApiSrcsTag: provider := ctx.OtherModuleProvider(dep, JavaInfoProvider).(JavaInfo) depApiSrcsStubsJar = provider.HeaderJars[0] case systemModulesTag: module := dep.(SystemModulesProvider) systemModulesPaths = append(systemModulesPaths, module.HeaderJars()...) } }) Loading @@ -1885,7 +1904,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { ctx.ModuleErrorf("Error: %s has an empty api file.", ctx.ModuleName()) } cmd := metalavaStubCmd(ctx, rule, srcFiles, homeDir) cmd := metalavaStubCmd(ctx, rule, srcFiles, homeDir, systemModulesPaths) al.stubsFlags(ctx, cmd, stubsDir) Loading Loading @@ -1917,6 +1936,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { flags.javaVersion = getStubsJavaVersion() flags.javacFlags = strings.Join(al.properties.Javacflags, " ") flags.classpath = classpath(classPaths) flags.bootClasspath = classpath(systemModulesPaths) annoSrcJar := android.PathForModuleOut(ctx, ctx.ModuleName(), "anno.srcjar") Loading
java/java_test.go +36 −0 Original line number Diff line number Diff line Loading @@ -2447,3 +2447,39 @@ func TestJavaApiLibraryApiFilesSorting(t *testing.T) { "default/java/api/module-lib-current.txt default/java/api/system-server-current.txt" android.AssertStringDoesContain(t, "source text files not in api scope order", manifestCommand, sourceFilesFlag) } func TestSdkLibraryProvidesSystemModulesToApiLibrary(t *testing.T) { result := android.GroupFixturePreparers( prepareForJavaTest, PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("foo"), android.FixtureModifyConfig(func(config android.Config) { config.SetApiLibraries([]string{"foo"}) }), android.FixtureMergeMockFs( map[string][]byte{ "A.java": nil, }, ), ).RunTestWithBp(t, ` java_library { name: "bar", srcs: ["a.java"], } java_system_modules { name: "baz", libs: ["bar"], } java_sdk_library { name: "foo", srcs: ["A.java"], system_modules: "baz", } `) m := result.ModuleForTests(apiScopePublic.apiLibraryModuleName("foo"), "android_common") manifest := m.Output("metalava.sbox.textproto") sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest) manifestCommand := sboxProto.Commands[0].GetCommand() classPathFlag := "--classpath __SBOX_SANDBOX_DIR__/out/.intermediates/bar/android_common/turbine-combined/bar.jar" android.AssertStringDoesContain(t, "command expected to contain classpath flag", manifestCommand, classPathFlag) }