Merge changes Ic2a585ea,I11ccabc4,Icc932c4a,I020556c7,I08713e91
am: ed9a92c311
Change-Id: I0367335939181566063b777184e864a7afb02308
This commit is contained in:
commit
a373a94fc0
7 changed files with 720 additions and 692 deletions
|
@ -95,6 +95,16 @@ func (once *OncePer) Once2StringSlice(key OnceKey, value func() ([]string, []str
|
|||
return s[0], s[1]
|
||||
}
|
||||
|
||||
// OncePath is the same as Once, but returns the value cast to a Path
|
||||
func (once *OncePer) OncePath(key OnceKey, value func() Path) Path {
|
||||
return once.Once(key, func() interface{} { return value() }).(Path)
|
||||
}
|
||||
|
||||
// OncePath is the same as Once, but returns the value cast to a SourcePath
|
||||
func (once *OncePer) OnceSourcePath(key OnceKey, value func() SourcePath) SourcePath {
|
||||
return once.Once(key, func() interface{} { return value() }).(SourcePath)
|
||||
}
|
||||
|
||||
// OnceKey is an opaque type to be used as the key in calls to Once.
|
||||
type OnceKey struct {
|
||||
key interface{}
|
||||
|
|
|
@ -478,6 +478,16 @@ func (c *RuleBuilderCommand) Flag(flag string) *RuleBuilderCommand {
|
|||
return c.Text(flag)
|
||||
}
|
||||
|
||||
// OptionalFlag adds the specified raw text to the command line if it is not nil. The text should not contain input or
|
||||
// output paths or the rule will not have them listed in its dependencies or outputs.
|
||||
func (c *RuleBuilderCommand) OptionalFlag(flag *string) *RuleBuilderCommand {
|
||||
if flag != nil {
|
||||
c.Text(*flag)
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
// Flags adds the specified raw text to the command line. The text should not contain input or output paths or the
|
||||
// rule will not have them listed in its dependencies or outputs.
|
||||
func (c *RuleBuilderCommand) Flags(flags []string) *RuleBuilderCommand {
|
||||
|
|
|
@ -148,16 +148,15 @@ func init() {
|
|||
}
|
||||
|
||||
type javaBuilderFlags struct {
|
||||
javacFlags string
|
||||
bootClasspath classpath
|
||||
classpath classpath
|
||||
processorPath classpath
|
||||
processor string
|
||||
systemModules classpath
|
||||
systemModulesDeps android.Paths
|
||||
aidlFlags string
|
||||
aidlDeps android.Paths
|
||||
javaVersion string
|
||||
javacFlags string
|
||||
bootClasspath classpath
|
||||
classpath classpath
|
||||
processorPath classpath
|
||||
processor string
|
||||
systemModules *systemModules
|
||||
aidlFlags string
|
||||
aidlDeps android.Paths
|
||||
javaVersion string
|
||||
|
||||
errorProneExtraJavacFlags string
|
||||
errorProneProcessorPath classpath
|
||||
|
@ -249,8 +248,9 @@ func transformJavaToClasses(ctx android.ModuleContext, outputFile android.Writab
|
|||
|
||||
var bootClasspath string
|
||||
if flags.javaVersion == "1.9" {
|
||||
deps = append(deps, flags.systemModulesDeps...)
|
||||
bootClasspath = flags.systemModules.FormJavaSystemModulesPath("--system=", ctx.Device())
|
||||
var systemModuleDeps android.Paths
|
||||
bootClasspath, systemModuleDeps = flags.systemModules.FormJavaSystemModulesPath(ctx.Device())
|
||||
deps = append(deps, systemModuleDeps...)
|
||||
} else {
|
||||
deps = append(deps, flags.bootClasspath...)
|
||||
if len(flags.bootClasspath) == 0 && ctx.Device() {
|
||||
|
@ -411,7 +411,7 @@ func TransformZipAlign(ctx android.ModuleContext, outputFile android.WritablePat
|
|||
})
|
||||
}
|
||||
|
||||
type classpath []android.Path
|
||||
type classpath android.Paths
|
||||
|
||||
func (x *classpath) FormJavaClassPath(optName string) string {
|
||||
if optName != "" && !strings.HasSuffix(optName, "=") && !strings.HasSuffix(optName, " ") {
|
||||
|
@ -424,21 +424,6 @@ func (x *classpath) FormJavaClassPath(optName string) string {
|
|||
}
|
||||
}
|
||||
|
||||
// Returns a --system argument in the form javac expects with -source 1.9. If forceEmpty is true,
|
||||
// returns --system=none if the list is empty to ensure javac does not fall back to the default
|
||||
// system modules.
|
||||
func (x *classpath) FormJavaSystemModulesPath(optName string, forceEmpty bool) string {
|
||||
if len(*x) > 1 {
|
||||
panic("more than one system module")
|
||||
} else if len(*x) == 1 {
|
||||
return optName + (*x)[0].String()
|
||||
} else if forceEmpty {
|
||||
return optName + "none"
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (x *classpath) FormTurbineClasspath(optName string) []string {
|
||||
if x == nil || *x == nil {
|
||||
return nil
|
||||
|
@ -466,3 +451,21 @@ func (x *classpath) Strings() []string {
|
|||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
type systemModules struct {
|
||||
dir android.Path
|
||||
deps android.Paths
|
||||
}
|
||||
|
||||
// Returns a --system argument in the form javac expects with -source 1.9. If forceEmpty is true,
|
||||
// returns --system=none if the list is empty to ensure javac does not fall back to the default
|
||||
// system modules.
|
||||
func (x *systemModules) FormJavaSystemModulesPath(forceEmpty bool) (string, android.Paths) {
|
||||
if x != nil {
|
||||
return "--system=" + x.dir.String(), x.deps
|
||||
} else if forceEmpty {
|
||||
return "--system=none", nil
|
||||
} else {
|
||||
return "", nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,11 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
const (
|
||||
JavaVmFlags = `-XX:OnError="cat hs_err_pid%p.log" -XX:CICompilerCount=6 -XX:+UseDynamicNumberOfGCThreads`
|
||||
JavacVmFlags = `-J-XX:OnError="cat hs_err_pid%p.log" -J-XX:CICompilerCount=6 -J-XX:+UseDynamicNumberOfGCThreads`
|
||||
)
|
||||
|
||||
func init() {
|
||||
pctx.Import("github.com/google/blueprint/bootstrap")
|
||||
|
||||
|
@ -70,8 +75,9 @@ func init() {
|
|||
// b/65004097: prevent using java.lang.invoke.StringConcatFactory when using -target 1.9
|
||||
`-XDstringConcat=inline`,
|
||||
}, " "))
|
||||
pctx.StaticVariable("JavaVmFlags", "-XX:OnError=\"cat hs_err_pid%p.log\" -XX:CICompilerCount=6 -XX:+UseDynamicNumberOfGCThreads")
|
||||
pctx.StaticVariable("JavacVmFlags", "-J-XX:OnError=\"cat hs_err_pid%p.log\" -J-XX:CICompilerCount=6 -J-XX:+UseDynamicNumberOfGCThreads")
|
||||
|
||||
pctx.StaticVariable("JavaVmFlags", JavaVmFlags)
|
||||
pctx.StaticVariable("JavacVmFlags", JavacVmFlags)
|
||||
|
||||
pctx.VariableConfigMethod("hostPrebuiltTag", android.Config.PrebuiltOS)
|
||||
|
||||
|
@ -155,3 +161,41 @@ func init() {
|
|||
pctx.HostBinToolVariable("Class2Greylist", "class2greylist")
|
||||
pctx.HostBinToolVariable("HiddenAPI", "hiddenapi")
|
||||
}
|
||||
|
||||
// JavaCmd returns a SourcePath object with the path to the java command.
|
||||
func JavaCmd(ctx android.PathContext) android.SourcePath {
|
||||
return javaTool(ctx, "java")
|
||||
}
|
||||
|
||||
// JavadocCmd returns a SourcePath object with the path to the java command.
|
||||
func JavadocCmd(ctx android.PathContext) android.SourcePath {
|
||||
return javaTool(ctx, "javadoc")
|
||||
}
|
||||
|
||||
func javaTool(ctx android.PathContext, tool string) android.SourcePath {
|
||||
type javaToolKey string
|
||||
|
||||
key := android.NewCustomOnceKey(javaToolKey(tool))
|
||||
|
||||
return ctx.Config().OnceSourcePath(key, func() android.SourcePath {
|
||||
return javaToolchain(ctx).Join(ctx, tool)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
var javaToolchainKey = android.NewOnceKey("javaToolchain")
|
||||
|
||||
func javaToolchain(ctx android.PathContext) android.SourcePath {
|
||||
return ctx.Config().OnceSourcePath(javaToolchainKey, func() android.SourcePath {
|
||||
return javaHome(ctx).Join(ctx, "bin")
|
||||
})
|
||||
}
|
||||
|
||||
var javaHomeKey = android.NewOnceKey("javaHome")
|
||||
|
||||
func javaHome(ctx android.PathContext) android.SourcePath {
|
||||
return ctx.Config().OnceSourcePath(javaHomeKey, func() android.SourcePath {
|
||||
// This is set up and guaranteed by soong_ui
|
||||
return android.PathForSource(ctx, ctx.Config().Getenv("ANDROID_JAVA_HOME"))
|
||||
})
|
||||
}
|
||||
|
|
1269
java/droiddoc.go
1269
java/droiddoc.go
File diff suppressed because it is too large
Load diff
11
java/java.go
11
java/java.go
|
@ -632,8 +632,7 @@ type deps struct {
|
|||
aidlIncludeDirs android.Paths
|
||||
srcs android.Paths
|
||||
srcJars android.Paths
|
||||
systemModules android.Path
|
||||
systemModulesDeps android.Paths
|
||||
systemModules *systemModules
|
||||
aidlPreprocess android.OptionalPath
|
||||
kotlinStdlib android.Paths
|
||||
kotlinAnnotations android.Paths
|
||||
|
@ -844,8 +843,7 @@ func (j *Module) collectDeps(ctx android.ModuleContext) deps {
|
|||
if sm.outputDir == nil || len(sm.outputDeps) == 0 {
|
||||
panic("Missing directory for system module dependency")
|
||||
}
|
||||
deps.systemModules = sm.outputDir
|
||||
deps.systemModulesDeps = sm.outputDeps
|
||||
deps.systemModules = &systemModules{sm.outputDir, sm.outputDeps}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -973,10 +971,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
|
|||
}
|
||||
|
||||
// systemModules
|
||||
if deps.systemModules != nil {
|
||||
flags.systemModules = append(flags.systemModules, deps.systemModules)
|
||||
flags.systemModulesDeps = append(flags.systemModulesDeps, deps.systemModulesDeps...)
|
||||
}
|
||||
flags.systemModules = deps.systemModules
|
||||
|
||||
// aidl flags.
|
||||
flags.aidlFlags, flags.aidlDeps = j.aidlFlags(ctx, deps.aidlPreprocess, deps.aidlIncludeDirs)
|
||||
|
|
|
@ -783,11 +783,6 @@ func TestDroiddoc(t *testing.T) {
|
|||
}
|
||||
`)
|
||||
|
||||
stubsJar := filepath.Join(buildDir, ".intermediates", "bar-doc", "android_common", "bar-doc-stubs.srcjar")
|
||||
barDoc := ctx.ModuleForTests("bar-doc", "android_common").Output("bar-doc-stubs.srcjar")
|
||||
if stubsJar != barDoc.Output.String() {
|
||||
t.Errorf("expected stubs Jar [%q], got %q", stubsJar, barDoc.Output.String())
|
||||
}
|
||||
inputs := ctx.ModuleForTests("bar-doc", "android_common").Rule("javadoc").Inputs
|
||||
var javaSrcs []string
|
||||
for _, i := range inputs {
|
||||
|
|
Loading…
Reference in a new issue