From b309240781b17ee994d088648d5fc76814dde436 Mon Sep 17 00:00:00 2001 From: Martin Stjernholm Date: Fri, 4 Sep 2020 00:49:44 +0100 Subject: Fix libnativeloader unit tests being skipped. ART_TARGET_ANDROID was only defined in art_defaults, which wasn't imported into libnativeloader_test. However doing that imports a lot of stuff, including compiler pickiness that doesn't work with cxxabi.h included via gtest.h. We instead make ART_TARGET_(ANDROID|LINUX) implicitly defined in all art_cc_* module types. These tests have probably not run since https://r.android.com/1295365. Also fixed the accumulated bitrot. Test: atest libnativeloader_test, check that 25 tests pass. Test: Plant a test failure in native_loader_test.cpp, check that presubmit fails. Bug: 154074847 Bug: 137356719 Change-Id: I4e9d4dc8d78c91a7b750b8de0ab7db2114b154ac --- build/art.go | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'build/art.go') diff --git a/build/art.go b/build/art.go index 6e9e9fda6e..4d491dcb75 100644 --- a/build/art.go +++ b/build/art.go @@ -132,11 +132,6 @@ func deviceFlags(ctx android.LoadHookContext) []string { ) cflags = append(cflags, "-DART_BASE_ADDRESS="+ctx.Config().LibartImgDeviceBaseAddress()) - if ctx.Config().IsEnvTrue("ART_TARGET_LINUX") { - cflags = append(cflags, "-DART_TARGET_LINUX") - } else { - cflags = append(cflags, "-DART_TARGET_ANDROID") - } minDelta := ctx.Config().GetenvWithDefault("LIBART_IMG_TARGET_MIN_BASE_ADDRESS_DELTA", "-0x1000000") maxDelta := ctx.Config().GetenvWithDefault("LIBART_IMG_TARGET_MAX_BASE_ADDRESS_DELTA", "0x1000000") cflags = append(cflags, "-DART_BASE_ADDRESS_MIN_DELTA="+minDelta) @@ -207,6 +202,26 @@ func globalDefaults(ctx android.LoadHookContext) { ctx.AppendProperties(p) } +// Hook that adds flags that are implicit for all cc_art_* modules. +func addImplicitFlags(ctx android.LoadHookContext) { + type props struct { + Target struct { + Android struct { + Cflags []string + } + } + } + + p := &props{} + if ctx.Config().IsEnvTrue("ART_TARGET_LINUX") { + p.Target.Android.Cflags = []string{"-DART_TARGET", "-DART_TARGET_LINUX"} + } else { + p.Target.Android.Cflags = []string{"-DART_TARGET", "-DART_TARGET_ANDROID"} + } + + ctx.AppendProperties(p) +} + func debugDefaults(ctx android.LoadHookContext) { type props struct { Cflags []string @@ -381,6 +396,7 @@ func artHostTestApexBundleFactory() android.Module { func artGlobalDefaultsFactory() android.Module { module := artDefaultsFactory() + android.AddLoadHook(module, addImplicitFlags) android.AddLoadHook(module, globalDefaults) return module @@ -422,6 +438,7 @@ func artLibrary() android.Module { installCodegenCustomizer(module, staticAndSharedLibrary) + android.AddLoadHook(module, addImplicitFlags) android.AddInstallHook(module, addTestcasesFile) return module } @@ -431,12 +448,14 @@ func artStaticLibrary() android.Module { installCodegenCustomizer(module, staticLibrary) + android.AddLoadHook(module, addImplicitFlags) return module } func artBinary() android.Module { module := cc.BinaryFactory() + android.AddLoadHook(module, addImplicitFlags) android.AddLoadHook(module, customLinker) android.AddLoadHook(module, prefer32Bit) android.AddInstallHook(module, addTestcasesFile) @@ -448,6 +467,7 @@ func artTest() android.Module { installCodegenCustomizer(module, binary) + android.AddLoadHook(module, addImplicitFlags) android.AddLoadHook(module, customLinker) android.AddLoadHook(module, prefer32Bit) android.AddInstallHook(module, testInstall) @@ -459,6 +479,7 @@ func artTestLibrary() android.Module { installCodegenCustomizer(module, staticAndSharedLibrary) + android.AddLoadHook(module, addImplicitFlags) android.AddLoadHook(module, prefer32Bit) android.AddInstallHook(module, testInstall) return module -- cgit v1.2.3-59-g8ed1b