summaryrefslogtreecommitdiff
path: root/java/java.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/java.go')
-rw-r--r--java/java.go77
1 files changed, 64 insertions, 13 deletions
diff --git a/java/java.go b/java/java.go
index 0841dad5e..ebd9f5ef2 100644
--- a/java/java.go
+++ b/java/java.go
@@ -811,7 +811,7 @@ func (p *librarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMemberCo
// If the min_sdk_version was set then add the canonical representation of the API level to the
// snapshot.
if j.deviceProperties.Min_sdk_version != nil {
- canonical := android.ReplaceFinalizedCodenames(ctx.SdkModuleContext().Config(), j.minSdkVersion.ApiLevel.String())
+ canonical := android.ReplaceFinalizedCodenames(ctx.SdkModuleContext().Config(), j.minSdkVersion.String())
p.MinSdkVersion = proptools.StringPtr(canonical)
}
@@ -1613,10 +1613,15 @@ type ApiLibrary struct {
android.ModuleBase
android.DefaultableModuleBase
+ hiddenAPI
+ dexer
+
properties JavaApiLibraryProperties
stubsSrcJar android.WritablePath
stubsJar android.WritablePath
+ // .dex of stubs, used for hiddenapi processing
+ dexJarFile OptionalDexJarPath
}
type JavaApiLibraryProperties struct {
@@ -1794,6 +1799,20 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
Inputs(staticLibs)
builder.Build("merge_zips", "merge jar files")
+ // compile stubs to .dex for hiddenapi processing
+ dexParams := &compileDexParams{
+ flags: javaBuilderFlags{},
+ sdkVersion: al.SdkVersion(ctx),
+ minSdkVersion: al.MinSdkVersion(ctx),
+ classesJar: al.stubsJar,
+ jarName: ctx.ModuleName() + ".jar",
+ }
+ dexOutputFile := al.dexer.compileDex(ctx, dexParams)
+ uncompressed := true
+ al.initHiddenAPI(ctx, makeDexJarPathFromPath(dexOutputFile), al.stubsJar, &uncompressed)
+ dexOutputFile = al.hiddenAPIEncodeDex(ctx, dexOutputFile)
+ al.dexJarFile = makeDexJarPathFromPath(dexOutputFile)
+
ctx.Phony(ctx.ModuleName(), al.stubsJar)
ctx.SetProvider(JavaInfoProvider, JavaInfo{
@@ -1801,6 +1820,32 @@ func (al *ApiLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
})
}
+func (al *ApiLibrary) DexJarBuildPath() OptionalDexJarPath {
+ return al.dexJarFile
+}
+
+func (al *ApiLibrary) DexJarInstallPath() android.Path {
+ return al.dexJarFile.Path()
+}
+
+func (al *ApiLibrary) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap {
+ return nil
+}
+
+// java_api_library constitutes the sdk, and does not build against one
+func (al *ApiLibrary) SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
+ return android.SdkSpecNone
+}
+
+// java_api_library is always at "current". Return FutureApiLevel
+func (al *ApiLibrary) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
+ return android.FutureApiLevel
+}
+
+// implement the following interfaces for hiddenapi processing
+var _ hiddenAPIModule = (*ApiLibrary)(nil)
+var _ UsesLibraryDependency = (*ApiLibrary)(nil)
+
//
// Java prebuilts
//
@@ -1874,7 +1919,7 @@ type Import struct {
hideApexVariantFromMake bool
sdkVersion android.SdkSpec
- minSdkVersion android.SdkSpec
+ minSdkVersion android.ApiLevel
}
var _ PermittedPackagesForUpdatableBootJars = (*Import)(nil)
@@ -1891,22 +1936,23 @@ func (j *Import) SystemModules() string {
return "none"
}
-func (j *Import) MinSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
+func (j *Import) MinSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
if j.properties.Min_sdk_version != nil {
- return android.SdkSpecFrom(ctx, *j.properties.Min_sdk_version)
+ return android.ApiLevelFrom(ctx, *j.properties.Min_sdk_version)
}
- return j.SdkVersion(ctx)
+ return j.SdkVersion(ctx).ApiLevel
}
-func (j *Import) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.SdkSpec {
+func (j *Import) ReplaceMaxSdkVersionPlaceholder(ctx android.EarlyModuleContext) android.ApiLevel {
if j.properties.Replace_max_sdk_version_placeholder != nil {
- return android.SdkSpecFrom(ctx, *j.properties.Replace_max_sdk_version_placeholder)
+ return android.ApiLevelFrom(ctx, *j.properties.Replace_max_sdk_version_placeholder)
}
- return android.SdkSpecFrom(ctx, "")
+ // Default is PrivateApiLevel
+ return android.SdkSpecPrivate.ApiLevel
}
-func (j *Import) TargetSdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
- return j.SdkVersion(ctx)
+func (j *Import) TargetSdkVersion(ctx android.EarlyModuleContext) android.ApiLevel {
+ return j.SdkVersion(ctx).ApiLevel
}
func (j *Import) Prebuilt() *android.Prebuilt {
@@ -2161,15 +2207,14 @@ func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu
func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext,
sdkVersion android.ApiLevel) error {
sdkVersionSpec := j.SdkVersion(ctx)
- minSdkVersionSpec := j.MinSdkVersion(ctx)
- if !minSdkVersionSpec.Specified() {
+ minSdkVersion := j.MinSdkVersion(ctx)
+ if !minSdkVersion.Specified() {
return fmt.Errorf("min_sdk_version is not specified")
}
// If the module is compiling against core (via sdk_version), skip comparison check.
if sdkVersionSpec.Kind == android.SdkCore {
return nil
}
- minSdkVersion := minSdkVersionSpec.ApiLevel
if minSdkVersion.GreaterThan(sdkVersion) {
return fmt.Errorf("newer SDK(%v)", minSdkVersion)
}
@@ -2626,10 +2671,12 @@ type eventLogTagsAttributes struct {
type aidlLibraryAttributes struct {
Srcs bazel.LabelListAttribute
+ Tags bazel.StringListAttribute
}
type javaAidlLibraryAttributes struct {
Deps bazel.LabelListAttribute
+ Tags bazel.StringListAttribute
}
// bp2BuildJavaInfo has information needed for the conversion of java*_modules
@@ -2701,6 +2748,8 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
return android.IsConvertedToAidlLibrary(ctx, src.OriginalModuleName)
})
+ apexAvailableTags := android.ApexAvailableTags(ctx.Module())
+
if !aidlSrcs.IsEmpty() {
aidlLibName := m.Name() + "_aidl_library"
ctx.CreateBazelTargetModule(
@@ -2711,6 +2760,7 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
android.CommonAttributes{Name: aidlLibName},
&aidlLibraryAttributes{
Srcs: aidlSrcs,
+ Tags: apexAvailableTags,
},
)
aidlLibs.Add(&bazel.LabelAttribute{Value: &bazel.Label{Label: ":" + aidlLibName}})
@@ -2725,6 +2775,7 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext)
android.CommonAttributes{Name: javaAidlLibName},
&javaAidlLibraryAttributes{
Deps: aidlLibs,
+ Tags: apexAvailableTags,
},
)