Merge "Switch hiddenapi to use OutputPath instead of ModuleOutPath"
This commit is contained in:
@@ -263,10 +263,10 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, flags javaBuilderFlags) (r8Fl
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, minSdkVersion sdkSpec,
|
func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, minSdkVersion sdkSpec,
|
||||||
classesJar android.Path, jarName string) android.ModuleOutPath {
|
classesJar android.Path, jarName string) android.OutputPath {
|
||||||
|
|
||||||
// Compile classes.jar into classes.dex and then javalib.jar
|
// Compile classes.jar into classes.dex and then javalib.jar
|
||||||
javalibJar := android.PathForModuleOut(ctx, "dex", jarName)
|
javalibJar := android.PathForModuleOut(ctx, "dex", jarName).OutputPath
|
||||||
outDir := android.PathForModuleOut(ctx, "dex")
|
outDir := android.PathForModuleOut(ctx, "dex")
|
||||||
|
|
||||||
zipFlags := "--ignore_missing_files"
|
zipFlags := "--ignore_missing_files"
|
||||||
@@ -329,7 +329,7 @@ func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, mi
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if proptools.Bool(d.dexProperties.Uncompress_dex) {
|
if proptools.Bool(d.dexProperties.Uncompress_dex) {
|
||||||
alignedJavalibJar := android.PathForModuleOut(ctx, "aligned", jarName)
|
alignedJavalibJar := android.PathForModuleOut(ctx, "aligned", jarName).OutputPath
|
||||||
TransformZipAlign(ctx, alignedJavalibJar, javalibJar)
|
TransformZipAlign(ctx, alignedJavalibJar, javalibJar)
|
||||||
javalibJar = alignedJavalibJar
|
javalibJar = alignedJavalibJar
|
||||||
}
|
}
|
||||||
|
@@ -118,7 +118,7 @@ func odexOnSystemOther(ctx android.ModuleContext, installPath android.InstallPat
|
|||||||
return dexpreopt.OdexOnSystemOtherByName(ctx.ModuleName(), android.InstallPathToOnDevicePath(ctx, installPath), dexpreopt.GetGlobalConfig(ctx))
|
return dexpreopt.OdexOnSystemOtherByName(ctx.ModuleName(), android.InstallPathToOnDevicePath(ctx, installPath), dexpreopt.GetGlobalConfig(ctx))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.ModuleOutPath) {
|
func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.WritablePath) {
|
||||||
// TODO(b/148690468): The check on d.installPath is to bail out in cases where
|
// TODO(b/148690468): The check on d.installPath is to bail out in cases where
|
||||||
// the dexpreopter struct hasn't been fully initialized before we're called,
|
// the dexpreopter struct hasn't been fully initialized before we're called,
|
||||||
// e.g. in aar.go. This keeps the behaviour that dexpreopting is effectively
|
// e.g. in aar.go. This keeps the behaviour that dexpreopting is effectively
|
||||||
|
@@ -89,8 +89,8 @@ type hiddenAPIIntf interface {
|
|||||||
|
|
||||||
var _ hiddenAPIIntf = (*hiddenAPI)(nil)
|
var _ hiddenAPIIntf = (*hiddenAPI)(nil)
|
||||||
|
|
||||||
func (h *hiddenAPI) hiddenAPI(ctx android.ModuleContext, name string, primary bool, dexJar android.ModuleOutPath,
|
func (h *hiddenAPI) hiddenAPI(ctx android.ModuleContext, name string, primary bool, dexJar android.OutputPath,
|
||||||
implementationJar android.Path, uncompressDex bool) android.ModuleOutPath {
|
implementationJar android.Path, uncompressDex bool) android.OutputPath {
|
||||||
if !ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") {
|
if !ctx.Config().IsEnvTrue("UNSAFE_DISABLE_HIDDENAPI_FLAGS") {
|
||||||
|
|
||||||
// Modules whose names are of the format <x>-hiddenapi provide hiddenapi information
|
// Modules whose names are of the format <x>-hiddenapi provide hiddenapi information
|
||||||
@@ -116,7 +116,7 @@ func (h *hiddenAPI) hiddenAPI(ctx android.ModuleContext, name string, primary bo
|
|||||||
// hiddenapi information for a module on the boot jars list then encode
|
// hiddenapi information for a module on the boot jars list then encode
|
||||||
// the gathered information in the generated dex file.
|
// the gathered information in the generated dex file.
|
||||||
if name == bootJarName {
|
if name == bootJarName {
|
||||||
hiddenAPIJar := android.PathForModuleOut(ctx, "hiddenapi", name+".jar")
|
hiddenAPIJar := android.PathForModuleOut(ctx, "hiddenapi", name+".jar").OutputPath
|
||||||
|
|
||||||
// More than one library with the same classes can be encoded but only one can
|
// More than one library with the same classes can be encoded but only one can
|
||||||
// be added to the global set of flags, otherwise it will result in duplicate
|
// be added to the global set of flags, otherwise it will result in duplicate
|
||||||
|
43
java/java.go
43
java/java.go
@@ -1689,35 +1689,44 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
|||||||
|
|
||||||
// Combine the classes built from sources, any manifests, and any static libraries into
|
// Combine the classes built from sources, any manifests, and any static libraries into
|
||||||
// classes.jar. If there is only one input jar this step will be skipped.
|
// classes.jar. If there is only one input jar this step will be skipped.
|
||||||
var outputFile android.ModuleOutPath
|
var outputFile android.OutputPath
|
||||||
|
|
||||||
if len(jars) == 1 && !manifest.Valid() {
|
if len(jars) == 1 && !manifest.Valid() {
|
||||||
|
// Optimization: skip the combine step as there is nothing to do
|
||||||
|
// TODO(ccross): this leaves any module-info.class files, but those should only come from
|
||||||
|
// prebuilt dependencies until we support modules in the platform build, so there shouldn't be
|
||||||
|
// any if len(jars) == 1.
|
||||||
|
|
||||||
|
// Transform the single path to the jar into an OutputPath as that is required by the following
|
||||||
|
// code.
|
||||||
if moduleOutPath, ok := jars[0].(android.ModuleOutPath); ok {
|
if moduleOutPath, ok := jars[0].(android.ModuleOutPath); ok {
|
||||||
// Optimization: skip the combine step if there is nothing to do
|
// The path contains an embedded OutputPath so reuse that.
|
||||||
// TODO(ccross): this leaves any module-info.class files, but those should only come from
|
outputFile = moduleOutPath.OutputPath
|
||||||
// prebuilt dependencies until we support modules in the platform build, so there shouldn't be
|
} else if outputPath, ok := jars[0].(android.OutputPath); ok {
|
||||||
// any if len(jars) == 1.
|
// The path is an OutputPath so reuse it directly.
|
||||||
outputFile = moduleOutPath
|
outputFile = outputPath
|
||||||
} else {
|
} else {
|
||||||
|
// The file is not in the out directory so create an OutputPath into which it can be copied
|
||||||
|
// and which the following code can use to refer to it.
|
||||||
combinedJar := android.PathForModuleOut(ctx, "combined", jarName)
|
combinedJar := android.PathForModuleOut(ctx, "combined", jarName)
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: android.Cp,
|
Rule: android.Cp,
|
||||||
Input: jars[0],
|
Input: jars[0],
|
||||||
Output: combinedJar,
|
Output: combinedJar,
|
||||||
})
|
})
|
||||||
outputFile = combinedJar
|
outputFile = combinedJar.OutputPath
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
combinedJar := android.PathForModuleOut(ctx, "combined", jarName)
|
combinedJar := android.PathForModuleOut(ctx, "combined", jarName)
|
||||||
TransformJarsToJar(ctx, combinedJar, "for javac", jars, manifest,
|
TransformJarsToJar(ctx, combinedJar, "for javac", jars, manifest,
|
||||||
false, nil, nil)
|
false, nil, nil)
|
||||||
outputFile = combinedJar
|
outputFile = combinedJar.OutputPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// jarjar implementation jar if necessary
|
// jarjar implementation jar if necessary
|
||||||
if j.expandJarjarRules != nil {
|
if j.expandJarjarRules != nil {
|
||||||
// Transform classes.jar into classes-jarjar.jar
|
// Transform classes.jar into classes-jarjar.jar
|
||||||
jarjarFile := android.PathForModuleOut(ctx, "jarjar", jarName)
|
jarjarFile := android.PathForModuleOut(ctx, "jarjar", jarName).OutputPath
|
||||||
TransformJarJar(ctx, jarjarFile, outputFile, j.expandJarjarRules)
|
TransformJarJar(ctx, jarjarFile, outputFile, j.expandJarjarRules)
|
||||||
outputFile = jarjarFile
|
outputFile = jarjarFile
|
||||||
|
|
||||||
@@ -1762,7 +1771,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
|||||||
implementationAndResourcesJar := outputFile
|
implementationAndResourcesJar := outputFile
|
||||||
if j.resourceJar != nil {
|
if j.resourceJar != nil {
|
||||||
jars := android.Paths{j.resourceJar, implementationAndResourcesJar}
|
jars := android.Paths{j.resourceJar, implementationAndResourcesJar}
|
||||||
combinedJar := android.PathForModuleOut(ctx, "withres", jarName)
|
combinedJar := android.PathForModuleOut(ctx, "withres", jarName).OutputPath
|
||||||
TransformJarsToJar(ctx, combinedJar, "for resources", jars, manifest,
|
TransformJarsToJar(ctx, combinedJar, "for resources", jars, manifest,
|
||||||
false, nil, nil)
|
false, nil, nil)
|
||||||
implementationAndResourcesJar = combinedJar
|
implementationAndResourcesJar = combinedJar
|
||||||
@@ -1788,7 +1797,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
|||||||
android.PathForSource(ctx, "build/make/core/proguard.jacoco.flags"))
|
android.PathForSource(ctx, "build/make/core/proguard.jacoco.flags"))
|
||||||
}
|
}
|
||||||
// Dex compilation
|
// Dex compilation
|
||||||
var dexOutputFile android.ModuleOutPath
|
var dexOutputFile android.OutputPath
|
||||||
dexOutputFile = j.dexer.compileDex(ctx, flags, j.minSdkVersion(), outputFile, jarName)
|
dexOutputFile = j.dexer.compileDex(ctx, flags, j.minSdkVersion(), outputFile, jarName)
|
||||||
if ctx.Failed() {
|
if ctx.Failed() {
|
||||||
return
|
return
|
||||||
@@ -1807,11 +1816,11 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
|
|||||||
// merge dex jar with resources if necessary
|
// merge dex jar with resources if necessary
|
||||||
if j.resourceJar != nil {
|
if j.resourceJar != nil {
|
||||||
jars := android.Paths{dexOutputFile, j.resourceJar}
|
jars := android.Paths{dexOutputFile, j.resourceJar}
|
||||||
combinedJar := android.PathForModuleOut(ctx, "dex-withres", jarName)
|
combinedJar := android.PathForModuleOut(ctx, "dex-withres", jarName).OutputPath
|
||||||
TransformJarsToJar(ctx, combinedJar, "for dex resources", jars, android.OptionalPath{},
|
TransformJarsToJar(ctx, combinedJar, "for dex resources", jars, android.OptionalPath{},
|
||||||
false, nil, nil)
|
false, nil, nil)
|
||||||
if *j.dexProperties.Uncompress_dex {
|
if *j.dexProperties.Uncompress_dex {
|
||||||
combinedAlignedJar := android.PathForModuleOut(ctx, "dex-withres-aligned", jarName)
|
combinedAlignedJar := android.PathForModuleOut(ctx, "dex-withres-aligned", jarName).OutputPath
|
||||||
TransformZipAlign(ctx, combinedAlignedJar, combinedJar)
|
TransformZipAlign(ctx, combinedAlignedJar, combinedJar)
|
||||||
dexOutputFile = combinedAlignedJar
|
dexOutputFile = combinedAlignedJar
|
||||||
} else {
|
} else {
|
||||||
@@ -1875,7 +1884,7 @@ func (j *Module) compileJavaClasses(ctx android.ModuleContext, jarName string, i
|
|||||||
jarName += strconv.Itoa(idx)
|
jarName += strconv.Itoa(idx)
|
||||||
}
|
}
|
||||||
|
|
||||||
classes := android.PathForModuleOut(ctx, "javac", jarName)
|
classes := android.PathForModuleOut(ctx, "javac", jarName).OutputPath
|
||||||
TransformJavaToClasses(ctx, classes, idx, srcFiles, srcJars, flags, extraJarDeps)
|
TransformJavaToClasses(ctx, classes, idx, srcFiles, srcJars, flags, extraJarDeps)
|
||||||
|
|
||||||
if ctx.Config().EmitXrefRules() {
|
if ctx.Config().EmitXrefRules() {
|
||||||
@@ -1955,12 +1964,12 @@ func (j *Module) compileJavaHeader(ctx android.ModuleContext, srcFiles, srcJars
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) instrument(ctx android.ModuleContext, flags javaBuilderFlags,
|
func (j *Module) instrument(ctx android.ModuleContext, flags javaBuilderFlags,
|
||||||
classesJar android.Path, jarName string) android.ModuleOutPath {
|
classesJar android.Path, jarName string) android.OutputPath {
|
||||||
|
|
||||||
specs := j.jacocoModuleToZipCommand(ctx)
|
specs := j.jacocoModuleToZipCommand(ctx)
|
||||||
|
|
||||||
jacocoReportClassesFile := android.PathForModuleOut(ctx, "jacoco-report-classes", jarName)
|
jacocoReportClassesFile := android.PathForModuleOut(ctx, "jacoco-report-classes", jarName)
|
||||||
instrumentedJar := android.PathForModuleOut(ctx, "jacoco", jarName)
|
instrumentedJar := android.PathForModuleOut(ctx, "jacoco", jarName).OutputPath
|
||||||
|
|
||||||
jacocoInstrumentJar(ctx, instrumentedJar, jacocoReportClassesFile, classesJar, specs)
|
jacocoInstrumentJar(ctx, instrumentedJar, jacocoReportClassesFile, classesJar, specs)
|
||||||
|
|
||||||
@@ -2937,7 +2946,7 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
}
|
}
|
||||||
j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
|
j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
|
||||||
|
|
||||||
var dexOutputFile android.ModuleOutPath
|
var dexOutputFile android.OutputPath
|
||||||
dexOutputFile = j.dexer.compileDex(ctx, flags, j.minSdkVersion(), outputFile, jarName)
|
dexOutputFile = j.dexer.compileDex(ctx, flags, j.minSdkVersion(), outputFile, jarName)
|
||||||
if ctx.Failed() {
|
if ctx.Failed() {
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user