From 790ef35d1e7c87fd738cc1dcee45b031d21de600 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 25 Oct 2021 19:15:55 -0700 Subject: [PATCH] Make HostToolPath, HostJNIToolPath and sboxPathForToolRel use pathForInstall Use pathForInstall instead of PathForOutput for HostToolPath, HostJNIToolPath and sboxPathForToolRel so that they internally produce an InstallPath that can later support being converted to Make install path. Bug: 204136549 Test: m checkbuild Change-Id: Ie16a62641d113873daeec4d1dd4261251bc0d0eb --- android/config.go | 12 +++++++----- android/rule_builder.go | 9 +++++---- apex/builder.go | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/android/config.go b/android/config.go index c8d7cfdc9..95d93c0de 100644 --- a/android/config.go +++ b/android/config.go @@ -355,14 +355,14 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string config.bp2buildModuleTypeConfig = map[string]bool{} + determineBuildOS(config) + return Config{config} } func modifyTestConfigToSupportArchMutator(testConfig Config) { config := testConfig.config - determineBuildOS(config) - config.Targets = map[OsType][]Target{ Android: []Target{ {Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", "", false}, @@ -568,15 +568,17 @@ func (c *config) HostToolDir() string { } func (c *config) HostToolPath(ctx PathContext, tool string) Path { - return PathForOutput(ctx, "host", c.PrebuiltOS(), "bin", tool) + path := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "bin", false, tool) + return path } -func (c *config) HostJNIToolPath(ctx PathContext, path string) Path { +func (c *config) HostJNIToolPath(ctx PathContext, lib string) Path { ext := ".so" if runtime.GOOS == "darwin" { ext = ".dylib" } - return PathForOutput(ctx, "host", c.PrebuiltOS(), "lib64", path+ext) + path := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "lib64", false, lib+ext) + return path } func (c *config) HostJavaToolPath(ctx PathContext, path string) Path { diff --git a/android/rule_builder.go b/android/rule_builder.go index c9a9ddd31..1c6b1c086 100644 --- a/android/rule_builder.go +++ b/android/rule_builder.go @@ -833,10 +833,11 @@ func (c *RuleBuilderCommand) PathForOutput(path WritablePath) string { func sboxPathForToolRel(ctx BuilderContext, path Path) string { // Errors will be handled in RuleBuilder.Build where we have a context to report them - relOut, isRelOut, _ := maybeRelErr(PathForOutput(ctx, "host", ctx.Config().PrebuiltOS()).String(), path.String()) - if isRelOut { - // The tool is in the output directory, it will be copied to __SBOX_OUT_DIR__/tools/out - return filepath.Join(sboxToolsSubDir, "out", relOut) + toolDir := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "", false) + relOutSoong, isRelOutSoong, _ := maybeRelErr(toolDir.String(), path.String()) + if isRelOutSoong { + // The tool is in the Soong output directory, it will be copied to __SBOX_OUT_DIR__/tools/out + return filepath.Join(sboxToolsSubDir, "out", relOutSoong) } // The tool is in the source directory, it will be copied to __SBOX_OUT_DIR__/tools/src return filepath.Join(sboxToolsSubDir, "src", path.String()) diff --git a/apex/builder.go b/apex/builder.go index 772f7897a..0d984c0b2 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -524,7 +524,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) { } unsignedOutputFile := android.PathForModuleOut(ctx, a.Name()+suffix+".unsigned") - outHostBinDir := android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "bin").String() + outHostBinDir := ctx.Config().HostToolPath(ctx, "").String() prebuiltSdkToolsBinDir := filepath.Join("prebuilts", "sdk", "tools", runtime.GOOS, "bin") // Figure out if need to compress apex.