diff options
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/java/java.go b/java/java.go index 275abbe35..3b0ad8d9f 100644 --- a/java/java.go +++ b/java/java.go @@ -876,7 +876,6 @@ func LibraryFactory() android.Module { module.initModuleAndImport(module) android.InitApexModule(module) - android.InitSdkAwareModule(module) android.InitBazelModule(module) InitJavaModule(module, android.HostAndDeviceSupported) return module @@ -899,7 +898,6 @@ func LibraryHostFactory() android.Module { module.Module.properties.Installable = proptools.BoolPtr(true) android.InitApexModule(module) - android.InitSdkAwareModule(module) android.InitBazelModule(module) InitJavaModule(module, android.HostSupported) return module @@ -915,6 +913,10 @@ type TestOptions struct { // a list of extra test configuration files that should be installed with the module. Extra_test_configs []string `android:"path,arch_variant"` + + // Extra <option> tags to add to the auto generated test xml file. The "key" + // is optional in each of these. + Tradefed_options []tradefed.Option } type testProperties struct { @@ -1192,9 +1194,18 @@ func (j *Test) generateAndroidBuildActionsWithConfig(ctx android.ModuleContext, defaultUnitTest := !inList("tradefed", j.properties.Libs) && !inList("cts", j.testProperties.Test_suites) j.testProperties.Test_options.Unit_test = proptools.BoolPtr(defaultUnitTest) } - - j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template, - j.testProperties.Test_suites, configs, j.testProperties.Auto_gen_config, j.testProperties.Test_options.Unit_test) + j.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{ + TestConfigProp: j.testProperties.Test_config, + TestConfigTemplateProp: j.testProperties.Test_config_template, + TestSuites: j.testProperties.Test_suites, + Config: configs, + OptionsForAutogenerated: j.testProperties.Test_options.Tradefed_options, + AutoGenConfig: j.testProperties.Auto_gen_config, + UnitTest: j.testProperties.Test_options.Unit_test, + DeviceTemplate: "${JavaTestConfigTemplate}", + HostTemplate: "${JavaHostTestConfigTemplate}", + HostUnitTestTemplate: "${JavaHostUnitTestConfigTemplate}", + }) j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data) @@ -1239,8 +1250,13 @@ func (j *TestHelperLibrary) GenerateAndroidBuildActions(ctx android.ModuleContex } func (j *JavaTestImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { - j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.prebuiltTestProperties.Test_config, nil, - j.prebuiltTestProperties.Test_suites, nil, nil, nil) + j.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{ + TestConfigProp: j.prebuiltTestProperties.Test_config, + TestSuites: j.prebuiltTestProperties.Test_suites, + DeviceTemplate: "${JavaTestConfigTemplate}", + HostTemplate: "${JavaHostTestConfigTemplate}", + HostUnitTestTemplate: "${JavaHostUnitTestConfigTemplate}", + }) j.Import.GenerateAndroidBuildActions(ctx) } @@ -1322,7 +1338,6 @@ func TestFactory() android.Module { module.Module.dexpreopter.isTest = true module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true) - android.InitSdkAwareModule(module) InitJavaModule(module, android.HostAndDeviceSupported) return module } @@ -1361,7 +1376,6 @@ func JavaTestImportFactory() android.Module { android.InitPrebuiltModule(module, &module.properties.Jars) android.InitApexModule(module) - android.InitSdkAwareModule(module) InitJavaModule(module, android.HostAndDeviceSupported) return module } @@ -1784,7 +1798,6 @@ type Import struct { android.ApexModuleBase android.BazelModuleBase prebuilt android.Prebuilt - android.SdkBase // Functionality common to Module and Import. embeddableInModuleAndImport @@ -2158,7 +2171,6 @@ func ImportFactory() android.Module { android.InitPrebuiltModule(module, &module.properties.Jars) android.InitApexModule(module) - android.InitSdkAwareModule(module) android.InitBazelModule(module) InitJavaModule(module, android.HostAndDeviceSupported) return module @@ -2663,7 +2675,7 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext) if m.properties.Libs != nil { // TODO 244210934 ALIX Check if this else statement breaks presubmits get rid of it if it doesn't - if strings.HasPrefix(ctx.ModuleType(), "java_binary") || strings.HasPrefix(ctx.ModuleType(), "java_library") { + if strings.HasPrefix(ctx.ModuleType(), "java_binary") || strings.HasPrefix(ctx.ModuleType(), "java_library") || ctx.ModuleType() == "android_library" { for _, d := range m.properties.Libs { neverlinkLabel := android.BazelLabelForModuleDepSingle(ctx, d) neverlinkLabel.Label = neverlinkLabel.Label + "-neverlink" @@ -2738,14 +2750,6 @@ func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) { Rule_class: "java_library", Bzl_load_location: "//build/bazel/rules/java:library.bzl", } - - ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs) - neverlinkProp := true - neverLinkAttrs := &javaLibraryAttributes{ - Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}), - Neverlink: bazel.BoolAttribute{Value: &neverlinkProp}, - } - ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name + "-neverlink"}, neverLinkAttrs) } else { attrs.Common_srcs = bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, m.properties.Common_srcs)) @@ -2753,10 +2757,16 @@ func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) { Rule_class: "kt_jvm_library", Bzl_load_location: "@rules_kotlin//kotlin:jvm_library.bzl", } - // TODO (b/244210934): create neverlink-duplicate target once kt_jvm_library supports neverlink attribute - ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs) } + ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs) + neverlinkProp := true + neverLinkAttrs := &javaLibraryAttributes{ + Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}), + Neverlink: bazel.BoolAttribute{Value: &neverlinkProp}, + } + ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name + "-neverlink"}, neverLinkAttrs) + } type javaBinaryHostAttributes struct { |