summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go73
1 files changed, 71 insertions, 2 deletions
diff --git a/java/java.go b/java/java.go
index cd249edad..1a266b859 100644
--- a/java/java.go
+++ b/java/java.go
@@ -87,6 +87,14 @@ func RegisterJavaSdkMemberTypes() {
android.RegisterSdkMemberType(javaTestSdkMemberType)
}
+type StubsLinkType int
+
+const (
+ Unknown StubsLinkType = iota
+ Stubs
+ Implementation
+)
+
var (
// Supports adding java header libraries to module_exports and sdk.
javaHeaderLibsSdkMemberType = &librarySdkMemberType{
@@ -248,6 +256,8 @@ type JavaInfo struct {
// against this module. If empty, ImplementationJars should be used instead.
HeaderJars android.Paths
+ RepackagedHeaderJars android.Paths
+
// set of header jars for all transitive libs deps
TransitiveLibsHeaderJars *android.DepSet[android.Path]
@@ -294,6 +304,11 @@ type JavaInfo struct {
// JacocoReportClassesFile is the path to a jar containing uninstrumented classes that will be
// instrumented by jacoco.
JacocoReportClassesFile android.Path
+
+ // StubsLinkType provides information about whether the provided jars are stub jars or
+ // implementation jars. If the provider is set by java_sdk_library, the link type is "unknown"
+ // and selection between the stub jar vs implementation jar is deferred to SdkLibrary.sdkJars(...)
+ StubsLinkType StubsLinkType
}
var JavaInfoProvider = blueprint.NewProvider[JavaInfo]()
@@ -692,6 +707,17 @@ func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.minSdkVersion = j.MinSdkVersion(ctx)
j.maxSdkVersion = j.MaxSdkVersion(ctx)
+ // SdkLibrary.GenerateAndroidBuildActions(ctx) sets the stubsLinkType to Unknown.
+ // If the stubsLinkType has already been set to Unknown, the stubsLinkType should
+ // not be overridden.
+ if j.stubsLinkType != Unknown {
+ if proptools.Bool(j.properties.Is_stubs_module) {
+ j.stubsLinkType = Stubs
+ } else {
+ j.stubsLinkType = Implementation
+ }
+ }
+
j.stem = proptools.StringDefault(j.overridableDeviceProperties.Stem, ctx.ModuleName())
proguardSpecInfo := j.collectProguardSpecInfo(ctx)
@@ -2016,6 +2042,7 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ImplementationAndResourcesJars: android.PathsIfNonNil(al.stubsJar),
ImplementationJars: android.PathsIfNonNil(al.stubsJar),
AidlIncludeDirs: android.Paths{},
+ StubsLinkType: Stubs,
// No aconfig libraries on api libraries
})
}
@@ -2095,6 +2122,14 @@ type ImportProperties struct {
// If unspecified, follows the naming convention that the source module of
// the prebuilt is Name() without "prebuilt_" prefix
Source_module_name *string
+
+ // Non-nil if this java_import module was dynamically created by a java_sdk_library_import
+ // The name is the undecorated name of the java_sdk_library as it appears in the blueprint file
+ // (without any prebuilt_ prefix)
+ Created_by_java_sdk_library_name *string `blueprint:"mutated"`
+
+ // Property signifying whether the module provides stubs jar or not.
+ Is_stubs_module *bool
}
type Import struct {
@@ -2125,6 +2160,8 @@ type Import struct {
sdkVersion android.SdkSpec
minSdkVersion android.ApiLevel
+
+ stubsLinkType StubsLinkType
}
var _ PermittedPackagesForUpdatableBootJars = (*Import)(nil)
@@ -2180,6 +2217,10 @@ func (j *Import) Stem() string {
return proptools.StringDefault(j.properties.Stem, j.BaseModuleName())
}
+func (j *Import) CreatedByJavaSdkLibraryName() *string {
+ return j.properties.Created_by_java_sdk_library_name
+}
+
func (a *Import) JacocoReportClassesFile() android.Path {
return nil
}
@@ -2215,6 +2256,12 @@ func (j *Import) commonBuildActions(ctx android.ModuleContext) {
if ctx.Windows() {
j.HideFromMake()
}
+
+ if proptools.Bool(j.properties.Is_stubs_module) {
+ j.stubsLinkType = Stubs
+ } else {
+ j.stubsLinkType = Implementation
+ }
}
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -2348,6 +2395,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ImplementationAndResourcesJars: android.PathsIfNonNil(j.combinedClasspathFile),
ImplementationJars: android.PathsIfNonNil(j.combinedClasspathFile),
AidlIncludeDirs: j.exportAidlIncludeDirs,
+ StubsLinkType: j.stubsLinkType,
// TODO(b/289117800): LOCAL_ACONFIG_FILES for prebuilts
})
}
@@ -2831,7 +2879,20 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module,
type JavaApiContributionImport struct {
JavaApiContribution
- prebuilt android.Prebuilt
+ prebuilt android.Prebuilt
+ prebuiltProperties javaApiContributionImportProperties
+}
+
+type javaApiContributionImportProperties struct {
+ // Name of the source soong module that gets shadowed by this prebuilt
+ // If unspecified, follows the naming convention that the source module of
+ // the prebuilt is Name() without "prebuilt_" prefix
+ Source_module_name *string
+
+ // Non-nil if this java_import module was dynamically created by a java_sdk_library_import
+ // The name is the undecorated name of the java_sdk_library as it appears in the blueprint file
+ // (without any prebuilt_ prefix)
+ Created_by_java_sdk_library_name *string `blueprint:"mutated"`
}
func ApiContributionImportFactory() android.Module {
@@ -2839,7 +2900,7 @@ func ApiContributionImportFactory() android.Module {
android.InitAndroidModule(module)
android.InitDefaultableModule(module)
android.InitPrebuiltModule(module, &[]string{""})
- module.AddProperties(&module.properties)
+ module.AddProperties(&module.properties, &module.prebuiltProperties)
module.AddProperties(&module.sdkLibraryComponentProperties)
return module
}
@@ -2852,6 +2913,14 @@ func (module *JavaApiContributionImport) Name() string {
return module.prebuilt.Name(module.ModuleBase.Name())
}
+func (j *JavaApiContributionImport) BaseModuleName() string {
+ return proptools.StringDefault(j.prebuiltProperties.Source_module_name, j.ModuleBase.Name())
+}
+
+func (j *JavaApiContributionImport) CreatedByJavaSdkLibraryName() *string {
+ return j.prebuiltProperties.Created_by_java_sdk_library_name
+}
+
func (ap *JavaApiContributionImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ap.JavaApiContribution.GenerateAndroidBuildActions(ctx)
}