diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/androidmk.go | 5 | ||||
-rwxr-xr-x | java/app.go | 2 | ||||
-rw-r--r-- | java/dexpreopt_bootjars.go | 25 | ||||
-rw-r--r-- | java/dexpreopt_config.go | 3 | ||||
-rw-r--r-- | java/platform_compat_config.go | 49 | ||||
-rw-r--r-- | java/sdk.go | 10 | ||||
-rw-r--r-- | java/sdk_library.go | 90 | ||||
-rw-r--r-- | java/testing.go | 3 |
8 files changed, 135 insertions, 52 deletions
diff --git a/java/androidmk.go b/java/androidmk.go index 11fea82d6..04bf15cf4 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -141,6 +141,9 @@ func (j *Test) AndroidMkEntries() []android.AndroidMkEntries { entries.SetPath("LOCAL_FULL_TEST_CONFIG", j.testConfig) } androidMkWriteTestData(j.data, entries) + if !BoolDefault(j.testProperties.Auto_gen_config, true) { + entries.SetString("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", "true") + } }) return entriesList @@ -613,7 +616,7 @@ func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries { fmt.Fprintln(w, dstubs.Name()+"-check-last-released-api:", dstubs.checkLastReleasedApiTimestamp.String()) - if dstubs.Name() == "api-stubs-docs" || dstubs.Name() == "system-api-stubs-docs" { + if dstubs.Name() != "android.car-system-stubs-docs" { fmt.Fprintln(w, ".PHONY: checkapi") fmt.Fprintln(w, "checkapi:", dstubs.checkLastReleasedApiTimestamp.String()) diff --git a/java/app.go b/java/app.go index 94f6bb10a..2933ccb4c 100755 --- a/java/app.go +++ b/java/app.go @@ -897,7 +897,7 @@ func (a *AndroidAppImport) processVariants(ctx android.LoadHookContext) { MergePropertiesFromVariant(ctx, &a.properties, archProps, archType.Name) } -func MergePropertiesFromVariant(ctx android.BaseModuleContext, +func MergePropertiesFromVariant(ctx android.EarlyModuleContext, dst interface{}, variantGroup reflect.Value, variant string) { src := variantGroup.FieldByName(proptools.FieldNameForProperty(variant)) if !src.IsValid() { diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index 88e3bc2b3..fe5bed501 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -327,7 +327,7 @@ func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage, invocationPath := outputPath.ReplaceExtension(ctx, "invocation") - cmd.Tool(global.Tools.Dex2oat). + cmd.Tool(global.SoongConfig.Dex2oat). Flag("--avoid-storing-invocation"). FlagWithOutput("--write-invocation-to=", invocationPath).ImplicitOutput(invocationPath). Flag("--runtime-arg").FlagWithArg("-Xms", global.Dex2oatImageXms). @@ -436,7 +436,6 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missin return nil } profile := ctx.Config().Once(bootImageProfileRuleKey, func() interface{} { - tools := global.Tools defaultProfile := "frameworks/base/config/boot-image-profile.txt" rule := android.NewRuleBuilder() @@ -462,7 +461,7 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missin rule.Command(). Text(`ANDROID_LOG_TAGS="*:e"`). - Tool(tools.Profman). + Tool(global.SoongConfig.Profman). FlagWithInput("--create-profile-from=", bootImageProfile). FlagForEachInput("--apk=", image.dexPathsDeps.Paths()). FlagForEachArg("--dex-location=", image.dexLocationsDeps). @@ -491,8 +490,6 @@ func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImage, mi return nil } return ctx.Config().Once(bootFrameworkProfileRuleKey, func() interface{} { - tools := global.Tools - rule := android.NewRuleBuilder() rule.MissingDeps(missingDeps) @@ -513,7 +510,7 @@ func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImage, mi rule.Command(). Text(`ANDROID_LOG_TAGS="*:e"`). - Tool(tools.Profman). + Tool(global.SoongConfig.Profman). Flag("--generate-boot-profile"). FlagWithInput("--create-profile-from=", bootFrameworkProfile). FlagForEachInput("--apk=", image.dexPathsDeps.Paths()). @@ -590,6 +587,7 @@ func writeGlobalConfigForMake(ctx android.SingletonContext, path android.Writabl func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) { if d.dexpreoptConfigForMake != nil { ctx.Strict("DEX_PREOPT_CONFIG_FOR_MAKE", d.dexpreoptConfigForMake.String()) + ctx.Strict("DEX_PREOPT_SOONG_CONFIG_FOR_MAKE", android.PathForOutput(ctx, "dexpreopt_soong.config").String()) } image := d.defaultBootImage @@ -597,7 +595,6 @@ func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) { ctx.Strict("DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED", image.profileInstalls.String()) ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_FILES", strings.Join(image.dexPathsDeps.Strings(), " ")) ctx.Strict("DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS", strings.Join(image.dexLocationsDeps, " ")) - ctx.Strict("DEXPREOPT_IMAGE_LOCATIONS", strings.Join(image.imageLocations, ":")) var imageNames []string for _, current := range append(d.otherImages, image) { @@ -610,15 +607,15 @@ func (d *dexpreoptBootJars) MakeVars(ctx android.MakeVarsContext) { sort.Slice(arches, func(i, j int) bool { return arches[i].String() < arches[j].String() }) for _, arch := range arches { - ctx.Strict("DEXPREOPT_IMAGE_VDEX_BUILT_INSTALLED_"+current.name+"_"+arch.String(), current.vdexInstalls[arch].String()) - ctx.Strict("DEXPREOPT_IMAGE_"+current.name+"_"+arch.String(), current.images[arch].String()) - ctx.Strict("DEXPREOPT_IMAGE_DEPS_"+current.name+"_"+arch.String(), strings.Join(current.imagesDeps[arch].Strings(), " ")) - ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+current.name+"_"+arch.String(), current.installs[arch].String()) - ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+current.name+"_"+arch.String(), current.unstrippedInstalls[arch].String()) - if current.zip != nil { - } + sfx := current.name + "_" + arch.String() + ctx.Strict("DEXPREOPT_IMAGE_VDEX_BUILT_INSTALLED_"+sfx, current.vdexInstalls[arch].String()) + ctx.Strict("DEXPREOPT_IMAGE_"+sfx, current.images[arch].String()) + ctx.Strict("DEXPREOPT_IMAGE_DEPS_"+sfx, strings.Join(current.imagesDeps[arch].Strings(), " ")) + ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+sfx, current.installs[arch].String()) + ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+sfx, current.unstrippedInstalls[arch].String()) } + ctx.Strict("DEXPREOPT_IMAGE_LOCATIONS_"+current.name, strings.Join(current.imageLocations, ":")) ctx.Strict("DEXPREOPT_IMAGE_ZIP_"+current.name, current.zip.String()) } ctx.Strict("DEXPREOPT_IMAGE_NAMES", strings.Join(imageNames, " ")) diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go index 76bda612e..35748b8d1 100644 --- a/java/dexpreopt_config.go +++ b/java/dexpreopt_config.go @@ -37,8 +37,9 @@ type globalConfigAndRaw struct { func dexpreoptGlobalConfigRaw(ctx android.PathContext) globalConfigAndRaw { return ctx.Config().Once(dexpreoptGlobalConfigKey, func() interface{} { if f := ctx.Config().DexpreoptGlobalConfig(); f != "" { + soongConfig := dexpreopt.CreateGlobalSoongConfig(ctx) ctx.AddNinjaFileDeps(f) - globalConfig, data, err := dexpreopt.LoadGlobalConfig(ctx, f) + globalConfig, data, err := dexpreopt.LoadGlobalConfig(ctx, f, soongConfig) if err != nil { panic(err) } diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go index fefd0e64b..715485fd5 100644 --- a/java/platform_compat_config.go +++ b/java/platform_compat_config.go @@ -19,9 +19,14 @@ import ( ) func init() { + android.RegisterSingletonType("platform_compat_config_singleton", platformCompatConfigSingletonFactory) android.RegisterModuleType("platform_compat_config", platformCompatConfigFactory) } +type platformCompatConfigSingleton struct { + metadata android.Path +} + type platformCompatConfigProperties struct { Src *string `android:"path"` } @@ -35,6 +40,46 @@ type platformCompatConfig struct { metadataFile android.OutputPath } +func (p *platformCompatConfig) compatConfigMetadata() android.OutputPath { + return p.metadataFile +} + +type platformCompatConfigIntf interface { + compatConfigMetadata() android.OutputPath +} + +var _ platformCompatConfigIntf = (*platformCompatConfig)(nil) + +// compat singleton rules +func (p *platformCompatConfigSingleton) GenerateBuildActions(ctx android.SingletonContext) { + + var compatConfigMetadata android.Paths + + ctx.VisitAllModules(func(module android.Module) { + if c, ok := module.(platformCompatConfigIntf); ok { + metadata := c.compatConfigMetadata() + compatConfigMetadata = append(compatConfigMetadata, metadata) + } + }) + + if compatConfigMetadata == nil { + // nothing to do. + return + } + + rule := android.NewRuleBuilder() + outputPath := android.PathForOutput(ctx, "compat_config", "merged_compat_config.xml") + + rule.Command(). + BuiltTool(ctx, "process-compat-config"). + FlagForEachInput("--xml ", compatConfigMetadata). + FlagWithOutput("--merged-config ", outputPath) + + rule.Build(pctx, ctx, "merged-compat-config", "Merge compat config") + + p.metadata = outputPath +} + func (p *platformCompatConfig) GenerateAndroidBuildActions(ctx android.ModuleContext) { rule := android.NewRuleBuilder() @@ -69,6 +114,10 @@ func (p *platformCompatConfig) AndroidMkEntries() []android.AndroidMkEntries { }} } +func platformCompatConfigSingletonFactory() android.Singleton { + return &platformCompatConfigSingleton{} +} + func platformCompatConfigFactory() android.Module { module := &platformCompatConfig{} module.AddProperties(&module.properties) diff --git a/java/sdk.go b/java/sdk.go index 6f0f432b3..66eb284ba 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -58,7 +58,7 @@ func sdkVersionOrDefault(ctx android.BaseModuleContext, v string) string { // Returns a sdk version as a number. For modules targeting an unreleased SDK (meaning it does not yet have a number) // it returns android.FutureApiLevel (10000). -func sdkVersionToNumber(ctx android.BaseModuleContext, v string) (int, error) { +func sdkVersionToNumber(ctx android.EarlyModuleContext, v string) (int, error) { switch v { case "", "none", "current", "test_current", "system_current", "core_current", "core_platform": return ctx.Config().DefaultAppTargetSdkInt(), nil @@ -72,7 +72,7 @@ func sdkVersionToNumber(ctx android.BaseModuleContext, v string) (int, error) { } } -func sdkVersionToNumberAsString(ctx android.BaseModuleContext, v string) (string, error) { +func sdkVersionToNumberAsString(ctx android.EarlyModuleContext, v string) (string, error) { n, err := sdkVersionToNumber(ctx, v) if err != nil { return "", err @@ -80,7 +80,7 @@ func sdkVersionToNumberAsString(ctx android.BaseModuleContext, v string) (string return strconv.Itoa(n), nil } -func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep { +func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep { v := sdkContext.sdkVersion() // For PDK builds, use the latest SDK version instead of "current" @@ -127,12 +127,12 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep { } if !jarPath.Valid() { - ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", v, jar) + ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", sdk, jar) return sdkDep{} } if !aidlPath.Valid() { - ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", v, aidl) + ctx.PropertyErrorf("sdk_version", "invalid sdk version %q, %q does not exist", sdk, aidl) return sdkDep{} } diff --git a/java/sdk_library.go b/java/sdk_library.go index 2cb8f728d..9b30e2ca4 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -97,12 +97,22 @@ type sdkLibraryProperties struct { // List of Java libraries that will be in the classpath when building stubs Stub_only_libs []string `android:"arch_variant"` - // list of package names that will be documented and publicized as API + // list of package names that will be documented and publicized as API. + // This allows the API to be restricted to a subset of the source files provided. + // If this is unspecified then all the source files will be treated as being part + // of the API. Api_packages []string // list of package names that must be hidden from the API Hidden_api_packages []string + // the relative path to the directory containing the api specification files. + // Defaults to "api". + Api_dir *string + + // If set to true there is no runtime library. + Api_only *bool + // local files that are used within user customized droiddoc options. Droiddoc_option_files []string @@ -176,7 +186,10 @@ func (module *SdkLibrary) DepsMutator(ctx android.BottomUpMutatorContext) { } func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) { - module.Library.GenerateAndroidBuildActions(ctx) + // Don't build an implementation library if this is api only. + if !proptools.Bool(module.sdkLibraryProperties.Api_only) { + module.Library.GenerateAndroidBuildActions(ctx) + } module.buildPermissionsFile(ctx) @@ -240,6 +253,9 @@ func (module *SdkLibrary) OutputFiles(tag string) (android.Paths, error) { } func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries { + if proptools.Bool(module.sdkLibraryProperties.Api_only) { + return nil + } entriesList := module.Library.AndroidMkEntries() entries := &entriesList[0] entries.Required = append(entries.Required, module.xmlFileName()) @@ -358,7 +374,7 @@ func (module *SdkLibrary) xmlFileName() string { // SDK version that the stubs library is built against. Note that this is always // *current. Older stubs library built with a numberd SDK version is created from // the prebuilt jar. -func (module *SdkLibrary) sdkVersion(apiScope apiScope) string { +func (module *SdkLibrary) sdkVersionForScope(apiScope apiScope) string { switch apiScope { case apiScopePublic: return "current" @@ -371,6 +387,18 @@ func (module *SdkLibrary) sdkVersion(apiScope apiScope) string { } } +// Get the sdk version for use when compiling the stubs library. +func (module *SdkLibrary) sdkVersionForStubsLibrary(mctx android.LoadHookContext, apiScope apiScope) string { + sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library)) + if sdkDep.hasStandardLibs() { + // If building against a standard sdk then use the sdk version appropriate for the scope. + return module.sdkVersionForScope(apiScope) + } else { + // Otherwise, use no system module. + return "none" + } +} + // $(INTERNAL_PLATFORM_<apiTagName>_API_FILE) points to the generated // api file for the current source // TODO: remove this when apicheck is done in soong @@ -418,14 +446,15 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.LoadHookContext, apiSc props := struct { Name *string Srcs []string + Installable *bool Sdk_version *string + System_modules *string Libs []string Soc_specific *bool Device_specific *bool Product_specific *bool System_ext_specific *bool Compile_dex *bool - System_modules *string Java_version *string Product_variables struct { Unbundled_build struct { @@ -441,23 +470,19 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.LoadHookContext, apiSc } }{} - sdkVersion := module.sdkVersion(apiScope) - sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library)) - if !sdkDep.hasStandardLibs() { - sdkVersion = "none" - } - props.Name = proptools.StringPtr(module.stubsName(apiScope)) // sources are generated from the droiddoc props.Srcs = []string{":" + module.docsName(apiScope)} + sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope) props.Sdk_version = proptools.StringPtr(sdkVersion) + props.System_modules = module.Library.Module.deviceProperties.System_modules + props.Installable = proptools.BoolPtr(false) props.Libs = module.sdkLibraryProperties.Stub_only_libs // Unbundled apps will use the prebult one from /prebuilts/sdk if mctx.Config().UnbundledBuildUsePrebuiltSdks() { props.Product_variables.Unbundled_build.Enabled = proptools.BoolPtr(false) } props.Product_variables.Pdk.Enabled = proptools.BoolPtr(false) - props.System_modules = module.Library.Module.deviceProperties.System_modules props.Openjdk9.Srcs = module.Library.Module.properties.Openjdk9.Srcs props.Openjdk9.Javacflags = module.Library.Module.properties.Openjdk9.Javacflags props.Java_version = module.Library.Module.properties.Java_version @@ -486,6 +511,7 @@ func (module *SdkLibrary) createStubsSources(mctx android.LoadHookContext, apiSc Srcs []string Installable *bool Sdk_version *string + System_modules *string Libs []string Arg_files []string Args *string @@ -507,6 +533,8 @@ func (module *SdkLibrary) createStubsSources(mctx android.LoadHookContext, apiSc }{} sdkDep := decodeSdkDep(mctx, sdkContext(&module.Library)) + // Use the platform API if standard libraries were requested, otherwise use + // no default libraries. sdkVersion := "" if !sdkDep.hasStandardLibs() { sdkVersion = "none" @@ -515,6 +543,7 @@ func (module *SdkLibrary) createStubsSources(mctx android.LoadHookContext, apiSc props.Name = proptools.StringPtr(module.docsName(apiScope)) props.Srcs = append(props.Srcs, module.Library.Module.properties.Srcs...) props.Sdk_version = proptools.StringPtr(sdkVersion) + props.System_modules = module.Library.Module.deviceProperties.System_modules props.Installable = proptools.BoolPtr(false) // A droiddoc module has only one Libs property and doesn't distinguish between // shared libs and static libs. So we need to add both of these libs to Libs property. @@ -571,8 +600,9 @@ func (module *SdkLibrary) createStubsSources(mctx android.LoadHookContext, apiSc currentApiFileName = "test-" + currentApiFileName removedApiFileName = "test-" + removedApiFileName } - currentApiFileName = path.Join("api", currentApiFileName) - removedApiFileName = path.Join("api", removedApiFileName) + apiDir := module.getApiDir() + currentApiFileName = path.Join(apiDir, currentApiFileName) + removedApiFileName = path.Join(apiDir, removedApiFileName) // TODO(jiyong): remove these three props props.Api_tag_name = proptools.StringPtr(module.apiTagName(apiScope)) props.Api_filename = proptools.StringPtr(currentApiFileName) @@ -637,7 +667,11 @@ func (module *SdkLibrary) PrebuiltJars(ctx android.BaseModuleContext, sdkVersion jar := filepath.Join(dir, module.BaseModuleName()+".jar") jarPath := android.ExistentPathForSource(ctx, jar) if !jarPath.Valid() { - ctx.PropertyErrorf("sdk_library", "invalid sdk version %q, %q does not exist", v, jar) + if ctx.Config().AllowMissingDependencies() { + return android.Paths{android.PathForSource(ctx, jar)} + } else { + ctx.PropertyErrorf("sdk_library", "invalid sdk version %q, %q does not exist", sdkVersion, jar) + } return nil } return android.Paths{jarPath.Path()} @@ -687,6 +721,10 @@ func javaSdkLibraries(config android.Config) *[]string { }).(*[]string) } +func (module *SdkLibrary) getApiDir() string { + return proptools.StringDefault(module.sdkLibraryProperties.Api_dir, "api") +} + // For a java_sdk_library module, create internal modules for stubs, docs, // runtime libs and xml file. If requested, the stubs and docs are created twice // once for public API level and once for system API level @@ -696,11 +734,6 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.LoadHookContext) { return } - if len(module.sdkLibraryProperties.Api_packages) == 0 { - mctx.PropertyErrorf("api_packages", "java_sdk_library must specify api_packages") - return - } - // If this builds against standard libraries (i.e. is not part of the core libraries) // then assume it provides both system and test apis. Otherwise, assume it does not and // also assume it does not contribute to the dist build. @@ -716,9 +749,10 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.LoadHookContext) { missing_current_api := false + apiDir := module.getApiDir() for _, scope := range scopes { for _, api := range []string{"current.txt", "removed.txt"} { - path := path.Join(mctx.ModuleDir(), "api", scope+api) + path := path.Join(mctx.ModuleDir(), apiDir, scope+api) p := android.ExistentPathForSource(mctx, path) if !p.Valid() { mctx.ModuleErrorf("Current api file %#v doesn't exist", path) @@ -738,7 +772,7 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.LoadHookContext) { mctx.ModuleErrorf("One or more current api files are missing. "+ "You can update them by:\n"+ "%s %q %s && m update-api", - script, mctx.ModuleDir(), strings.Join(scopes, " ")) + script, filepath.Join(mctx.ModuleDir(), apiDir), strings.Join(scopes, " ")) return } @@ -754,16 +788,18 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.LoadHookContext) { // for test API stubs module.createStubsLibrary(mctx, apiScopeTest) module.createStubsSources(mctx, apiScopeTest) + } + if !proptools.Bool(module.sdkLibraryProperties.Api_only) { // for runtime module.createXmlFile(mctx) - } - // record java_sdk_library modules so that they are exported to make - javaSdkLibraries := javaSdkLibraries(mctx.Config()) - javaSdkLibrariesLock.Lock() - defer javaSdkLibrariesLock.Unlock() - *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName()) + // record java_sdk_library modules so that they are exported to make + javaSdkLibraries := javaSdkLibraries(mctx.Config()) + javaSdkLibrariesLock.Lock() + defer javaSdkLibrariesLock.Unlock() + *javaSdkLibraries = append(*javaSdkLibraries, module.BaseModuleName()) + } } func (module *SdkLibrary) InitSdkLibraryProperties() { diff --git a/java/testing.go b/java/testing.go index ab3af6576..08bae4407 100644 --- a/java/testing.go +++ b/java/testing.go @@ -205,9 +205,6 @@ func GatherRequiredDepsForTest() string { systemModules := []string{ "core-current-stubs-system-modules", "core-platform-api-stubs-system-modules", - "android_stubs_current_system_modules", - "android_system_stubs_current_system_modules", - "android_test_stubs_current_system_modules", } for _, extra := range systemModules { |