aboutsummaryrefslogtreecommitdiff
path: root/java/sdk_library_internal.go
diff options
context:
space:
mode:
authormosimchah <mosimchah@gmail.com>2025-12-02 09:27:38 -0500
committermosimchah <mosimchah@gmail.com>2025-12-02 09:27:38 -0500
commitc7bade461dc55726f62997d13a48582f7c4b4655 (patch)
treeea0588da76060a2038f54f67efd046ca77634b10 /java/sdk_library_internal.go
parent0f5414d19317805e8bbbe7c4db5f0fd78769bad5 (diff)
parent89d78cff8b00d3b20a90074635c3fe5a2ee49474 (diff)
Merge branch 'lineage-23.1' of https://github.com/LineageOS/android_build_soong into HEADw16.1
* 'lineage-23.1' of https://github.com/LineageOS/android_build_soong: (528 commits) Revert "install_symlink: Make symlink target configurable" Reapply "Clear as much of cc.Module as possible after GenerateBuildActions" Revert "rust: config: Fix missing CPU variant LD flags in Rust" Rename build-flag in outdir Revert^4 "cipd: Default CIPD proxy server to on, add opt-out" Convert check-vintf-all to phony with actions Create a partial implementation of check-vintf-all for soong-only Configure RBE rust pool based on build variant Revert^3 "Add sdk version check to arr" Add jdk.internal.invoke to the allowlist Make droid always depend on symbols zip Import Device and Odm skus Don't install gob_gen in Soong Remove bazel reference from run_integration_tests.sh Fix bootstrap_test.sh Don't panic in aconfig libraries when AllowMissingDependencies is set Avoid returning nil paths from PathForModuleSrc Revert "Flag controled clang version" Rework module target dependencies on required deps Revert^2 "Add sdk version check to arr" ... Change-Id: I6e9a63fa14fda917a42e426e5dcebbad7f67e1de
Diffstat (limited to 'java/sdk_library_internal.go')
-rw-r--r--java/sdk_library_internal.go40
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