Convert droidstubs to android.RuleBuilder
The droiddoc rules are ripe for converting to android.RuleBuilder,
they conditionally use many input files which is hard to track
with the standard blueprint.Rule style, as the argument and the
dependency have to be handled independently. Start converting
to android.RuleBuilder by converting the droidstubs module.
Test: m docs
Test: m checkapi
Test: m updateapi
Change-Id: I08713e91149471e88a40115f69824cf5eaf88fb6
diff --git a/java/config/config.go b/java/config/config.go
index d017ae6..6a0a10a 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -47,6 +47,11 @@
}
)
+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")
@@ -69,8 +74,9 @@
// 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)
@@ -154,3 +160,41 @@
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"))
+ })
+}