Merge changes Iaab7a588,I7bc1d1f3
am: f6df17afd1
Change-Id: Ia257b3a4a6afcce134057c4eaa5a79e54b336513
This commit is contained in:
commit
8cf991bd2d
|
@ -89,7 +89,7 @@ func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
publicResourcesFile, proguardOptionsFile, aaptJavaFileList :=
|
publicResourcesFile, proguardOptionsFile, aaptJavaFileList :=
|
||||||
CreateResourceJavaFiles(ctx, aaptRJavaFlags, aaptDeps)
|
CreateResourceJavaFiles(ctx, aaptRJavaFlags, aaptDeps)
|
||||||
a.aaptJavaFileList = aaptJavaFileList
|
a.aaptJavaFileList = aaptJavaFileList
|
||||||
a.ExtraSrcLists = append(a.ExtraSrcLists, aaptJavaFileList)
|
// TODO(ccross): export aapt generated java files as a src jar
|
||||||
|
|
||||||
if a.appProperties.Export_package_resources {
|
if a.appProperties.Export_package_resources {
|
||||||
aaptPackageFlags := append([]string(nil), aaptFlags...)
|
aaptPackageFlags := append([]string(nil), aaptFlags...)
|
||||||
|
|
109
java/builder.go
109
java/builder.go
|
@ -40,7 +40,7 @@ var (
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: `rm -rf "$outDir" "$annoDir" && mkdir -p "$outDir" "$annoDir" && ` +
|
Command: `rm -rf "$outDir" "$annoDir" && mkdir -p "$outDir" "$annoDir" && ` +
|
||||||
`${config.JavacWrapper}${config.JavacCmd} ${config.JavacHeapFlags} ${config.CommonJdkFlags} ` +
|
`${config.JavacWrapper}${config.JavacCmd} ${config.JavacHeapFlags} ${config.CommonJdkFlags} ` +
|
||||||
`$javacFlags $bootClasspath $classpath ` +
|
`$javacFlags $sourcepath $bootClasspath $classpath ` +
|
||||||
`-source $javaVersion -target $javaVersion ` +
|
`-source $javaVersion -target $javaVersion ` +
|
||||||
`-d $outDir -s $annoDir @$out.rsp && ` +
|
`-d $outDir -s $annoDir @$out.rsp && ` +
|
||||||
`${config.SoongZipCmd} -jar -o $out -C $outDir -D $outDir`,
|
`${config.SoongZipCmd} -jar -o $out -C $outDir -D $outDir`,
|
||||||
|
@ -48,13 +48,13 @@ var (
|
||||||
Rspfile: "$out.rsp",
|
Rspfile: "$out.rsp",
|
||||||
RspfileContent: "$in",
|
RspfileContent: "$in",
|
||||||
},
|
},
|
||||||
"javacFlags", "bootClasspath", "classpath", "outDir", "annoDir", "javaVersion")
|
"javacFlags", "sourcepath", "bootClasspath", "classpath", "outDir", "annoDir", "javaVersion")
|
||||||
|
|
||||||
errorprone = pctx.AndroidStaticRule("errorprone",
|
errorprone = pctx.AndroidStaticRule("errorprone",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: `rm -rf "$outDir" "$annoDir" && mkdir -p "$outDir" "$annoDir" && ` +
|
Command: `rm -rf "$outDir" "$annoDir" && mkdir -p "$outDir" "$annoDir" && ` +
|
||||||
`${config.ErrorProneCmd} ` +
|
`${config.ErrorProneCmd} ` +
|
||||||
`$javacFlags $bootClasspath $classpath ` +
|
`$javacFlags $sourcepath $bootClasspath $classpath ` +
|
||||||
`-source $javaVersion -target $javaVersion ` +
|
`-source $javaVersion -target $javaVersion ` +
|
||||||
`-d $outDir -s $annoDir @$out.rsp && ` +
|
`-d $outDir -s $annoDir @$out.rsp && ` +
|
||||||
`${config.SoongZipCmd} -jar -o $out -C $outDir -D $outDir`,
|
`${config.SoongZipCmd} -jar -o $out -C $outDir -D $outDir`,
|
||||||
|
@ -67,7 +67,7 @@ var (
|
||||||
Rspfile: "$out.rsp",
|
Rspfile: "$out.rsp",
|
||||||
RspfileContent: "$in",
|
RspfileContent: "$in",
|
||||||
},
|
},
|
||||||
"javacFlags", "bootClasspath", "classpath", "outDir", "annoDir", "javaVersion")
|
"javacFlags", "sourcepath", "bootClasspath", "classpath", "outDir", "annoDir", "javaVersion")
|
||||||
|
|
||||||
jar = pctx.AndroidStaticRule("jar",
|
jar = pctx.AndroidStaticRule("jar",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
|
@ -135,49 +135,41 @@ type javaBuilderFlags struct {
|
||||||
protoOutFlag string
|
protoOutFlag string
|
||||||
}
|
}
|
||||||
|
|
||||||
func TransformJavaToClasses(ctx android.ModuleContext, srcFiles, srcFileLists android.Paths,
|
func TransformJavaToClasses(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||||
flags javaBuilderFlags, deps android.Paths) android.ModuleOutPath {
|
srcFiles android.Paths, srcJars classpath,
|
||||||
|
flags javaBuilderFlags, deps android.Paths) {
|
||||||
|
|
||||||
return transformJavaToClasses(ctx, srcFiles, srcFileLists, flags, deps,
|
transformJavaToClasses(ctx, outputFile, srcFiles, srcJars, flags, deps,
|
||||||
"classes-compiled.jar", "", "javac", javac)
|
"", "javac", javac)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RunErrorProne(ctx android.ModuleContext, srcFiles, srcFileLists android.Paths,
|
func RunErrorProne(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||||
flags javaBuilderFlags) android.Path {
|
srcFiles android.Paths, srcJars classpath,
|
||||||
|
flags javaBuilderFlags) {
|
||||||
|
|
||||||
if config.ErrorProneJar == "" {
|
if config.ErrorProneJar == "" {
|
||||||
ctx.ModuleErrorf("cannot build with Error Prone, missing external/error_prone?")
|
ctx.ModuleErrorf("cannot build with Error Prone, missing external/error_prone?")
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return transformJavaToClasses(ctx, srcFiles, srcFileLists, flags, nil,
|
transformJavaToClasses(ctx, outputFile, srcFiles, srcJars, flags, nil,
|
||||||
"classes-errorprone.list", "-errorprone", "errorprone", errorprone)
|
"-errorprone", "errorprone", errorprone)
|
||||||
}
|
}
|
||||||
|
|
||||||
// transformJavaToClasses takes source files and converts them to a jar containing .class files.
|
// transformJavaToClasses takes source files and converts them to a jar containing .class files.
|
||||||
// srcFiles is a list of paths to sources, srcFileLists is a list of paths to files that contain
|
// srcFiles is a list of paths to sources, srcJars is a list of paths to jar files that contain
|
||||||
// paths to sources. There is no dependency on the sources passed through srcFileLists, those
|
// sources. flags contains various command line flags to be passed to the compiler.
|
||||||
// must be added through the deps argument, which contains a list of paths that should be added
|
|
||||||
// as implicit dependencies. flags contains various command line flags to be passed to the
|
|
||||||
// compiler.
|
|
||||||
//
|
//
|
||||||
// This method may be used for different compilers, including javac and Error Prone. The rule
|
// This method may be used for different compilers, including javac and Error Prone. The rule
|
||||||
// argument specifies which command line to use and desc sets the description of the rule that will
|
// argument specifies which command line to use and desc sets the description of the rule that will
|
||||||
// be printed at build time. The stem argument provides the file name of the output jar, and
|
// be printed at build time. The stem argument provides the file name of the output jar, and
|
||||||
// suffix will be appended to various intermediate files and directories to avoid collisions when
|
// suffix will be appended to various intermediate files and directories to avoid collisions when
|
||||||
// this function is called twice in the same module directory.
|
// this function is called twice in the same module directory.
|
||||||
func transformJavaToClasses(ctx android.ModuleContext, srcFiles, srcFileLists android.Paths,
|
func transformJavaToClasses(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||||
flags javaBuilderFlags, deps android.Paths, stem, suffix, desc string,
|
srcFiles android.Paths, srcJars classpath,
|
||||||
rule blueprint.Rule) android.ModuleOutPath {
|
flags javaBuilderFlags, deps android.Paths,
|
||||||
|
intermediatesSuffix, desc string, rule blueprint.Rule) {
|
||||||
|
|
||||||
outputFile := android.PathForModuleOut(ctx, stem)
|
deps = append(deps, srcJars...)
|
||||||
|
|
||||||
javacFlags := flags.javacFlags
|
|
||||||
if len(srcFileLists) > 0 {
|
|
||||||
javacFlags += " " + android.JoinWithPrefix(srcFileLists.Strings(), "@")
|
|
||||||
}
|
|
||||||
|
|
||||||
deps = append(deps, srcFileLists...)
|
|
||||||
|
|
||||||
var bootClasspath string
|
var bootClasspath string
|
||||||
if flags.javaVersion == "1.9" {
|
if flags.javaVersion == "1.9" {
|
||||||
|
@ -197,22 +189,19 @@ func transformJavaToClasses(ctx android.ModuleContext, srcFiles, srcFileLists an
|
||||||
Inputs: srcFiles,
|
Inputs: srcFiles,
|
||||||
Implicits: deps,
|
Implicits: deps,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"javacFlags": javacFlags,
|
"javacFlags": flags.javacFlags,
|
||||||
"bootClasspath": bootClasspath,
|
"bootClasspath": bootClasspath,
|
||||||
|
"sourcepath": srcJars.JavaSourcepath(),
|
||||||
"classpath": flags.classpath.JavaClasspath(),
|
"classpath": flags.classpath.JavaClasspath(),
|
||||||
"outDir": android.PathForModuleOut(ctx, "classes"+suffix).String(),
|
"outDir": android.PathForModuleOut(ctx, "classes"+intermediatesSuffix).String(),
|
||||||
"annoDir": android.PathForModuleOut(ctx, "anno"+suffix).String(),
|
"annoDir": android.PathForModuleOut(ctx, "anno"+intermediatesSuffix).String(),
|
||||||
"javaVersion": flags.javaVersion,
|
"javaVersion": flags.javaVersion,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return outputFile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TransformResourcesToJar(ctx android.ModuleContext, jarArgs []string,
|
func TransformResourcesToJar(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||||
deps android.Paths) android.Path {
|
jarArgs []string, deps android.Paths) {
|
||||||
|
|
||||||
outputFile := android.PathForModuleOut(ctx, "res.jar")
|
|
||||||
|
|
||||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||||
Rule: jar,
|
Rule: jar,
|
||||||
|
@ -223,18 +212,10 @@ func TransformResourcesToJar(ctx android.ModuleContext, jarArgs []string,
|
||||||
"jarArgs": strings.Join(jarArgs, " "),
|
"jarArgs": strings.Join(jarArgs, " "),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return outputFile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TransformJarsToJar(ctx android.ModuleContext, stem string, jars android.Paths,
|
func TransformJarsToJar(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||||
manifest android.OptionalPath, stripDirs bool) android.Path {
|
jars android.Paths, manifest android.OptionalPath, stripDirs bool) {
|
||||||
|
|
||||||
outputFile := android.PathForModuleOut(ctx, stem)
|
|
||||||
|
|
||||||
if len(jars) == 1 && !manifest.Valid() {
|
|
||||||
return jars[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
var deps android.Paths
|
var deps android.Paths
|
||||||
|
|
||||||
|
@ -258,14 +239,11 @@ func TransformJarsToJar(ctx android.ModuleContext, stem string, jars android.Pat
|
||||||
"jarArgs": strings.Join(jarArgs, " "),
|
"jarArgs": strings.Join(jarArgs, " "),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return outputFile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TransformDesugar(ctx android.ModuleContext, classesJar android.Path,
|
func TransformDesugar(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||||
flags javaBuilderFlags) android.Path {
|
classesJar android.Path, flags javaBuilderFlags) {
|
||||||
|
|
||||||
outputFile := android.PathForModuleOut(ctx, "classes-desugar.jar")
|
|
||||||
dumpDir := android.PathForModuleOut(ctx, "desugar_dumped_classes")
|
dumpDir := android.PathForModuleOut(ctx, "desugar_dumped_classes")
|
||||||
|
|
||||||
javaFlags := ""
|
javaFlags := ""
|
||||||
|
@ -294,17 +272,14 @@ func TransformDesugar(ctx android.ModuleContext, classesJar android.Path,
|
||||||
"desugarFlags": flags.desugarFlags,
|
"desugarFlags": flags.desugarFlags,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return outputFile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Converts a classes.jar file to classes*.dex, then combines the dex files with any resources
|
// Converts a classes.jar file to classes*.dex, then combines the dex files with any resources
|
||||||
// in the classes.jar file into a dex jar.
|
// in the classes.jar file into a dex jar.
|
||||||
func TransformClassesJarToDexJar(ctx android.ModuleContext, stem string, classesJar android.Path,
|
func TransformClassesJarToDexJar(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||||
flags javaBuilderFlags) android.Path {
|
classesJar android.Path, flags javaBuilderFlags) {
|
||||||
|
|
||||||
outDir := android.PathForModuleOut(ctx, "dex")
|
outDir := android.PathForModuleOut(ctx, "dex")
|
||||||
outputFile := android.PathForModuleOut(ctx, stem)
|
|
||||||
|
|
||||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||||
Rule: dx,
|
Rule: dx,
|
||||||
|
@ -316,12 +291,10 @@ func TransformClassesJarToDexJar(ctx android.ModuleContext, stem string, classes
|
||||||
"outDir": outDir.String(),
|
"outDir": outDir.String(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return outputFile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TransformJarJar(ctx android.ModuleContext, classesJar android.Path, rulesFile android.Path) android.ModuleOutPath {
|
func TransformJarJar(ctx android.ModuleContext, outputFile android.WritablePath,
|
||||||
outputFile := android.PathForModuleOut(ctx, "classes-jarjar.jar")
|
classesJar android.Path, rulesFile android.Path) {
|
||||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||||
Rule: jarjar,
|
Rule: jarjar,
|
||||||
Description: "jarjar",
|
Description: "jarjar",
|
||||||
|
@ -332,12 +305,20 @@ func TransformJarJar(ctx android.ModuleContext, classesJar android.Path, rulesFi
|
||||||
"rulesFile": rulesFile.String(),
|
"rulesFile": rulesFile.String(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return outputFile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type classpath []android.Path
|
type classpath []android.Path
|
||||||
|
|
||||||
|
// Returns a -sourcepath argument in the form javac expects. If the list is empty returns
|
||||||
|
// -sourcepath "" to ensure javac does not fall back to searching the classpath for sources.
|
||||||
|
func (x *classpath) JavaSourcepath() string {
|
||||||
|
if len(*x) > 0 {
|
||||||
|
return "-sourcepath " + strings.Join(x.Strings(), ":")
|
||||||
|
} else {
|
||||||
|
return `-sourcepath ""`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Returns a -classpath argument in the form java or javac expects
|
// Returns a -classpath argument in the form java or javac expects
|
||||||
func (x *classpath) JavaClasspath() string {
|
func (x *classpath) JavaClasspath() string {
|
||||||
if len(*x) > 0 {
|
if len(*x) > 0 {
|
||||||
|
|
11
java/gen.go
11
java/gen.go
|
@ -85,7 +85,7 @@ func genLogtags(ctx android.ModuleContext, logtagsFile android.Path) android.Pat
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||||
flags javaBuilderFlags) (android.Paths, android.Paths) {
|
flags javaBuilderFlags) (android.Paths, classpath) {
|
||||||
|
|
||||||
var protoFiles android.Paths
|
var protoFiles android.Paths
|
||||||
outSrcFiles := make(android.Paths, 0, len(srcFiles))
|
outSrcFiles := make(android.Paths, 0, len(srcFiles))
|
||||||
|
@ -106,16 +106,17 @@ func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var outSrcFileLists android.Paths
|
var outSrcJars classpath
|
||||||
|
|
||||||
if len(protoFiles) > 0 {
|
if len(protoFiles) > 0 {
|
||||||
protoFileList := genProto(ctx, protoFiles,
|
protoSrcJar := android.PathForModuleGen(ctx, "proto.src.jar")
|
||||||
|
genProto(ctx, protoSrcJar, protoFiles,
|
||||||
flags.protoFlags, flags.protoOutFlag, "")
|
flags.protoFlags, flags.protoOutFlag, "")
|
||||||
|
|
||||||
outSrcFileLists = append(outSrcFileLists, protoFileList)
|
outSrcJars = append(outSrcJars, protoSrcJar)
|
||||||
}
|
}
|
||||||
|
|
||||||
return outSrcFiles, outSrcFileLists
|
return outSrcFiles, outSrcJars
|
||||||
}
|
}
|
||||||
|
|
||||||
func LogtagsSingleton() blueprint.Singleton {
|
func LogtagsSingleton() blueprint.Singleton {
|
||||||
|
|
53
java/java.go
53
java/java.go
|
@ -169,9 +169,9 @@ type Module struct {
|
||||||
|
|
||||||
logtagsSrcs android.Paths
|
logtagsSrcs android.Paths
|
||||||
|
|
||||||
// filelists of extra source files that should be included in the javac command line,
|
// jars containing source files that should be included in the javac command line,
|
||||||
// for example R.java generated by aapt for android apps
|
// for example R.java generated by aapt for android apps
|
||||||
ExtraSrcLists android.Paths
|
ExtraSrcJars android.Paths
|
||||||
|
|
||||||
// installed file for binary dependency
|
// installed file for binary dependency
|
||||||
installFile android.Path
|
installFile android.Path
|
||||||
|
@ -370,7 +370,7 @@ type deps struct {
|
||||||
staticJars android.Paths
|
staticJars android.Paths
|
||||||
staticJarResources android.Paths
|
staticJarResources android.Paths
|
||||||
aidlIncludeDirs android.Paths
|
aidlIncludeDirs android.Paths
|
||||||
srcFileLists android.Paths
|
srcJars android.Paths
|
||||||
systemModules android.Path
|
systemModules android.Path
|
||||||
aidlPreprocess android.OptionalPath
|
aidlPreprocess android.OptionalPath
|
||||||
}
|
}
|
||||||
|
@ -422,7 +422,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
||||||
if ctx.ModuleName() == "framework" {
|
if ctx.ModuleName() == "framework" {
|
||||||
// framework.jar has a one-off dependency on the R.java and Manifest.java files
|
// framework.jar has a one-off dependency on the R.java and Manifest.java files
|
||||||
// generated by framework-res.apk
|
// generated by framework-res.apk
|
||||||
deps.srcFileLists = append(deps.srcFileLists, module.(*AndroidApp).aaptJavaFileList)
|
// TODO(ccross): aapt java files should go in a src jar
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
|
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
|
||||||
|
@ -483,13 +483,12 @@ func (j *Module) compile(ctx android.ModuleContext) {
|
||||||
flags = protoFlags(ctx, &j.protoProperties, flags)
|
flags = protoFlags(ctx, &j.protoProperties, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
var srcFileLists android.Paths
|
var srcJars classpath
|
||||||
|
srcFiles, srcJars = j.genSources(ctx, srcFiles, flags)
|
||||||
|
|
||||||
srcFiles, srcFileLists = j.genSources(ctx, srcFiles, flags)
|
srcJars = append(srcJars, deps.srcJars...)
|
||||||
|
|
||||||
srcFileLists = append(srcFileLists, deps.srcFileLists...)
|
srcJars = append(srcJars, j.ExtraSrcJars...)
|
||||||
|
|
||||||
srcFileLists = append(srcFileLists, j.ExtraSrcLists...)
|
|
||||||
|
|
||||||
var jars android.Paths
|
var jars android.Paths
|
||||||
|
|
||||||
|
@ -501,12 +500,14 @@ func (j *Module) compile(ctx android.ModuleContext) {
|
||||||
// a rebuild when error-prone is turned off).
|
// a rebuild when error-prone is turned off).
|
||||||
// TODO(ccross): Once we always compile with javac9 we may be able to conditionally
|
// TODO(ccross): Once we always compile with javac9 we may be able to conditionally
|
||||||
// enable error-prone without affecting the output class files.
|
// enable error-prone without affecting the output class files.
|
||||||
errorprone := RunErrorProne(ctx, srcFiles, srcFileLists, flags)
|
errorprone := android.PathForModuleOut(ctx, "classes-errorprone.list")
|
||||||
|
RunErrorProne(ctx, errorprone, srcFiles, srcJars, flags)
|
||||||
extraJarDeps = append(extraJarDeps, errorprone)
|
extraJarDeps = append(extraJarDeps, errorprone)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile java sources into .class files
|
// Compile java sources into .class files
|
||||||
classes := TransformJavaToClasses(ctx, srcFiles, srcFileLists, flags, extraJarDeps)
|
classes := android.PathForModuleOut(ctx, "classes-compiled.jar")
|
||||||
|
TransformJavaToClasses(ctx, classes, srcFiles, srcJars, flags, extraJarDeps)
|
||||||
if ctx.Failed() {
|
if ctx.Failed() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -533,7 +534,8 @@ func (j *Module) compile(ctx android.ModuleContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(resArgs) > 0 {
|
if len(resArgs) > 0 {
|
||||||
resourceJar := TransformResourcesToJar(ctx, resArgs, resDeps)
|
resourceJar := android.PathForModuleOut(ctx, "res.jar")
|
||||||
|
TransformResourcesToJar(ctx, resourceJar, resArgs, resDeps)
|
||||||
if ctx.Failed() {
|
if ctx.Failed() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -548,12 +550,23 @@ func (j *Module) compile(ctx android.ModuleContext) {
|
||||||
|
|
||||||
// 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.
|
||||||
outputFile := TransformJarsToJar(ctx, "classes.jar", jars, manifest, false)
|
var outputFile android.Path
|
||||||
|
|
||||||
|
if len(jars) == 1 && !manifest.Valid() {
|
||||||
|
// Optimization: skip the combine step if there is nothing to do
|
||||||
|
outputFile = jars[0]
|
||||||
|
} else {
|
||||||
|
combinedJar := android.PathForModuleOut(ctx, "classes.jar")
|
||||||
|
TransformJarsToJar(ctx, combinedJar, jars, manifest, false)
|
||||||
|
outputFile = combinedJar
|
||||||
|
}
|
||||||
|
|
||||||
if j.properties.Jarjar_rules != nil {
|
if j.properties.Jarjar_rules != nil {
|
||||||
jarjar_rules := android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules)
|
jarjar_rules := android.PathForModuleSrc(ctx, *j.properties.Jarjar_rules)
|
||||||
// Transform classes.jar into classes-jarjar.jar
|
// Transform classes.jar into classes-jarjar.jar
|
||||||
outputFile = TransformJarJar(ctx, outputFile, jarjar_rules)
|
jarjarFile := android.PathForModuleOut(ctx, "classes-jarjar.jar")
|
||||||
|
TransformJarJar(ctx, jarjarFile, outputFile, jarjar_rules)
|
||||||
|
outputFile = jarjarFile
|
||||||
if ctx.Failed() {
|
if ctx.Failed() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -609,13 +622,17 @@ func (j *Module) compile(ctx android.ModuleContext) {
|
||||||
|
|
||||||
flags.desugarFlags = strings.Join(desugarFlags, " ")
|
flags.desugarFlags = strings.Join(desugarFlags, " ")
|
||||||
|
|
||||||
desugarJar := TransformDesugar(ctx, outputFile, flags)
|
desugarJar := android.PathForModuleOut(ctx, "classes-desugar.jar")
|
||||||
|
TransformDesugar(ctx, desugarJar, outputFile, flags)
|
||||||
|
outputFile = desugarJar
|
||||||
if ctx.Failed() {
|
if ctx.Failed() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile classes.jar into classes.dex and then javalib.jar
|
// Compile classes.jar into classes.dex and then javalib.jar
|
||||||
outputFile = TransformClassesJarToDexJar(ctx, "javalib.jar", desugarJar, flags)
|
javalibJar := android.PathForModuleOut(ctx, "javalib.jar")
|
||||||
|
TransformClassesJarToDexJar(ctx, javalibJar, desugarJar, flags)
|
||||||
|
outputFile = javalibJar
|
||||||
if ctx.Failed() {
|
if ctx.Failed() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -790,7 +807,9 @@ func (j *Import) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||||
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
j.classpathFiles = android.PathsForModuleSrc(ctx, j.properties.Jars)
|
j.classpathFiles = android.PathsForModuleSrc(ctx, j.properties.Jars)
|
||||||
|
|
||||||
j.combinedClasspathFile = TransformJarsToJar(ctx, "classes.jar", j.classpathFiles, android.OptionalPath{}, false)
|
outputFile := android.PathForModuleOut(ctx, "classes.jar")
|
||||||
|
TransformJarsToJar(ctx, outputFile, j.classpathFiles, android.OptionalPath{}, false)
|
||||||
|
j.combinedClasspathFile = outputFile
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ Dependency = (*Import)(nil)
|
var _ Dependency = (*Import)(nil)
|
||||||
|
|
|
@ -30,20 +30,21 @@ var (
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: `rm -rf $outDir && mkdir -p $outDir && ` +
|
Command: `rm -rf $outDir && mkdir -p $outDir && ` +
|
||||||
`$protocCmd $protoOut=$protoOutFlags:$outDir $protoFlags $in && ` +
|
`$protocCmd $protoOut=$protoOutFlags:$outDir $protoFlags $in && ` +
|
||||||
`find $outDir -name "*.java" > $out`,
|
`${config.SoongZipCmd} -jar -o $out -C $outDir -D $outDir`,
|
||||||
CommandDeps: []string{"$protocCmd"},
|
CommandDeps: []string{
|
||||||
|
"$protocCmd",
|
||||||
|
"${config.SoongZipCmd}",
|
||||||
|
},
|
||||||
}, "protoFlags", "protoOut", "protoOutFlags", "outDir")
|
}, "protoFlags", "protoOut", "protoOutFlags", "outDir")
|
||||||
)
|
)
|
||||||
|
|
||||||
func genProto(ctx android.ModuleContext, protoFiles android.Paths,
|
func genProto(ctx android.ModuleContext, outputSrcJar android.WritablePath,
|
||||||
protoFlags string, protoOut, protoOutFlags string) android.WritablePath {
|
protoFiles android.Paths, protoFlags string, protoOut, protoOutFlags string) {
|
||||||
|
|
||||||
protoFileList := android.PathForModuleGen(ctx, "proto.filelist")
|
|
||||||
|
|
||||||
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
ctx.ModuleBuild(pctx, android.ModuleBuildParams{
|
||||||
Rule: proto,
|
Rule: proto,
|
||||||
Description: "protoc " + protoFiles[0].Rel(),
|
Description: "protoc " + protoFiles[0].Rel(),
|
||||||
Output: protoFileList,
|
Output: outputSrcJar,
|
||||||
Inputs: protoFiles,
|
Inputs: protoFiles,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"outDir": android.ProtoDir(ctx).String(),
|
"outDir": android.ProtoDir(ctx).String(),
|
||||||
|
@ -52,8 +53,6 @@ func genProto(ctx android.ModuleContext, protoFiles android.Paths,
|
||||||
"protoFlags": protoFlags,
|
"protoFlags": protoFlags,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
return protoFileList
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func protoDeps(ctx android.BottomUpMutatorContext, p *android.ProtoProperties) {
|
func protoDeps(ctx android.BottomUpMutatorContext, p *android.ProtoProperties) {
|
||||||
|
|
Loading…
Reference in New Issue