Fix turbine classpath arguments

We were passing "--classpath foo.jar --classpath bar.jar" to turbine,
it now wants (and may always have expected?)
"--classpath foo.jar bar.jar".

Test: m checkbuild
Change-Id: Ib7e0ca64a34e236110f7b785d6a0fb51ed75567e
This commit is contained in:
Colin Cross 2019-10-31 15:22:57 -07:00
parent c48ea97c9c
commit c2557d1d56
3 changed files with 16 additions and 8 deletions

View File

@ -313,7 +313,7 @@ func TransformJavaToHeaderClasses(ctx android.ModuleContext, outputFile android.
// ensure turbine does not fall back to the default bootclasspath.
bootClasspath = `--bootclasspath ""`
} else {
bootClasspath = strings.Join(flags.bootClasspath.FormTurbineClasspath("--bootclasspath "), " ")
bootClasspath = flags.bootClasspath.FormTurbineClassPath("--bootclasspath ")
}
}
@ -330,7 +330,7 @@ func TransformJavaToHeaderClasses(ctx android.ModuleContext, outputFile android.
"javacFlags": flags.javacFlags,
"bootClasspath": bootClasspath,
"srcJars": strings.Join(srcJars.Strings(), " "),
"classpath": strings.Join(classpath.FormTurbineClasspath("--classpath "), " "),
"classpath": classpath.FormTurbineClassPath("--classpath "),
"outDir": android.PathForModuleOut(ctx, "turbine", "classes").String(),
"javaVersion": flags.javaVersion.String(),
},
@ -523,18 +523,26 @@ func TransformZipAlign(ctx android.ModuleContext, outputFile android.WritablePat
type classpath android.Paths
func (x *classpath) FormJavaClassPath(optName string) string {
func (x *classpath) formJoinedClassPath(optName string, sep string) string {
if optName != "" && !strings.HasSuffix(optName, "=") && !strings.HasSuffix(optName, " ") {
optName += " "
}
if len(*x) > 0 {
return optName + strings.Join(x.Strings(), ":")
return optName + strings.Join(x.Strings(), sep)
} else {
return ""
}
}
func (x *classpath) FormJavaClassPath(optName string) string {
return x.formJoinedClassPath(optName, ":")
}
func (x *classpath) FormTurbineClasspath(optName string) []string {
func (x *classpath) FormTurbineClassPath(optName string) string {
return x.formJoinedClassPath(optName, " ")
}
// FormRepeatedClassPath returns a list of arguments with the given optName prefixed to each element of the classpath.
func (x *classpath) FormRepeatedClassPath(optName string) []string {
if x == nil || *x == nil {
return nil
}

View File

@ -85,8 +85,8 @@ func (j *Module) dexCommonFlags(ctx android.ModuleContext) []string {
func (j *Module) d8Flags(ctx android.ModuleContext, flags javaBuilderFlags) ([]string, android.Paths) {
d8Flags := j.dexCommonFlags(ctx)
d8Flags = append(d8Flags, flags.bootClasspath.FormTurbineClasspath("--lib ")...)
d8Flags = append(d8Flags, flags.classpath.FormTurbineClasspath("--lib ")...)
d8Flags = append(d8Flags, flags.bootClasspath.FormRepeatedClassPath("--lib ")...)
d8Flags = append(d8Flags, flags.classpath.FormRepeatedClassPath("--lib ")...)
var d8Deps android.Paths
d8Deps = append(d8Deps, flags.bootClasspath...)

View File

@ -133,7 +133,7 @@ func kotlinKapt(ctx android.ModuleContext, outputFile android.WritablePath,
deps = append(deps, srcJars...)
deps = append(deps, flags.processorPath...)
kaptProcessorPath := flags.processorPath.FormTurbineClasspath("-P plugin:org.jetbrains.kotlin.kapt3:apclasspath=")
kaptProcessorPath := flags.processorPath.FormRepeatedClassPath("-P plugin:org.jetbrains.kotlin.kapt3:apclasspath=")
kaptProcessor := ""
if flags.processor != "" {