Loading android/onceper.go +10 −0 Original line number Original line Diff line number Diff line Loading @@ -95,6 +95,16 @@ func (once *OncePer) Once2StringSlice(key OnceKey, value func() ([]string, []str return s[0], s[1] 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. // OnceKey is an opaque type to be used as the key in calls to Once. type OnceKey struct { type OnceKey struct { key interface{} key interface{} Loading android/rule_builder.go +10 −0 Original line number Original line Diff line number Diff line Loading @@ -478,6 +478,16 @@ func (c *RuleBuilderCommand) Flag(flag string) *RuleBuilderCommand { return c.Text(flag) 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 // 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. // rule will not have them listed in its dependencies or outputs. func (c *RuleBuilderCommand) Flags(flags []string) *RuleBuilderCommand { func (c *RuleBuilderCommand) Flags(flags []string) *RuleBuilderCommand { Loading java/builder.go +31 −28 Original line number Original line Diff line number Diff line Loading @@ -153,8 +153,7 @@ type javaBuilderFlags struct { classpath classpath classpath classpath processorPath classpath processorPath classpath processor string processor string systemModules classpath systemModules *systemModules systemModulesDeps android.Paths aidlFlags string aidlFlags string aidlDeps android.Paths aidlDeps android.Paths javaVersion string javaVersion string Loading Loading @@ -249,8 +248,9 @@ func transformJavaToClasses(ctx android.ModuleContext, outputFile android.Writab var bootClasspath string var bootClasspath string if flags.javaVersion == "1.9" { if flags.javaVersion == "1.9" { deps = append(deps, flags.systemModulesDeps...) var systemModuleDeps android.Paths bootClasspath = flags.systemModules.FormJavaSystemModulesPath("--system=", ctx.Device()) bootClasspath, systemModuleDeps = flags.systemModules.FormJavaSystemModulesPath(ctx.Device()) deps = append(deps, systemModuleDeps...) } else { } else { deps = append(deps, flags.bootClasspath...) deps = append(deps, flags.bootClasspath...) if len(flags.bootClasspath) == 0 && ctx.Device() { if len(flags.bootClasspath) == 0 && ctx.Device() { Loading Loading @@ -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 { func (x *classpath) FormJavaClassPath(optName string) string { if optName != "" && !strings.HasSuffix(optName, "=") && !strings.HasSuffix(optName, " ") { if optName != "" && !strings.HasSuffix(optName, "=") && !strings.HasSuffix(optName, " ") { Loading @@ -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 { func (x *classpath) FormTurbineClasspath(optName string) []string { if x == nil || *x == nil { if x == nil || *x == nil { return nil return nil Loading Loading @@ -466,3 +451,21 @@ func (x *classpath) Strings() []string { } } return ret 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 } } java/config/config.go +46 −2 Original line number Original line Diff line number Diff line Loading @@ -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() { func init() { pctx.Import("github.com/google/blueprint/bootstrap") pctx.Import("github.com/google/blueprint/bootstrap") Loading @@ -70,8 +75,9 @@ func init() { // b/65004097: prevent using java.lang.invoke.StringConcatFactory when using -target 1.9 // b/65004097: prevent using java.lang.invoke.StringConcatFactory when using -target 1.9 `-XDstringConcat=inline`, `-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) pctx.VariableConfigMethod("hostPrebuiltTag", android.Config.PrebuiltOS) Loading Loading @@ -155,3 +161,41 @@ func init() { pctx.HostBinToolVariable("Class2Greylist", "class2greylist") pctx.HostBinToolVariable("Class2Greylist", "class2greylist") pctx.HostBinToolVariable("HiddenAPI", "hiddenapi") 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")) }) } Loading
android/onceper.go +10 −0 Original line number Original line Diff line number Diff line Loading @@ -95,6 +95,16 @@ func (once *OncePer) Once2StringSlice(key OnceKey, value func() ([]string, []str return s[0], s[1] 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. // OnceKey is an opaque type to be used as the key in calls to Once. type OnceKey struct { type OnceKey struct { key interface{} key interface{} Loading
android/rule_builder.go +10 −0 Original line number Original line Diff line number Diff line Loading @@ -478,6 +478,16 @@ func (c *RuleBuilderCommand) Flag(flag string) *RuleBuilderCommand { return c.Text(flag) 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 // 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. // rule will not have them listed in its dependencies or outputs. func (c *RuleBuilderCommand) Flags(flags []string) *RuleBuilderCommand { func (c *RuleBuilderCommand) Flags(flags []string) *RuleBuilderCommand { Loading
java/builder.go +31 −28 Original line number Original line Diff line number Diff line Loading @@ -153,8 +153,7 @@ type javaBuilderFlags struct { classpath classpath classpath classpath processorPath classpath processorPath classpath processor string processor string systemModules classpath systemModules *systemModules systemModulesDeps android.Paths aidlFlags string aidlFlags string aidlDeps android.Paths aidlDeps android.Paths javaVersion string javaVersion string Loading Loading @@ -249,8 +248,9 @@ func transformJavaToClasses(ctx android.ModuleContext, outputFile android.Writab var bootClasspath string var bootClasspath string if flags.javaVersion == "1.9" { if flags.javaVersion == "1.9" { deps = append(deps, flags.systemModulesDeps...) var systemModuleDeps android.Paths bootClasspath = flags.systemModules.FormJavaSystemModulesPath("--system=", ctx.Device()) bootClasspath, systemModuleDeps = flags.systemModules.FormJavaSystemModulesPath(ctx.Device()) deps = append(deps, systemModuleDeps...) } else { } else { deps = append(deps, flags.bootClasspath...) deps = append(deps, flags.bootClasspath...) if len(flags.bootClasspath) == 0 && ctx.Device() { if len(flags.bootClasspath) == 0 && ctx.Device() { Loading Loading @@ -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 { func (x *classpath) FormJavaClassPath(optName string) string { if optName != "" && !strings.HasSuffix(optName, "=") && !strings.HasSuffix(optName, " ") { if optName != "" && !strings.HasSuffix(optName, "=") && !strings.HasSuffix(optName, " ") { Loading @@ -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 { func (x *classpath) FormTurbineClasspath(optName string) []string { if x == nil || *x == nil { if x == nil || *x == nil { return nil return nil Loading Loading @@ -466,3 +451,21 @@ func (x *classpath) Strings() []string { } } return ret 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 } }
java/config/config.go +46 −2 Original line number Original line Diff line number Diff line Loading @@ -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() { func init() { pctx.Import("github.com/google/blueprint/bootstrap") pctx.Import("github.com/google/blueprint/bootstrap") Loading @@ -70,8 +75,9 @@ func init() { // b/65004097: prevent using java.lang.invoke.StringConcatFactory when using -target 1.9 // b/65004097: prevent using java.lang.invoke.StringConcatFactory when using -target 1.9 `-XDstringConcat=inline`, `-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) pctx.VariableConfigMethod("hostPrebuiltTag", android.Config.PrebuiltOS) Loading Loading @@ -155,3 +161,41 @@ func init() { pctx.HostBinToolVariable("Class2Greylist", "class2greylist") pctx.HostBinToolVariable("Class2Greylist", "class2greylist") pctx.HostBinToolVariable("HiddenAPI", "hiddenapi") 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")) }) }