summaryrefslogtreecommitdiff
path: root/build/art.go
diff options
context:
space:
mode:
author David Srbecky <dsrbecky@google.com> 2020-06-22 15:39:00 +0100
committer Treehugger Robot <treehugger-gerrit@google.com> 2020-06-24 19:45:23 +0000
commit1cf46a3342d8821fcdb700ada24ac272e85a2a39 (patch)
tree1357357f0bb79433672883c6949fdd86b896b256 /build/art.go
parent842e9c8c0affaff5253de233974c63ba7ba7f8b4 (diff)
Copy tools needed by host gtests to testcases directory.
Atest requires that everything is in the testcases directory. The files are not used yet (this is left to follow-up CLs). Bug: 147819342 Test: check the generated general-tests.zip ("m general-tests") Change-Id: Ied22a736e81a7cff03641d18bacd829b86a6ef0b
Diffstat (limited to 'build/art.go')
-rw-r--r--build/art.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/build/art.go b/build/art.go
index 5a09be0283..6b684c2504 100644
--- a/build/art.go
+++ b/build/art.go
@@ -17,6 +17,7 @@ package art
import (
"fmt"
"log"
+ "strings"
"sync"
"github.com/google/blueprint/proptools"
@@ -274,6 +275,32 @@ func testInstall(ctx android.InstallHookContext) {
testMap[name] = tests
}
+var testcasesContentKey = android.NewOnceKey("artTestcasesContent")
+
+func testcasesContent(config android.Config) map[string]string {
+ return config.Once(testcasesContentKey, func() interface{} {
+ return make(map[string]string)
+ }).(map[string]string)
+}
+
+// Binaries and libraries also need to be copied in the testcases directory for
+// running tests on host. This method adds module to the list of needed files.
+// The 'key' is the file in testcases and 'value' is the path to copy it from.
+// The actual copy will be done in make since soong does not do installations.
+func addTestcasesFile(ctx android.InstallHookContext) {
+ testcasesContent := testcasesContent(ctx.Config())
+
+ artTestMutex.Lock()
+ defer artTestMutex.Unlock()
+
+ if ctx.Os().Class == android.Host {
+ path := ctx.Path().ToMakePath().String()
+ parts := strings.Split(path, "/")
+ // Keep last two parts of the path (e.g. bin/dex2oat).
+ testcasesContent[strings.Join(parts[len(parts)-2:], "/")] = path
+ }
+}
+
var artTestMutex sync.Mutex
func init() {
@@ -392,6 +419,7 @@ func artLibrary() android.Module {
installCodegenCustomizer(module, staticAndSharedLibrary)
+ android.AddInstallHook(module, addTestcasesFile)
return module
}
@@ -408,6 +436,7 @@ func artBinary() android.Module {
android.AddLoadHook(module, customLinker)
android.AddLoadHook(module, prefer32Bit)
+ android.AddInstallHook(module, addTestcasesFile)
return module
}