diff options
Diffstat (limited to 'java/sdk_library_internal.go')
| -rw-r--r-- | java/sdk_library_internal.go | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/java/sdk_library_internal.go b/java/sdk_library_internal.go index f5feabeb4..2d27c42f6 100644 --- a/java/sdk_library_internal.go +++ b/java/sdk_library_internal.go @@ -20,7 +20,9 @@ import ( "strings" "android/soong/android" + "android/soong/dexpreopt" "android/soong/etc" + "android/soong/java/config" "github.com/google/blueprint/proptools" ) @@ -168,6 +170,7 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) &module.dexpreoptProperties, &module.linter.properties, &module.overridableProperties, + &module.usesLibrary.usesLibraryProperties, &props, module.sdkComponentPropertiesForChildLibrary(), } @@ -581,7 +584,9 @@ func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) { Min_device_sdk *string Max_device_sdk *string Sdk_library_min_api_level *string - Uses_libs_dependencies proptools.Configurable[[]string] + Uses_libs proptools.Configurable[[]string] + Libs []string + Impl_only_libs []string }{ Name: proptools.StringPtr(module.xmlPermissionsModuleName()), Enabled: module.EnabledProperty(), @@ -592,7 +597,9 @@ func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) { Min_device_sdk: module.commonSdkLibraryProperties.Min_device_sdk, Max_device_sdk: module.commonSdkLibraryProperties.Max_device_sdk, Sdk_library_min_api_level: &moduleMinApiLevelStr, - Uses_libs_dependencies: module.usesLibraryProperties.Uses_libs.Clone(), + Uses_libs: module.usesLibraryProperties.Uses_libs.Clone(), + Libs: android.RemoveListFromList(module.properties.Libs, config.FrameworkLibraries), + Impl_only_libs: module.sdkLibraryProperties.Impl_only_libs, } mctx.CreateModule(sdkLibraryXmlFactory, &props) @@ -716,6 +723,8 @@ type sdkLibraryXml struct { installDirPath android.InstallPath hideApexVariantFromMake bool + + usesLibrary } type sdkLibraryXmlProperties struct { @@ -754,10 +763,11 @@ type sdkLibraryXmlProperties struct { // This value comes from the ApiLevel of the MinSdkVersion property. Sdk_library_min_api_level *string - // Uses-libs dependencies that the shared library requires to work correctly. - // - // This will add dependency="foo:bar" to the <library> section. - Uses_libs_dependencies proptools.Configurable[[]string] + // List of java libraries that will be in the classpath. + Libs []string `android:"arch_variant"` + + // List of Java libraries that will be in the classpath when building the implementation lib. + Impl_only_libs []string `android:"arch_variant"` } // java_sdk_library_xml builds the permission xml file for a java_sdk_library. @@ -765,7 +775,7 @@ type sdkLibraryXmlProperties struct { func sdkLibraryXmlFactory() android.Module { module := &sdkLibraryXml{} - module.AddProperties(&module.properties) + module.AddProperties(&module.properties, &module.usesLibrary.usesLibraryProperties) android.InitApexModule(module) android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon) @@ -801,7 +811,10 @@ func (module *sdkLibraryXml) ApexAvailableFor() []string { } func (module *sdkLibraryXml) DepsMutator(ctx android.BottomUpMutatorContext) { - // do nothing + module.usesLibrary.deps(ctx, false) + libDeps := ctx.AddVariationDependencies(nil, usesLibStagingTag, module.properties.Libs...) + libDeps = append(libDeps, ctx.AddVariationDependencies(nil, usesLibStagingTag, module.properties.Impl_only_libs...)...) + module.usesLibrary.depsFromLibs(ctx, libDeps) } var _ android.ApexModule = (*sdkLibraryXml)(nil) @@ -865,8 +878,13 @@ func formattedOptionalAttribute(attrName string, value *string) string { return fmt.Sprintf(" %s=\"%s\"\n", attrName, *value) } -func formattedDependenciesAttribute(dependencies []string) string { - if dependencies == nil { +func (module *sdkLibraryXml) formattedDependenciesAttribute(ctx android.ModuleContext) string { + classLoaderContexts := module.usesLibrary.classLoaderContextForUsesLibDeps(ctx) + dependencies := make([]string, 0, len(classLoaderContexts[dexpreopt.AnySdkVersion])) + for _, dep := range classLoaderContexts[dexpreopt.AnySdkVersion] { + dependencies = append(dependencies, dep.Name) + } + if len(dependencies) == 0 { return "" } return fmt.Sprintf(" dependency=\"%s\"\n", strings.Join(dependencies, ":")) @@ -881,7 +899,7 @@ func (module *sdkLibraryXml) permissionsContents(ctx android.ModuleContext) stri implicitUntilAttr := formattedOptionalSdkLevelAttribute(ctx, "on-bootclasspath-before", module.properties.On_bootclasspath_before) minSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "min-device-sdk", module.properties.Min_device_sdk) maxSdkAttr := formattedOptionalSdkLevelAttribute(ctx, "max-device-sdk", module.properties.Max_device_sdk) - dependenciesAttr := formattedDependenciesAttribute(module.properties.Uses_libs_dependencies.GetOrDefault(ctx, nil)) + dependenciesAttr := module.formattedDependenciesAttribute(ctx) // <library> is understood in all android versions whereas <apex-library> is only understood from API T (and ignored before that). // similarly, min_device_sdk is only understood from T. So if a library is using that, we need to use the apex-library to make sure this library is not loaded before T var libraryTag string |
