From a3a828d637507b8300aee6588f4c933a6b96973f Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Wed, 23 Dec 2020 03:29:10 +0000 Subject: 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 --- build/art.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'build/art.go') diff --git a/build/art.go b/build/art.go index 4d491dcb75..a24da800f2 100644 --- a/build/art.go +++ b/build/art.go @@ -305,18 +305,23 @@ func testcasesContent(config android.Config) map[string]string { // 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 -- cgit v1.2.3-59-g8ed1b