From 3e3eda6eb616bda3fd3126381e3200f24461c10d Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 4 Nov 2021 10:22:51 -0700 Subject: [PATCH] Temporarily add method to get java binary tool cc binaries are moving from out/soong/host/linux-x86/bin to out/host/linux-86/bin first, to be followed by java binaries. Temporarily add a method that gets the java binary path while it is different from the cc binary path. Bug: 204136549 Test: m checkbuild Change-Id: I04a7e741436da6be68078f23d074870413a5bb5e --- android/config.go | 5 +++++ android/package_ctx.go | 10 ++++++++++ java/config/config.go | 4 ++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/android/config.go b/android/config.go index 78d43c6d4..3b5730091 100644 --- a/android/config.go +++ b/android/config.go @@ -585,6 +585,11 @@ func (c *config) HostJavaToolPath(ctx PathContext, path string) Path { return PathForOutput(ctx, "host", c.PrebuiltOS(), "framework", path) } +func (c *config) HostJavaBinToolPath(ctx PathContext, tool string) Path { + path := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "bin", false, tool) + return path +} + // PrebuiltOS returns the name of the host OS used in prebuilts directories. func (c *config) PrebuiltOS() string { switch runtime.GOOS { diff --git a/android/package_ctx.go b/android/package_ctx.go index c19debbb4..abd0c29da 100644 --- a/android/package_ctx.go +++ b/android/package_ctx.go @@ -177,6 +177,16 @@ func (p PackageContext) HostBinToolVariable(name, path string) blueprint.Variabl }) } +// HostJavaBinToolVariable returns a Variable whose value is the path to a host java tool +// in the bin directory for host java targets. It may only be called during a Go +// package's initialization - either from the init() function or as part of a +// package-scoped variable's initialization. +func (p PackageContext) HostJavaBinToolVariable(name, path string) blueprint.Variable { + return p.VariableFunc(name, func(ctx PackageVarContext) string { + return ctx.Config().HostJavaBinToolPath(ctx, path).String() + }) +} + // HostJNIToolVariable returns a Variable whose value is the path to a host tool // in the lib directory for host targets. It may only be called during a Go // package's initialization - either from the init() function or as part of a diff --git a/java/config/config.go b/java/config/config.go index 30c6f91aa..92d49a6cf 100644 --- a/java/config/config.go +++ b/java/config/config.go @@ -124,8 +124,8 @@ func init() { pctx.HostBinToolVariable("Zip2ZipCmd", "zip2zip") pctx.HostBinToolVariable("ZipSyncCmd", "zipsync") pctx.HostBinToolVariable("ApiCheckCmd", "apicheck") - pctx.HostBinToolVariable("D8Cmd", "d8") - pctx.HostBinToolVariable("R8Cmd", "r8-compat-proguard") + pctx.HostJavaBinToolVariable("D8Cmd", "d8") + pctx.HostJavaBinToolVariable("R8Cmd", "r8-compat-proguard") pctx.HostBinToolVariable("HiddenAPICmd", "hiddenapi") pctx.HostBinToolVariable("ExtractApksCmd", "extract_apks") pctx.VariableFunc("TurbineJar", func(ctx android.PackageVarContext) string {