Fix to not copy pseudo-random module variants to art-test-cases.zip.
The install hook can be called for more than one module variant for the
same library (for host). In that case it would just copy the last one,
which may be some sanitizer variant that won't work.
The install hook needs to check the SkipInstall flag to pick the right
variant.
This patch also limits the copying to the BuildOs variants, since the
OsClass "host" is used for Windows as well.
Also error out if conflicting source paths are detected, so this error
can't slip by unnoticed.
Test: m nothing
Test: m art-host-tests
unzip out/target/product/vsoc_x86/art-host-tests.zip
host/testcases/art_common/out/host/linux-x86/bin/dexdiag
Check that dexdiag runs without linker symbol error.
Test: Check that testcasesContent() returns the same number of entries
before and after the IsSkipInstall() filter.
Bug: 176192921
Change-Id: Ief8168e223fc196a49fa266aae38fead71e574ae
diff --git a/build/art.go b/build/art.go
index 4d491dc..a24da80 100644
--- a/build/art.go
+++ b/build/art.go
@@ -305,18 +305,23 @@
// 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) {
+ if ctx.Os() != android.BuildOs || ctx.Module().IsSkipInstall() {
+ return
+ }
+
testcasesContent := testcasesContent(ctx.Config())
artTestMutex.Lock()
defer artTestMutex.Unlock()
- if ctx.Os().Class == android.Host {
- src := ctx.SrcPath().String()
- path := strings.Split(ctx.Path().ToMakePath().String(), "/")
- // Keep last two parts of the install path (e.g. bin/dex2oat).
- dst := strings.Join(path[len(path)-2:], "/")
- testcasesContent[dst] = src
+ src := ctx.SrcPath().String()
+ path := strings.Split(ctx.Path().ToMakePath().String(), "/")
+ // Keep last two parts of the install path (e.g. bin/dex2oat).
+ dst := strings.Join(path[len(path)-2:], "/")
+ if oldSrc, ok := testcasesContent[dst]; ok {
+ ctx.ModuleErrorf("Conflicting sources for %s: %s and %s", dst, oldSrc, src)
}
+ testcasesContent[dst] = src
}
var artTestMutex sync.Mutex