summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/sdk.go6
-rw-r--r--java/java.go35
-rw-r--r--sdk/java_sdk_test.go7
-rw-r--r--sdk/update.go16
4 files changed, 18 insertions, 46 deletions
diff --git a/android/sdk.go b/android/sdk.go
index bab0ed8fd..f2cdc880b 100644
--- a/android/sdk.go
+++ b/android/sdk.go
@@ -177,12 +177,6 @@ type SnapshotBuilder interface {
// to the zip
CopyToSnapshot(src Path, dest string)
- // Return the path to an empty file.
- //
- // This can be used by sdk member types that need to create an empty file in the snapshot, simply
- // pass the value returned from this to the CopyToSnapshot() method.
- EmptyFile() Path
-
// Unzip the supplied zip into the snapshot relative directory destDir.
UnzipToSnapshot(zipPath Path, destDir string)
diff --git a/java/java.go b/java/java.go
index 78d974b42..7d0b206ac 100644
--- a/java/java.go
+++ b/java/java.go
@@ -40,18 +40,21 @@ func init() {
// Register sdk member types.
android.RegisterSdkMemberType(javaHeaderLibsSdkMemberType)
+ // Export implementation classes jar as part of the sdk.
+ exportImplementationClassesJar := func(_ android.SdkMemberContext, j *Library) android.Path {
+ implementationJars := j.ImplementationAndResourcesJars()
+ if len(implementationJars) != 1 {
+ panic(fmt.Errorf("there must be only one implementation jar from %q", j.Name()))
+ }
+ return implementationJars[0]
+ }
+
// Register java implementation libraries for use only in module_exports (not sdk).
android.RegisterSdkMemberType(&librarySdkMemberType{
android.SdkMemberTypeBase{
PropertyName: "java_libs",
},
- func(_ android.SdkMemberContext, j *Library) android.Path {
- implementationJars := j.ImplementationAndResourcesJars()
- if len(implementationJars) != 1 {
- panic(fmt.Errorf("there must be only one implementation jar from %q", j.Name()))
- }
- return implementationJars[0]
- },
+ exportImplementationClassesJar,
sdkSnapshotFilePathForJar,
copyEverythingToSnapshot,
})
@@ -72,19 +75,11 @@ func init() {
PropertyName: "java_boot_libs",
SupportsSdk: true,
},
- func(ctx android.SdkMemberContext, j *Library) android.Path {
- // Java boot libs are only provided in the SDK to provide access to their dex implementation
- // jar for use by dexpreopting and boot jars package check. They do not need to provide an
- // actual implementation jar but the java_import will need a file that exists so just copy an
- // empty file. Any attempt to use that file as a jar will cause a build error.
- return ctx.SnapshotBuilder().EmptyFile()
- },
- func(osPrefix, name string) string {
- // Create a special name for the implementation jar to try and provide some useful information
- // to a developer that attempts to compile against this.
- // TODO(b/175714559): Provide a proper error message in Soong not ninja.
- return filepath.Join(osPrefix, "java_boot_libs", "snapshot", "jars", "are", "invalid", name+jarFileSuffix)
- },
+ // Temporarily export implementation classes jar for java_boot_libs as it is required for the
+ // hiddenapi processing.
+ // TODO(b/179354495): Revert once hiddenapi processing has been modularized.
+ exportImplementationClassesJar,
+ sdkSnapshotFilePathForJar,
onlyCopyJarToSnapshot,
})
diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go
index 488afd84e..17a6ca9b8 100644
--- a/sdk/java_sdk_test.go
+++ b/sdk/java_sdk_test.go
@@ -503,7 +503,7 @@ java_import {
sdk_member_name: "myjavalib",
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
- jars: ["java_boot_libs/snapshot/jars/are/invalid/myjavalib.jar"],
+ jars: ["java/myjavalib.jar"],
}
java_import {
@@ -511,7 +511,7 @@ java_import {
prefer: false,
visibility: ["//visibility:public"],
apex_available: ["//apex_available:platform"],
- jars: ["java_boot_libs/snapshot/jars/are/invalid/myjavalib.jar"],
+ jars: ["java/myjavalib.jar"],
}
module_exports_snapshot {
@@ -519,10 +519,9 @@ module_exports_snapshot {
visibility: ["//visibility:public"],
java_boot_libs: ["myexports_myjavalib@current"],
}
-
`),
checkAllCopyRules(`
-.intermediates/myexports/common_os/empty -> java_boot_libs/snapshot/jars/are/invalid/myjavalib.jar
+.intermediates/myjavalib/android_common/withres/myjavalib.jar -> java/myjavalib.jar
`),
)
}
diff --git a/sdk/update.go b/sdk/update.go
index b5bc9f434..377aaae76 100644
--- a/sdk/update.go
+++ b/sdk/update.go
@@ -653,9 +653,6 @@ type snapshotBuilder struct {
filesToZip android.Paths
zipsToMerge android.Paths
- // The path to an empty file.
- emptyFile android.WritablePath
-
prebuiltModules map[string]*bpModule
prebuiltOrder []*bpModule
@@ -706,19 +703,6 @@ func (s *snapshotBuilder) UnzipToSnapshot(zipPath android.Path, destDir string)
s.zipsToMerge = append(s.zipsToMerge, tmpZipPath)
}
-func (s *snapshotBuilder) EmptyFile() android.Path {
- if s.emptyFile == nil {
- ctx := s.ctx
- s.emptyFile = android.PathForModuleOut(ctx, "empty")
- s.ctx.Build(pctx, android.BuildParams{
- Rule: android.Touch,
- Output: s.emptyFile,
- })
- }
-
- return s.emptyFile
-}
-
func (s *snapshotBuilder) AddPrebuiltModule(member android.SdkMember, moduleType string) android.BpModule {
name := member.Name()
if s.prebuiltModules[name] != nil {