From 37e0de50043a7db812f8faedc9be57748f96e690 Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Fri, 19 Feb 2021 17:05:39 +0000 Subject: [PATCH] Only export sysprop headers in exported sysprop include directory Bug: 180712399 Test: m nothing Change-Id: Ia93d20fe0fecf977773257fa43fe40e7fe9f024f --- cc/cc_test.go | 3 --- cc/library.go | 8 +++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cc/cc_test.go b/cc/cc_test.go index 37cbff115..70fdd5f5f 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -4154,8 +4154,6 @@ func TestIncludeDirsExporting(t *testing.T) { ) }) - // TODO fix this test as it exports the sysprop public and non-public headers irrespective of - // which include directory is exported. t.Run("ensure only sysprop headers are exported", func(t *testing.T) { ctx := testCc(t, genRuleModules+` cc_library_shared { @@ -4176,7 +4174,6 @@ func TestIncludeDirsExporting(t *testing.T) { expectedSystemIncludeDirs(``), expectedGeneratedHeaders(` .intermediates/libfoo/android_arm64_armv8-a_shared/gen/sysprop/include/a.sysprop.h - .intermediates/libfoo/android_arm64_armv8-a_shared/gen/sysprop/public/include/a.sysprop.h `), expectedOrderOnlyDeps(` .intermediates/libfoo/android_arm64_armv8-a_shared/gen/sysprop/include/a.sysprop.h diff --git a/cc/library.go b/cc/library.go index f1363c9c1..0e6e10764 100644 --- a/cc/library.go +++ b/cc/library.go @@ -1348,10 +1348,16 @@ func (library *libraryDecorator) link(ctx ModuleContext, } } + // Make sure to only export headers which are within the include directory. + _, headers := android.FilterPathListPredicate(library.baseCompiler.syspropHeaders, func(path android.Path) bool { + _, isRel := android.MaybeRel(ctx, dir.String(), path.String()) + return isRel + }) + // Add sysprop-related directories to the exported directories of this library. library.reexportDirs(dir) library.reexportDeps(library.baseCompiler.syspropOrderOnlyDeps...) - library.addExportedGeneratedHeaders(library.baseCompiler.syspropHeaders...) + library.addExportedGeneratedHeaders(headers...) } // Add stub-related flags if this library is a stub library.