diff options
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 59 |
1 files changed, 33 insertions, 26 deletions
diff --git a/java/java.go b/java/java.go index 9c7f845ac..52f3c11aa 100644 --- a/java/java.go +++ b/java/java.go @@ -184,10 +184,6 @@ type CompilerProperties struct { Output_params []string } - Sysprop struct { - Platform *bool - } `blueprint:"mutated"` - Instrument bool `blueprint:"mutated"` // List of files to include in the META-INF/services folder of the resulting jar. @@ -274,7 +270,8 @@ type CompilerDeviceProperties struct { Proguard_flags_files []string `android:"path"` } - // When targeting 1.9, override the modules to use with --system + // When targeting 1.9 and above, override the modules to use with --system, + // otherwise provides defaults libraries to add to the bootclasspath. System_modules *string UncompressDex bool `blueprint:"mutated"` @@ -290,6 +287,7 @@ type Module struct { android.ModuleBase android.DefaultableModuleBase android.ApexModuleBase + android.SdkBase properties CompilerProperties protoProperties android.ProtoProperties @@ -460,7 +458,10 @@ type checkVendorModuleContext interface { type sdkDep struct { useModule, useFiles, useDefaultLibs, invalidVersion bool - modules []string + modules []string + + // The default system modules to use. Will be an empty string if no system + // modules are to be used. systemModules string frameworkResModule string @@ -499,6 +500,10 @@ func (j *Module) sdkVersion() string { return proptools.StringDefault(j.deviceProperties.Sdk_version, defaultSdkVersion(j)) } +func (j *Module) systemModules() string { + return proptools.String(j.deviceProperties.System_modules) +} + func (j *Module) minSdkVersion() string { if j.deviceProperties.Min_sdk_version != nil { return *j.deviceProperties.Min_sdk_version @@ -531,11 +536,10 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) { ctx.AddVariationDependencies(nil, proguardRaiseTag, config.DefaultLibraries...) } } - } else if j.deviceProperties.System_modules == nil { - ctx.PropertyErrorf("sdk_version", - `system_modules is required to be set when sdk_version is "none", did you mean "core_platform"`) - } else if *j.deviceProperties.System_modules != "none" { - ctx.AddVariationDependencies(nil, systemModulesTag, *j.deviceProperties.System_modules) + } else if sdkDep.systemModules != "" { + // Add the system modules to both the system modules and bootclasspath. + ctx.AddVariationDependencies(nil, systemModulesTag, sdkDep.systemModules) + ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.systemModules) } if ctx.ModuleName() == "android_stubs_current" || ctx.ModuleName() == "android_system_stubs_current" || @@ -581,18 +585,6 @@ func hasSrcExt(srcs []string, ext string) bool { return false } -func shardPaths(paths android.Paths, shardSize int) []android.Paths { - ret := make([]android.Paths, 0, (len(paths)+shardSize-1)/shardSize) - for len(paths) > shardSize { - ret = append(ret, paths[0:shardSize]) - paths = paths[shardSize:] - } - if len(paths) > 0 { - ret = append(ret, paths) - } - return ret -} - func (j *Module) hasSrcExt(ext string) bool { return hasSrcExt(j.properties.Srcs, ext) } @@ -848,6 +840,12 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps { } default: switch tag { + case bootClasspathTag: + // If a system modules dependency has been added to the bootclasspath + // then add its libs to the bootclasspath. + sm := module.(*SystemModules) + deps.bootClasspath = append(deps.bootClasspath, sm.headerJars...) + case systemModulesTag: if deps.systemModules != nil { panic("Found two system module dependencies") @@ -1154,7 +1152,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { shardSize := int(*(j.properties.Javac_shard_size)) var shardSrcs []android.Paths if len(uniqueSrcFiles) > 0 { - shardSrcs = shardPaths(uniqueSrcFiles, shardSize) + shardSrcs = android.ShardPaths(uniqueSrcFiles, shardSize) for idx, shardSrc := range shardSrcs { classes := j.compileJavaClasses(ctx, jarName, idx, shardSrc, nil, flags, extraJarDeps) @@ -1636,6 +1634,7 @@ func LibraryFactory() android.Module { InitJavaModule(module, android.HostAndDeviceSupported) android.InitApexModule(module) + android.InitSdkAwareModule(module) return module } @@ -1682,6 +1681,11 @@ type testProperties struct { // list of files or filegroup modules that provide data that should be installed alongside // the test Data []string `android:"path"` + + // Flag to indicate whether or not to create test config automatically. If AndroidTest.xml + // doesn't exist next to the Android.bp, this attribute doesn't need to be set to true + // explicitly. + Auto_gen_config *bool } type testHelperLibraryProperties struct { @@ -1706,7 +1710,8 @@ type TestHelperLibrary struct { } func (j *Test) GenerateAndroidBuildActions(ctx android.ModuleContext) { - j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template, j.testProperties.Test_suites) + j.testConfig = tradefed.AutoGenJavaTestConfig(ctx, j.testProperties.Test_config, j.testProperties.Test_config_template, + j.testProperties.Test_suites, j.testProperties.Auto_gen_config) j.data = android.PathsForModuleSrc(ctx, j.testProperties.Data) j.Library.GenerateAndroidBuildActions(ctx) @@ -1798,7 +1803,7 @@ type Binary struct { isWrapperVariant bool wrapperFile android.Path - binaryFile android.OutputPath + binaryFile android.InstallPath } func (j *Binary) HostToolPath() android.OptionalPath { @@ -1916,6 +1921,7 @@ type Import struct { android.DefaultableModuleBase android.ApexModuleBase prebuilt android.Prebuilt + android.SdkBase properties ImportProperties @@ -2072,6 +2078,7 @@ func ImportFactory() android.Module { android.InitPrebuiltModule(module, &module.properties.Jars) InitJavaModule(module, android.HostAndDeviceSupported) android.InitApexModule(module) + android.InitSdkAwareModule(module) return module } |