From acfcc1f682072552b4c4d9af2f642f53bdbf3f43 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 25 Oct 2021 15:40:32 -0700 Subject: [PATCH] Move cc module installation into Soong Move cc module installation rules into Soong by overriding InstallBypassMake. Update the locations that find host tools to look in the Make installation directory instead of the Soong installation directory, which will no longer be used. The methods that find host tools are also used on go binaries, so update the config methods that tell Blueprint where to install go binaries to the Make installation directory too. Bug: 204136549 Test: m checkbuild Change-Id: Id172592c195e506102982a4af0084f6d9c68a896 --- android/config.go | 12 +++++++++++- android/paths.go | 3 +++ android/rule_builder.go | 8 ++++++++ cc/androidmk.go | 5 ----- cc/cc.go | 2 ++ ui/build/config.go | 6 +++++- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/android/config.go b/android/config.go index 3b5730091..1f96649d4 100644 --- a/android/config.go +++ b/android/config.go @@ -564,11 +564,18 @@ func (c *config) SetAllowMissingDependencies() { // BlueprintToolLocation returns the directory containing build system tools // from Blueprint, like soong_zip and merge_zips. func (c *config) HostToolDir() string { - return filepath.Join(c.soongOutDir, "host", c.PrebuiltOS(), "bin") + if c.KatiEnabled() { + return filepath.Join(c.outDir, "host", c.PrebuiltOS(), "bin") + } else { + return filepath.Join(c.soongOutDir, "host", c.PrebuiltOS(), "bin") + } } func (c *config) HostToolPath(ctx PathContext, tool string) Path { path := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "bin", false, tool) + if ctx.Config().KatiEnabled() { + path = path.ToMakePath() + } return path } @@ -578,6 +585,9 @@ func (c *config) HostJNIToolPath(ctx PathContext, lib string) Path { ext = ".dylib" } path := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "lib64", false, lib+ext) + if ctx.Config().KatiEnabled() { + path = path.ToMakePath() + } return path } diff --git a/android/paths.go b/android/paths.go index 69ab5f75c..82c8a2471 100644 --- a/android/paths.go +++ b/android/paths.go @@ -465,6 +465,9 @@ func (p OutputPaths) Strings() []string { // PathForGoBinary returns the path to the installed location of a bootstrap_go_binary module. func PathForGoBinary(ctx PathContext, goBinary bootstrap.GoBinaryTool) Path { goBinaryInstallDir := pathForInstall(ctx, ctx.Config().BuildOS, ctx.Config().BuildArch, "bin", false) + if ctx.Config().KatiEnabled() { + goBinaryInstallDir = goBinaryInstallDir.ToMakePath() + } rel := Rel(ctx, goBinaryInstallDir.String(), goBinary.InstallPath()) return goBinaryInstallDir.Join(ctx, rel) } diff --git a/android/rule_builder.go b/android/rule_builder.go index 1c6b1c086..f8de5fb96 100644 --- a/android/rule_builder.go +++ b/android/rule_builder.go @@ -839,6 +839,14 @@ func sboxPathForToolRel(ctx BuilderContext, path Path) string { // The tool is in the Soong output directory, it will be copied to __SBOX_OUT_DIR__/tools/out return filepath.Join(sboxToolsSubDir, "out", relOutSoong) } + if ctx.Config().KatiEnabled() { + toolDir = toolDir.ToMakePath() + relOut, isRelOut, _ := maybeRelErr(toolDir.String(), path.String()) + if isRelOut { + // The tool is in the Make output directory, it will be copied to __SBOX_OUT_DIR__/tools/out + return filepath.Join(sboxToolsSubDir, "out", relOut) + } + } // 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/cc/androidmk.go b/cc/androidmk.go index 93283d09d..5c4ef1705 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -450,11 +450,6 @@ func (installer *baseInstaller) AndroidMkEntries(ctx AndroidMkContext, entries * if installer.path == (android.InstallPath{}) { return } - // Soong installation is only supported for host modules. Have Make - // installation trigger Soong installation. - if ctx.Target().Os.Class == android.Host { - entries.OutputFile = android.OptionalPathForPath(installer.path) - } entries.ExtraEntries = append(entries.ExtraEntries, func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { path, file := filepath.Split(installer.path.ToMakePath().String()) diff --git a/cc/cc.go b/cc/cc.go index 32652c118..8915d6faa 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -1365,6 +1365,8 @@ func (c *Module) InstallInRoot() bool { return c.installer != nil && c.installer.installInRoot() } +func (c *Module) InstallBypassMake() bool { return true } + type baseModuleContext struct { android.BaseModuleContext moduleContextImpl diff --git a/ui/build/config.go b/ui/build/config.go index e0fa5034b..c30663349 100644 --- a/ui/build/config.go +++ b/ui/build/config.go @@ -786,7 +786,11 @@ func (c *configImpl) PrebuiltOS() string { } func (c *configImpl) HostToolDir() string { - return filepath.Join(c.SoongOutDir(), "host", c.PrebuiltOS(), "bin") + if c.SkipKatiNinja() { + return filepath.Join(c.SoongOutDir(), "host", c.PrebuiltOS(), "bin") + } else { + return filepath.Join(c.OutDir(), "host", c.PrebuiltOS(), "bin") + } } func (c *configImpl) NamedGlobFile(name string) string {