From 067b88976206266082762a3ba757088b7db83ab6 Mon Sep 17 00:00:00 2001 From: Liz Kammer Date: Fri, 16 Jul 2021 11:01:46 -0400 Subject: [PATCH] Correct isThirdParty check Previously, isThirdParty check was over-selecting for third-party-ness, the only non-third-party paths were those explicitly excluded from typically third party directories, results in ~all code being considered third party. Updated test to ensure bionic is not considered third party, which fails without this change. Test: go soong tests Change-Id: Id371aaad2ceef2b3163384fa84712397877cbe90 --- cc/cc_test.go | 59 ++++++++++++++++++++++++--------------------- cc/compiler.go | 3 ++- cc/compiler_test.go | 9 ++++--- 3 files changed, 38 insertions(+), 33 deletions(-) diff --git a/cc/cc_test.go b/cc/cc_test.go index dd51fe853..84c3a869c 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -3955,10 +3955,13 @@ func TestIncludeDirectoryOrdering(t *testing.T) { `, lib, lib) } - ctx := PrepareForIntegrationTestWithCc.RunTestWithBp(t, bp) + ctx := android.GroupFixturePreparers( + PrepareForIntegrationTestWithCc, + android.FixtureAddTextFile("external/foo/Android.bp", bp), + ).RunTest(t) // Use the arm variant instead of the arm64 variant so that it gets headers from // ndk_libandroid_support to test LateStaticLibs. - cflags := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_sdk_static").Output("obj/foo.o").Args["cFlags"] + cflags := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_sdk_static").Output("obj/external/foo/foo.o").Args["cFlags"] var includes []string flags := strings.Split(cflags, " ") @@ -3981,32 +3984,32 @@ func TestIncludeDirectoryOrdering(t *testing.T) { "${config.ArmToolchainCflags}", "${config.ArmArmv7ANeonCflags}", "${config.ArmGenericCflags}", - "android_arm_export_include_dirs", - "lib32_export_include_dirs", - "arm_export_include_dirs", - "android_export_include_dirs", - "linux_export_include_dirs", - "export_include_dirs", - "android_arm_local_include_dirs", - "lib32_local_include_dirs", - "arm_local_include_dirs", - "android_local_include_dirs", - "linux_local_include_dirs", - "local_include_dirs", - ".", - "libheader1", - "libheader2", - "libwhole1", - "libwhole2", - "libstatic1", - "libstatic2", - "libshared1", - "libshared2", - "liblinux", - "libandroid", - "libarm", - "lib32", - "libandroid_arm", + "external/foo/android_arm_export_include_dirs", + "external/foo/lib32_export_include_dirs", + "external/foo/arm_export_include_dirs", + "external/foo/android_export_include_dirs", + "external/foo/linux_export_include_dirs", + "external/foo/export_include_dirs", + "external/foo/android_arm_local_include_dirs", + "external/foo/lib32_local_include_dirs", + "external/foo/arm_local_include_dirs", + "external/foo/android_local_include_dirs", + "external/foo/linux_local_include_dirs", + "external/foo/local_include_dirs", + "external/foo", + "external/foo/libheader1", + "external/foo/libheader2", + "external/foo/libwhole1", + "external/foo/libwhole2", + "external/foo/libstatic1", + "external/foo/libstatic2", + "external/foo/libshared1", + "external/foo/libshared2", + "external/foo/liblinux", + "external/foo/libandroid", + "external/foo/libarm", + "external/foo/lib32", + "external/foo/libandroid_arm", "defaults/cc/common/ndk_libc++_shared", "defaults/cc/common/ndk_libandroid_support", "out/soong/ndk/sysroot/usr/include", diff --git a/cc/compiler.go b/cc/compiler.go index 34ac47ae3..e19efd507 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -692,8 +692,9 @@ func isThirdParty(path string) bool { return false } } + return true } - return true + return false } // Properties for rust_bindgen related to generating rust bindings. diff --git a/cc/compiler_test.go b/cc/compiler_test.go index c301388ae..a3ee4a616 100644 --- a/cc/compiler_test.go +++ b/cc/compiler_test.go @@ -19,23 +19,24 @@ import ( ) func TestIsThirdParty(t *testing.T) { - shouldFail := []string{ + thirdPartyPaths := []string{ "external/foo/", "vendor/bar/", "hardware/underwater_jaguar/", } - shouldPass := []string{ + nonThirdPartyPaths := []string{ "vendor/google/cts/", "hardware/google/pixel", "hardware/interfaces/camera", "hardware/ril/supa_ril", + "bionic/libc", } - for _, path := range shouldFail { + for _, path := range thirdPartyPaths { if !isThirdParty(path) { t.Errorf("Expected %s to be considered third party", path) } } - for _, path := range shouldPass { + for _, path := range nonThirdPartyPaths { if isThirdParty(path) { t.Errorf("Expected %s to *not* be considered third party", path) }