diff options
Diffstat (limited to 'java')
-rwxr-xr-x | java/app.go | 25 | ||||
-rw-r--r-- | java/app_test.go | 10 | ||||
-rw-r--r-- | java/base.go | 27 | ||||
-rw-r--r-- | java/core-libraries/Android.bp | 108 | ||||
-rw-r--r-- | java/dexpreopt_bootjars.go | 2 | ||||
-rw-r--r-- | java/droidstubs.go | 8 | ||||
-rw-r--r-- | java/fuzz.go | 15 | ||||
-rw-r--r-- | java/hiddenapi_modular.go | 8 | ||||
-rw-r--r-- | java/java.go | 114 | ||||
-rw-r--r-- | java/java_test.go | 55 | ||||
-rw-r--r-- | java/sdk.go | 18 |
11 files changed, 329 insertions, 61 deletions
diff --git a/java/app.go b/java/app.go index 561ce1d17..d9272e4fc 100755 --- a/java/app.go +++ b/java/app.go @@ -18,6 +18,7 @@ package java // related module types, including their override variants. import ( + "fmt" "path/filepath" "strings" @@ -288,7 +289,13 @@ func (a *AndroidApp) OverridablePropertiesDepsMutator(ctx android.BottomUpMutato } if a.appProperties.Privapp_allowlist != nil && !Bool(a.appProperties.Privileged) { - ctx.PropertyErrorf("privapp_allowlist", "privileged must be set in order to use privapp_allowlist") + // There are a few uids that are explicitly considered privileged regardless of their + // app's location. Bluetooth is one such app. It should arguably be moved to priv-app, + // but for now, allow it not to be in priv-app. + privilegedBecauseOfUid := ctx.ModuleName() == "Bluetooth" + if !privilegedBecauseOfUid { + ctx.PropertyErrorf("privapp_allowlist", "privileged must be set in order to use privapp_allowlist (with a few exceptions)") + } } for _, cert := range a.appProperties.Additional_certificates { @@ -795,8 +802,9 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) { shouldInstallAppPackage := (Bool(a.Module.properties.Installable) || ctx.Host()) && apexInfo.IsForPlatform() && !a.appProperties.PreventInstall if shouldInstallAppPackage { if a.privAppAllowlist.Valid() { - installPath := android.PathForModuleInstall(ctx, "etc", "permissions") - ctx.InstallFile(installPath, a.privAppAllowlist.Path().Base(), a.privAppAllowlist.Path()) + allowlistInstallPath := android.PathForModuleInstall(ctx, "etc", "permissions") + allowlistInstallFilename := a.installApkName + ".xml" + ctx.InstallFile(allowlistInstallPath, allowlistInstallFilename, a.privAppAllowlist.Path()) } var extraInstalledPaths android.Paths @@ -1390,10 +1398,15 @@ func (u *usesLibrary) deps(ctx android.BottomUpMutatorContext, addCompatDeps boo } } -// presentOptionalUsesLibs returns optional_uses_libs after filtering out MissingUsesLibraries, which don't exist in the -// build. +// presentOptionalUsesLibs returns optional_uses_libs after filtering out libraries that don't exist in the source tree. func (u *usesLibrary) presentOptionalUsesLibs(ctx android.BaseModuleContext) []string { - optionalUsesLibs, _ := android.FilterList(u.usesLibraryProperties.Optional_uses_libs, ctx.Config().MissingUsesLibraries()) + optionalUsesLibs := android.FilterListPred(u.usesLibraryProperties.Optional_uses_libs, func(s string) bool { + exists := ctx.OtherModuleExists(s) + if !exists && !android.InList(ctx.ModuleName(), ctx.Config().BuildWarningBadOptionalUsesLibsAllowlist()) { + fmt.Printf("Warning: Module '%s' depends on non-existing optional_uses_libs '%s'\n", ctx.ModuleName(), s) + } + return exists + }) return optionalUsesLibs } diff --git a/java/app_test.go b/java/app_test.go index 7f9f0ed9f..cf7d17490 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -2645,7 +2645,7 @@ func TestUsesLibraries(t *testing.T) { PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("runtime-library", "foo", "quuz", "qux", "bar", "fred"), android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.MissingUsesLibraries = []string{"baz"} + variables.BuildWarningBadOptionalUsesLibsAllowlist = []string{"app", "prebuilt"} }), ).RunTestWithBp(t, bp) @@ -3545,8 +3545,8 @@ func TestPrivappAllowlist(t *testing.T) { } // verify that permissions are copied to device - app.Output("out/soong/target/product/test_device/system/etc/permissions/privapp_allowlist_com.android.foo.xml") - overrideApp.Output("out/soong/target/product/test_device/system/etc/permissions/privapp_allowlist_com.google.android.foo.xml") + app.Output("out/soong/target/product/test_device/system/etc/permissions/foo.xml") + overrideApp.Output("out/soong/target/product/test_device/system/etc/permissions/bar.xml") } func TestPrivappAllowlistAndroidMk(t *testing.T) { @@ -3597,7 +3597,7 @@ func TestPrivappAllowlistAndroidMk(t *testing.T) { t, "androidmk has incorrect LOCAL_SOONG_INSTALL_PAIRS; expected to it to include privapp_allowlist", baseEntries.EntryMap["LOCAL_SOONG_INSTALL_PAIRS"][0], - "privapp_allowlist_com.android.foo.xml:\\S+/target/product/test_device/system/etc/permissions/privapp_allowlist_com.android.foo.xml", + "privapp_allowlist_com.android.foo.xml:\\S+/target/product/test_device/system/etc/permissions/foo.xml", ) overrideAndroidApp := overrideApp.Module().(*AndroidApp) @@ -3624,6 +3624,6 @@ func TestPrivappAllowlistAndroidMk(t *testing.T) { t, "androidmk has incorrect LOCAL_SOONG_INSTALL_PAIRS; expected to it to include privapp_allowlist", overrideEntries.EntryMap["LOCAL_SOONG_INSTALL_PAIRS"][0], - "\\S+soong/.intermediates/foo/android_common_bar/privapp_allowlist_com.google.android.foo.xml:\\S+/target/product/test_device/system/etc/permissions/privapp_allowlist_com.google.android.foo.xml", + "\\S+soong/.intermediates/foo/android_common_bar/privapp_allowlist_com.google.android.foo.xml:\\S+/target/product/test_device/system/etc/permissions/bar.xml", ) } diff --git a/java/base.go b/java/base.go index 374138c78..ed61e12ed 100644 --- a/java/base.go +++ b/java/base.go @@ -79,6 +79,9 @@ type CommonProperties struct { // list of java libraries that will be compiled into the resulting jar Static_libs []string `android:"arch_variant"` + // list of java libraries that should not be used to build this module + Exclude_static_libs []string `android:"arch_variant"` + // manifest file to be included in resulting jar Manifest *string `android:"path"` @@ -724,6 +727,8 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) { } libDeps := ctx.AddVariationDependencies(nil, libTag, j.properties.Libs...) + + j.properties.Static_libs = android.RemoveListFromList(j.properties.Static_libs, j.properties.Exclude_static_libs) ctx.AddVariationDependencies(nil, staticLibTag, j.properties.Static_libs...) // Add dependency on libraries that provide additional hidden api annotations. @@ -1923,22 +1928,22 @@ type moduleWithSdkDep interface { func (m *Module) getSdkLinkType(ctx android.BaseModuleContext, name string) (ret sdkLinkType, stubs bool) { switch name { - case android.SdkCore.JavaLibraryName(ctx.Config()), - android.JavaApiLibraryName(ctx.Config(), "legacy.core.platform.api.stubs"), - android.JavaApiLibraryName(ctx.Config(), "stable.core.platform.api.stubs"), + case android.SdkCore.DefaultJavaLibraryName(), + "legacy.core.platform.api.stubs", + "stable.core.platform.api.stubs", "stub-annotations", "private-stub-annotations-jar", - android.JavaApiLibraryName(ctx.Config(), "core-lambda-stubs"), + "core-lambda-stubs", "core-generated-annotation-stubs": return javaCore, true - case android.SdkPublic.JavaLibraryName(ctx.Config()): + case android.SdkPublic.DefaultJavaLibraryName(): return javaSdk, true - case android.SdkSystem.JavaLibraryName(ctx.Config()): + case android.SdkSystem.DefaultJavaLibraryName(): return javaSystem, true - case android.SdkModule.JavaLibraryName(ctx.Config()): + case android.SdkModule.DefaultJavaLibraryName(): return javaModule, true - case android.SdkSystemServer.JavaLibraryName(ctx.Config()): + case android.SdkSystemServer.DefaultJavaLibraryName(): return javaSystemServer, true - case android.SdkTest.JavaLibraryName(ctx.Config()): + case android.SdkTest.DefaultJavaLibraryName(): return javaSystem, true } @@ -2188,5 +2193,9 @@ func (j *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { if binary, ok := ctx.Module().(*Binary); ok { javaBinaryHostBp2Build(ctx, binary) } + case "java_test_host": + if testHost, ok := ctx.Module().(*TestHost); ok { + javaTestHostBp2Build(ctx, testHost) + } } } diff --git a/java/core-libraries/Android.bp b/java/core-libraries/Android.bp index 958f4cead..eadd9c697 100644 --- a/java/core-libraries/Android.bp +++ b/java/core-libraries/Android.bp @@ -33,19 +33,45 @@ dist_targets = [ "win_sdk", ] -java_library { - name: "core.current.stubs", +java_defaults { + name: "core.current.stubs.defaults", visibility: ["//visibility:public"], + sdk_version: "none", + system_modules: "none", + dist: { + targets: dist_targets, + }, +} + +java_library { + name: "core.current.stubs.from-source", + defaults: [ + "core.current.stubs.defaults", + ], static_libs: [ "art.module.public.api.stubs", "conscrypt.module.public.api.stubs", "i18n.module.public.api.stubs", ], - sdk_version: "none", - system_modules: "none", +} - dist: { - targets: dist_targets, +java_library { + name: "core.current.stubs", + defaults: [ + "core.current.stubs.defaults", + ], + static_libs: [ + "core.current.stubs.from-source", + ], + product_variables: { + build_from_text_stub: { + static_libs: [ + "core.current.stubs.from-text", + ], + exclude_static_libs: [ + "core.current.stubs.from-source", + ], + }, }, } @@ -199,18 +225,46 @@ core_platform_visibility = ["//visibility:public"] // API annotations are available to the dex tools that enable enforcement of runtime // accessibility. b/119068555 java_library { + name: "legacy.core.platform.api.stubs.from-source", + visibility: core_platform_visibility, + defaults: [ + "core.platform.api.stubs.defaults", + ], + static_libs: [ + "art.module.public.api.stubs.module_lib", + "conscrypt.module.platform.api.stubs", + "legacy.i18n.module.platform.api.stubs", + ], +} + +java_library { name: "legacy.core.platform.api.stubs", visibility: core_platform_visibility, + defaults: [ + "core.platform.api.stubs.defaults", + ], + static_libs: [ + "legacy.core.platform.api.stubs.from-source", + ], + product_variables: { + build_from_text_stub: { + static_libs: [ + "stable.core.platform.api.stubs.from-text", + ], + exclude_static_libs: [ + "stable.core.platform.api.stubs.from-source", + ], + }, + }, +} + +java_defaults { + name: "core.platform.api.stubs.defaults", hostdex: true, compile_dex: true, sdk_version: "none", system_modules: "none", - static_libs: [ - "art.module.public.api.stubs.module_lib", - "conscrypt.module.platform.api.stubs", - "legacy.i18n.module.platform.api.stubs", - ], patch_module: "java.base", } @@ -233,20 +287,38 @@ java_library { } java_library { - name: "stable.core.platform.api.stubs", + name: "stable.core.platform.api.stubs.from-source", visibility: core_platform_visibility, - hostdex: true, - compile_dex: true, - - sdk_version: "none", - system_modules: "none", + defaults: [ + "core.platform.api.stubs.defaults", + ], static_libs: [ "art.module.public.api.stubs.module_lib", // conscrypt only has a stable version, so it is okay to depend on it here: "conscrypt.module.platform.api.stubs", "stable.i18n.module.platform.api.stubs", ], - patch_module: "java.base", +} + +java_library { + name: "stable.core.platform.api.stubs", + visibility: core_platform_visibility, + defaults: [ + "core.platform.api.stubs.defaults", + ], + static_libs: [ + "stable.core.platform.api.stubs.from-source", + ], + product_variables: { + build_from_text_stub: { + static_libs: [ + "stable.core.platform.api.stubs.from-text", + ], + exclude_static_libs: [ + "stable.core.platform.api.stubs.from-source", + ], + }, + }, } // Same as stable.core.platform.api.stubs, but android annotations are diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index 116c833e0..35f60979f 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -816,7 +816,7 @@ func buildBootImageVariant(ctx android.ModuleContext, image *bootImageVariant, p cmd.FlagWithArg("--instruction-set-features=", global.InstructionSetFeatures[arch]) } - if global.EnableUffdGc { + if global.EnableUffdGc && image.target.Os == android.Android { cmd.Flag("--runtime-arg").Flag("-Xgc:CMC") } diff --git a/java/droidstubs.go b/java/droidstubs.go index 8a521aabb..151c94a43 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -535,6 +535,14 @@ func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersi // b/223382732 FlagWithArg("--hide ", "ChangedDefault") + // Force metalava to ignore classes on the classpath when an API file contains missing classes. + // See b/285140653 for more information. + cmd.FlagWithArg("--api-class-resolution ", "api") + + // Force metalava to sort overloaded methods by their order in the source code. + // See b/285312164 for more information. + cmd.FlagWithArg("--api-overloaded-method-order ", "source") + return cmd } diff --git a/java/fuzz.go b/java/fuzz.go index 5dfaacfb3..b3c2fd47c 100644 --- a/java/fuzz.go +++ b/java/fuzz.go @@ -30,8 +30,12 @@ import ( const ( hostString = "host" targetString = "target" + deviceString = "device" ) +// Any shared libs for these deps will also be packaged +var artDeps = []string{"libdl_android"} + func init() { RegisterJavaFuzzBuildComponents(android.InitRegistrationContext) } @@ -78,7 +82,18 @@ func JavaFuzzFactory() android.Module { } func (j *JavaFuzzTest) DepsMutator(ctx android.BottomUpMutatorContext) { + if j.Os().Class.String() == deviceString { + j.testProperties.Jni_libs = append(j.testProperties.Jni_libs, artDeps...) + } + if len(j.testProperties.Jni_libs) > 0 { + if j.fuzzPackagedModule.FuzzProperties.Fuzz_config == nil { + config := &fuzz.FuzzConfig{} + j.fuzzPackagedModule.FuzzProperties.Fuzz_config = config + } + // this will be used by the ingestion pipeline to determine the version + // of jazzer to add to the fuzzer package + j.fuzzPackagedModule.FuzzProperties.Fuzz_config.IsJni = proptools.BoolPtr(true) for _, target := range ctx.MultiTargets() { sharedLibVariations := append(target.Variations(), blueprint.Variation{Mutator: "link", Variation: "shared"}) ctx.AddFarVariationDependencies(sharedLibVariations, jniLibTag, j.testProperties.Jni_libs...) diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go index e54275b88..da9c9970a 100644 --- a/java/hiddenapi_modular.go +++ b/java/hiddenapi_modular.go @@ -236,12 +236,12 @@ func hiddenAPIComputeMonolithicStubLibModules(config android.Config) map[*Hidden testStubModules = append(testStubModules, "sdk_test_current_android") } else { // Use stub modules built from source - publicStubModules = append(publicStubModules, android.SdkPublic.JavaLibraryName(config)) - systemStubModules = append(systemStubModules, android.SdkSystem.JavaLibraryName(config)) - testStubModules = append(testStubModules, android.SdkTest.JavaLibraryName(config)) + publicStubModules = append(publicStubModules, android.SdkPublic.DefaultJavaLibraryName()) + systemStubModules = append(systemStubModules, android.SdkSystem.DefaultJavaLibraryName()) + testStubModules = append(testStubModules, android.SdkTest.DefaultJavaLibraryName()) } // We do not have prebuilts of the core platform api yet - corePlatformStubModules = append(corePlatformStubModules, android.JavaApiLibraryName(config, "legacy.core.platform.api.stubs")) + corePlatformStubModules = append(corePlatformStubModules, "legacy.core.platform.api.stubs") // Allow products to define their own stubs for custom product jars that apps can use. publicStubModules = append(publicStubModules, config.ProductHiddenAPIStubs()...) diff --git a/java/java.go b/java/java.go index aa9f936d0..a8793fe87 100644 --- a/java/java.go +++ b/java/java.go @@ -936,6 +936,10 @@ type TestOptions struct { // Extra <option> tags to add to the auto generated test xml file. The "key" // is optional in each of these. Tradefed_options []tradefed.Option + + // Extra <option> tags to add to the auto generated test xml file under the test runner, e.g., AndroidJunitTest. + // The "key" is optional in each of these. + Test_runner_options []tradefed.Option } type testProperties struct { @@ -1218,6 +1222,7 @@ func (j *Test) generateAndroidBuildActionsWithConfig(ctx android.ModuleContext, TestSuites: j.testProperties.Test_suites, Config: configs, OptionsForAutogenerated: j.testProperties.Test_options.Tradefed_options, + TestRunnerOptions: j.testProperties.Test_options.Test_runner_options, AutoGenConfig: j.testProperties.Auto_gen_config, UnitTest: j.testProperties.Test_options.Unit_test, DeviceTemplate: "${JavaTestConfigTemplate}", @@ -1416,6 +1421,8 @@ func TestHostFactory() android.Module { nil, nil) + android.InitBazelModule(module) + InitJavaModuleMultiTargets(module, android.HostSupported) return module @@ -1728,6 +1735,14 @@ func metalavaStubCmd(ctx android.ModuleContext, rule *android.RuleBuilder, FlagWithArg("--hide ", "InvalidNullabilityOverride"). FlagWithArg("--hide ", "ChangedDefault") + // Force metalava to ignore classes on the classpath when an API file contains missing classes. + // See b/285140653 for more information. + cmd.FlagWithArg("--api-class-resolution ", "api") + + // Force metalava to sort overloaded methods by their order in the source code. + // See b/285312164 for more information. + cmd.FlagWithArg("--api-overloaded-method-order ", "source") + return cmd } @@ -2798,6 +2813,14 @@ type bp2BuildJavaInfo struct { hasKotlin bool } +// Replaces //a/b/my_xsd_config with //a/b/my_xsd_config-java +func xsdConfigJavaTarget(ctx android.BazelConversionPathContext, mod blueprint.Module) string { + callback := func(xsd android.XsdConfigBp2buildTargets) string { + return xsd.JavaBp2buildTargetName() + } + return android.XsdConfigBp2buildTarget(ctx, mod, callback) +} + // convertLibraryAttrsBp2Build returns a javaCommonAttributes struct with // converted attributes shared across java_* modules and a bp2BuildJavaInfo struct // which has other non-attribute information needed for bp2build conversion @@ -2812,8 +2835,15 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext) for axis, configToProps := range archVariantProps { for config, _props := range configToProps { if archProps, ok := _props.(*CommonProperties); ok { - archSrcs := android.BazelLabelForModuleSrcExcludes(ctx, archProps.Srcs, archProps.Exclude_srcs) + srcsNonXsd, srcsXsd := android.PartitionXsdSrcs(ctx, archProps.Srcs) + excludeSrcsNonXsd, _ := android.PartitionXsdSrcs(ctx, archProps.Exclude_srcs) + archSrcs := android.BazelLabelForModuleSrcExcludes(ctx, srcsNonXsd, excludeSrcsNonXsd) srcs.SetSelectValue(axis, config, archSrcs) + + // Add to static deps + xsdJavaConfigLibraryLabels := android.BazelLabelForModuleDepsWithFn(ctx, srcsXsd, xsdConfigJavaTarget) + staticDeps.Append(xsdJavaConfigLibraryLabels) + } } } @@ -3114,23 +3144,89 @@ func javaBinaryHostBp2Build(ctx android.TopDownMutatorContext, m *Binary) { return } - libName := m.Name() + "_lib" + libInfo := libraryCreationInfo{ + deps: deps, + attrs: commonAttrs, + baseName: m.Name(), + hasKotlin: bp2BuildInfo.hasKotlin, + } + libName := createLibraryTarget(ctx, libInfo) + binAttrs.Runtime_deps.Add(&bazel.LabelAttribute{Value: &bazel.Label{Label: ":" + libName}}) + + // Create the BazelTargetModule. + ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, binAttrs) +} + +type javaTestHostAttributes struct { + *javaCommonAttributes + Deps bazel.LabelListAttribute + Runtime_deps bazel.LabelListAttribute +} + +// javaTestHostBp2Build is for java_test_host bp2build. +func javaTestHostBp2Build(ctx android.TopDownMutatorContext, m *TestHost) { + commonAttrs, bp2BuildInfo := m.convertLibraryAttrsBp2Build(ctx) + depLabels := bp2BuildInfo.DepLabels + + deps := depLabels.Deps + deps.Append(depLabels.StaticDeps) + + var runtimeDeps bazel.LabelListAttribute + attrs := &javaTestHostAttributes{ + Runtime_deps: runtimeDeps, + } + props := bazel.BazelTargetModuleProperties{ + Rule_class: "java_test", + Bzl_load_location: "//build/bazel/rules/java:test.bzl", + } + + if commonAttrs.Srcs.IsEmpty() { + // if there are no sources, then the dependencies can only be used at runtime + attrs.Runtime_deps = deps + attrs.javaCommonAttributes = commonAttrs + ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs) + return + } + + libInfo := libraryCreationInfo{ + deps: deps, + attrs: commonAttrs, + baseName: m.Name(), + hasKotlin: bp2BuildInfo.hasKotlin, + } + libName := createLibraryTarget(ctx, libInfo) + attrs.Runtime_deps.Add(&bazel.LabelAttribute{Value: &bazel.Label{Label: ":" + libName}}) + + // Create the BazelTargetModule. + ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs) +} + +// libraryCreationInfo encapsulates the info needed to create java_library target from +// java_binary_host or java_test_host. +type libraryCreationInfo struct { + deps bazel.LabelListAttribute + attrs *javaCommonAttributes + baseName string + hasKotlin bool +} + +// helper function that creates java_library target from java_binary_host or java_test_host, +// and returns the library target name, +func createLibraryTarget(ctx android.TopDownMutatorContext, libInfo libraryCreationInfo) string { + libName := libInfo.baseName + "_lib" var libProps bazel.BazelTargetModuleProperties - if bp2BuildInfo.hasKotlin { + if libInfo.hasKotlin { libProps = ktJvmLibraryBazelTargetModuleProperties() } else { libProps = javaLibraryBazelTargetModuleProperties() } libAttrs := &javaLibraryAttributes{ - Deps: deps, - javaCommonAttributes: commonAttrs, + Deps: libInfo.deps, + javaCommonAttributes: libInfo.attrs, } ctx.CreateBazelTargetModule(libProps, android.CommonAttributes{Name: libName}, libAttrs) - binAttrs.Runtime_deps.Add(&bazel.LabelAttribute{Value: &bazel.Label{Label: ":" + libName}}) - - // Create the BazelTargetModule. - ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, binAttrs) + return libName } type bazelJavaImportAttributes struct { diff --git a/java/java_test.go b/java/java_test.go index ea89e6eb8..561b187d0 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -2298,3 +2298,58 @@ java_test_host { t.Errorf("Expected args[\"extraConfigs\"] to equal %q, was %q", expected, args["extraConfigs"]) } } + +func TestTestRunnerOptions(t *testing.T) { + result := PrepareForTestWithJavaBuildComponents.RunTestWithBp(t, ` +java_test_host { + name: "foo", + test_options: { + test_runner_options: [ + { + name: "test-timeout", + value: "10m" + } + ] + } +} +`) + + buildOS := result.Config.BuildOS.String() + args := result.ModuleForTests("foo", buildOS+"_common"). + Output("out/soong/.intermediates/foo/" + buildOS + "_common/foo.config").Args + expected := proptools.NinjaAndShellEscape("<option name=\"test-timeout\" value=\"10m\" />\\n ") + if args["extraTestRunnerConfigs"] != expected { + t.Errorf("Expected args[\"extraTestRunnerConfigs\"] to equal %q, was %q", expected, args["extraTestRunnerConfigs"]) + } +} + +func TestJavaExcludeStaticLib(t *testing.T) { + ctx, _ := testJava(t, ` + java_library { + name: "bar", + } + java_library { + name: "foo", + } + java_library { + name: "baz", + static_libs: [ + "foo", + "bar", + ], + exclude_static_libs: [ + "bar", + ], + } + `) + + // "bar" not included as dependency of "baz" + CheckModuleDependencies(t, ctx, "baz", "android_common", []string{ + `core-lambda-stubs`, + `ext`, + `foo`, + `framework`, + `stable-core-platform-api-stubs-system-modules`, + `stable.core.platform.api.stubs`, + }) +} diff --git a/java/sdk.go b/java/sdk.go index 7fa604fdb..7699aabe0 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -151,7 +151,7 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext) systemModules := android.JavaApiLibraryName(ctx.Config(), fmt.Sprintf("core-%s-stubs-system-modules", systemModulesKind)) return sdkDep{ useModule: true, - bootclasspath: []string{module, android.JavaApiLibraryName(ctx.Config(), config.DefaultLambdaStubsLibrary)}, + bootclasspath: []string{module, config.DefaultLambdaStubsLibrary}, systemModules: systemModules, java9Classpath: []string{module}, frameworkResModule: "framework-res", @@ -193,20 +193,20 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext) noFrameworksLibs: true, } case android.SdkPublic, android.SdkSystem, android.SdkTest: - return toModule(sdkVersion.Kind.JavaLibraryName(ctx.Config()), sdkFrameworkAidlPath(ctx)) + return toModule(sdkVersion.Kind.DefaultJavaLibraryName(), sdkFrameworkAidlPath(ctx)) case android.SdkCore: return sdkDep{ useModule: true, - bootclasspath: []string{android.SdkCore.JavaLibraryName(ctx.Config()), android.JavaApiLibraryName(ctx.Config(), config.DefaultLambdaStubsLibrary)}, + bootclasspath: []string{android.SdkCore.DefaultJavaLibraryName(), config.DefaultLambdaStubsLibrary}, systemModules: android.JavaApiLibraryName(ctx.Config(), "core-public-stubs-system-modules"), noFrameworksLibs: true, } case android.SdkModule: // TODO(146757305): provide .apk and .aidl that have more APIs for modules - return toModule(sdkVersion.Kind.JavaLibraryName(ctx.Config()), nonUpdatableFrameworkAidlPath(ctx)) + return toModule(sdkVersion.Kind.DefaultJavaLibraryName(), nonUpdatableFrameworkAidlPath(ctx)) case android.SdkSystemServer: // TODO(146757305): provide .apk and .aidl that have more APIs for modules - return toModule(sdkVersion.Kind.JavaLibraryName(ctx.Config()), sdkFrameworkAidlPath(ctx)) + return toModule(sdkVersion.Kind.DefaultJavaLibraryName(), sdkFrameworkAidlPath(ctx)) default: panic(fmt.Errorf("invalid sdk %q", sdkVersion.Raw)) } @@ -269,9 +269,9 @@ func (sdkSingleton) GenerateBuildActions(ctx android.SingletonContext) { // Create framework.aidl by extracting anything that implements android.os.Parcelable from the SDK stubs modules. func createSdkFrameworkAidl(ctx android.SingletonContext) { stubsModules := []string{ - android.SdkPublic.JavaLibraryName(ctx.Config()), - android.SdkTest.JavaLibraryName(ctx.Config()), - android.SdkSystem.JavaLibraryName(ctx.Config()), + android.SdkPublic.DefaultJavaLibraryName(), + android.SdkTest.DefaultJavaLibraryName(), + android.SdkSystem.DefaultJavaLibraryName(), } combinedAidl := sdkFrameworkAidlPath(ctx) @@ -286,7 +286,7 @@ func createSdkFrameworkAidl(ctx android.SingletonContext) { // Creates a version of framework.aidl for the non-updatable part of the platform. func createNonUpdatableFrameworkAidl(ctx android.SingletonContext) { - stubsModules := []string{android.SdkModule.JavaLibraryName(ctx.Config())} + stubsModules := []string{android.SdkModule.DefaultJavaLibraryName()} combinedAidl := nonUpdatableFrameworkAidlPath(ctx) tempPath := tempPathForRestat(ctx, combinedAidl) |