diff options
Diffstat (limited to 'java/java.go')
| -rw-r--r-- | java/java.go | 68 |
1 files changed, 52 insertions, 16 deletions
diff --git a/java/java.go b/java/java.go index 67b9ba966..91b7cf24b 100644 --- a/java/java.go +++ b/java/java.go @@ -64,6 +64,7 @@ func registerJavaBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType("java_api_library", ApiLibraryFactory) ctx.RegisterModuleType("java_api_contribution", ApiContributionFactory) ctx.RegisterModuleType("java_api_contribution_import", ApiContributionImportFactory) + ctx.RegisterModuleType("java_genrule_combiner", GenruleCombinerFactory) // This mutator registers dependencies on dex2oat for modules that should be // dexpreopted. This is done late when the final variants have been @@ -373,7 +374,7 @@ type JavaInfo struct { ProvidesUsesLibInfo *ProvidesUsesLibInfo - ModuleWithUsesLibraryInfo *ModuleWithUsesLibraryInfo + MissingOptionalUsesLibs []string ModuleWithSdkDepInfo *ModuleWithSdkDepInfo @@ -402,7 +403,12 @@ type JavaInfo struct { BuiltInstalled string - BuiltInstalledForApex []dexpreopterInstall + // ApexSystemServerDexpreoptInstalls stores the list of dexpreopt artifacts if this is a system server + // jar in an apex. + ApexSystemServerDexpreoptInstalls []DexpreopterInstall + + // ApexSystemServerDexJars stores the list of dex jars if this is a system server jar in an apex. + ApexSystemServerDexJars android.Paths // The config is used for two purposes: // - Passing dexpreopt information about libraries from Soong to Make. This is needed when @@ -590,7 +596,7 @@ var ( ) func IsLibDepTag(depTag blueprint.DependencyTag) bool { - return depTag == libTag || depTag == sdkLibTag + return depTag == libTag } func IsStaticLibDepTag(depTag blueprint.DependencyTag) bool { @@ -823,6 +829,8 @@ type Library struct { combinedExportedProguardFlagsFile android.Path InstallMixin func(ctx android.ModuleContext, installPath android.Path) (extraInstallDeps android.InstallPaths) + + apiXmlFile android.WritablePath } var _ android.ApexModule = (*Library)(nil) @@ -1129,7 +1137,8 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { javaInfo.BootDexJarPath = j.bootDexJarPath javaInfo.UncompressDexState = j.uncompressDexState javaInfo.Active = j.active - javaInfo.BuiltInstalledForApex = j.builtInstalledForApex + javaInfo.ApexSystemServerDexpreoptInstalls = j.apexSystemServerDexpreoptInstalls + javaInfo.ApexSystemServerDexJars = j.apexSystemServerDexJars javaInfo.BuiltInstalled = j.builtInstalled javaInfo.ConfigPath = j.configPath javaInfo.OutputProfilePathOnHost = j.outputProfilePathOnHost @@ -1149,6 +1158,8 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { j.javaLibraryModuleInfoJSON(ctx) buildComplianceMetadata(ctx) + + j.createApiXmlFile(ctx) } func (j *Library) javaLibraryModuleInfoJSON(ctx android.ModuleContext) *android.ModuleInfoJSON { @@ -1172,7 +1183,6 @@ func (j *Library) javaLibraryModuleInfoJSON(ctx android.ModuleContext) *android. if j.hideApexVariantFromMake { moduleInfoJSON.Disabled = true - j.dexpreopter.ModuleInfoJSONForApex(ctx) } return moduleInfoJSON } @@ -1184,7 +1194,7 @@ func buildComplianceMetadata(ctx android.ModuleContext) { for _, paths := range ctx.GetOutputFiles().TaggedOutputFiles { builtFiles = append(builtFiles, paths.Strings()...) } - complianceMetadataInfo.SetListValue(android.ComplianceMetadataProp.BUILT_FILES, android.FirstUniqueStrings(builtFiles)) + complianceMetadataInfo.SetListValue(android.ComplianceMetadataProp.BUILT_FILES, android.SortedUniqueStrings(builtFiles)) // Static deps staticDepNames := make([]string, 0) @@ -1197,8 +1207,8 @@ func buildComplianceMetadata(ctx android.ModuleContext) { staticDepFiles = append(staticDepFiles, dep.ResourceJars...) } }) - complianceMetadataInfo.SetListValue(android.ComplianceMetadataProp.STATIC_DEPS, android.FirstUniqueStrings(staticDepNames)) - complianceMetadataInfo.SetListValue(android.ComplianceMetadataProp.STATIC_DEP_FILES, android.FirstUniqueStrings(staticDepFiles.Strings())) + complianceMetadataInfo.SetListValue(android.ComplianceMetadataProp.STATIC_DEPS, android.SortedUniqueStrings(staticDepNames)) + complianceMetadataInfo.SetListValue(android.ComplianceMetadataProp.STATIC_DEP_FILES, android.SortedUniqueStrings(staticDepFiles.Strings())) } func (j *Library) getJarInstallDir(ctx android.ModuleContext) android.InstallPath { @@ -1254,6 +1264,35 @@ func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) { } } +var apiXMLGeneratingApiSurfaces = []android.SdkKind{ + android.SdkPublic, + android.SdkSystem, + android.SdkModule, + android.SdkSystemServer, + android.SdkTest, +} + +func (j *Library) createApiXmlFile(ctx android.ModuleContext) { + if kind, ok := android.JavaLibraryNameToSdkKind(ctx.ModuleName()); ok && android.InList(kind, apiXMLGeneratingApiSurfaces) { + scopePrefix := AllApiScopes.matchingScopeFromSdkKind(kind).apiFilePrefix + j.apiXmlFile = android.PathForModuleOut(ctx, fmt.Sprintf("%sapi.xml", scopePrefix)) + ctx.Build(pctx, android.BuildParams{ + Rule: generateApiXMLRule, + // LOCAL_SOONG_CLASSES_JAR + Input: j.implementationAndResourcesJar, + Output: j.apiXmlFile, + }) + } +} + +var _ android.ModuleMakeVarsProvider = (*Library)(nil) + +func (j *Library) MakeVars(ctx android.MakeVarsModuleContext) { + if j.apiXmlFile != nil { + ctx.DistForGoal("dist_files", j.apiXmlFile) + } +} + const ( aidlIncludeDir = "aidl" javaDir = "java" @@ -1883,8 +1922,8 @@ func (j *Test) generateAndroidBuildActionsWithConfig(ctx android.ModuleContext, dataPath := android.DataPath{SrcPath: data} ctx.InstallTestData(pathInTestCases, []android.DataPath{dataPath}) } - if j.installFile != nil { - ctx.InstallFile(pathInTestCases, ctx.ModuleName()+".jar", j.installFile) + if j.outputFile != nil { + ctx.InstallFile(pathInTestCases, ctx.ModuleName()+".jar", j.outputFile) } } } @@ -3507,7 +3546,6 @@ func DexImportFactory() android.Module { type Defaults struct { android.ModuleBase android.DefaultsModuleBase - android.ApexModuleBase } // java_defaults provides a set of properties that can be inherited by other java or android modules. @@ -3674,11 +3712,11 @@ func addMissingOptionalUsesLibsFromDep(ctx android.ModuleContext, depModule andr usesLibrary *usesLibrary) { dep, ok := android.OtherModuleProvider(ctx, depModule, JavaInfoProvider) - if !ok || dep.ModuleWithUsesLibraryInfo == nil { + if !ok { return } - for _, lib := range dep.ModuleWithUsesLibraryInfo.UsesLibrary.usesLibraryProperties.Missing_optional_uses_libs { + for _, lib := range dep.MissingOptionalUsesLibs { if !android.InList(lib, usesLibrary.usesLibraryProperties.Missing_optional_uses_libs) { usesLibrary.usesLibraryProperties.Missing_optional_uses_libs = append(usesLibrary.usesLibraryProperties.Missing_optional_uses_libs, lib) @@ -3766,9 +3804,7 @@ func setExtraJavaInfo(ctx android.ModuleContext, module android.Module, javaInfo } if mwul, ok := module.(ModuleWithUsesLibrary); ok { - javaInfo.ModuleWithUsesLibraryInfo = &ModuleWithUsesLibraryInfo{ - UsesLibrary: mwul.UsesLibrary(), - } + javaInfo.MissingOptionalUsesLibs = mwul.UsesLibrary().usesLibraryProperties.Missing_optional_uses_libs } if mwsd, ok := module.(moduleWithSdkDep); ok { |