From 7a7d067c741826ba8f735df863d3a7d0b1da1acf Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Wed, 17 Feb 2021 12:17:40 +0000 Subject: [PATCH] Generated headers may not be arch specific Previously, it was assumed that generated headers must be arch specific and so prevented the fields referencing the paths to those headers from being automatically optimized by the sdk generation code. That is not always the case, e.g. with headers generated from protos so this change allows those fields to be optimized. Bug: 180427921 Test: m nothing Change-Id: Id2af419d58ae3c30ea6d9e87f71e33a9ff6ba13b --- cc/library_sdk_member.go | 26 +++++++++++++------------- sdk/cc_sdk_test.go | 35 +++++++++++++++++------------------ 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go index 14ff4d891..d5f2adf8b 100644 --- a/cc/library_sdk_member.go +++ b/cc/library_sdk_member.go @@ -206,22 +206,22 @@ var includeDirProperties = []includeDirsProperty{ dirs: true, }, { - // exportedGeneratedIncludeDirs lists directories that contains some header files - // that are explicitly listed in the exportedGeneratedHeaders property. So, the contents + // ExportedGeneratedIncludeDirs lists directories that contains some header files + // that are explicitly listed in the ExportedGeneratedHeaders property. So, the contents // of these directories do not need to be copied, but these directories do need adding to // the export_include_dirs property in the prebuilt module in the snapshot. - pathsGetter: func(libInfo *nativeLibInfoProperties) android.Paths { return libInfo.exportedGeneratedIncludeDirs }, + pathsGetter: func(libInfo *nativeLibInfoProperties) android.Paths { return libInfo.ExportedGeneratedIncludeDirs }, propertyName: "export_include_dirs", snapshotDir: nativeGeneratedIncludeDir, copy: false, dirs: true, }, { - // exportedGeneratedHeaders lists header files that are in one of the directories - // specified in exportedGeneratedIncludeDirs must be copied into the snapshot. - // As they are in a directory in exportedGeneratedIncludeDirs they do not need adding to a + // ExportedGeneratedHeaders lists header files that are in one of the directories + // specified in ExportedGeneratedIncludeDirs must be copied into the snapshot. + // As they are in a directory in ExportedGeneratedIncludeDirs they do not need adding to a // property in the prebuilt module in the snapshot. - pathsGetter: func(libInfo *nativeLibInfoProperties) android.Paths { return libInfo.exportedGeneratedHeaders }, + pathsGetter: func(libInfo *nativeLibInfoProperties) android.Paths { return libInfo.ExportedGeneratedHeaders }, propertyName: "", snapshotDir: nativeGeneratedIncludeDir, copy: true, @@ -351,13 +351,13 @@ type nativeLibInfoProperties struct { // The list of arch specific exported generated include dirs. // - // This field is not exported as its contents are always arch specific. - exportedGeneratedIncludeDirs android.Paths + // This field is exported as its contents may not be arch specific, e.g. protos. + ExportedGeneratedIncludeDirs android.Paths `android:"arch_variant"` // The list of arch specific exported generated header files. // - // This field is not exported as its contents are is always arch specific. - exportedGeneratedHeaders android.Paths + // This field is exported as its contents may not be arch specific, e.g. protos. + ExportedGeneratedHeaders android.Paths `android:"arch_variant"` // The list of possibly common exported system include dirs. // @@ -430,7 +430,7 @@ func (p *nativeLibInfoProperties) PopulateFromVariant(ctx android.SdkMemberConte // Make sure that the include directories are unique. p.ExportedIncludeDirs = android.FirstUniquePaths(exportedIncludeDirs) - p.exportedGeneratedIncludeDirs = android.FirstUniquePaths(exportedGeneratedIncludeDirs) + p.ExportedGeneratedIncludeDirs = android.FirstUniquePaths(exportedGeneratedIncludeDirs) // Take a copy before filtering out duplicates to avoid changing the slice owned by the // ccModule. @@ -456,7 +456,7 @@ func (p *nativeLibInfoProperties) PopulateFromVariant(ctx android.SdkMemberConte } p.SystemSharedLibs = specifiedDeps.systemSharedLibs } - p.exportedGeneratedHeaders = exportedInfo.GeneratedHeaders + p.ExportedGeneratedHeaders = exportedInfo.GeneratedHeaders if !p.memberType.noOutputFiles && addOutputFile { p.outputFile = getRequiredMemberOutputFile(ctx, ccModule) diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go index 5b132417e..997d2f66b 100644 --- a/sdk/cc_sdk_test.go +++ b/sdk/cc_sdk_test.go @@ -494,31 +494,26 @@ cc_prebuilt_library_shared { apex_available: ["//apex_available:platform"], stl: "none", compile_multilib: "both", - export_include_dirs: ["include/myinclude"], + export_include_dirs: [ + "include/myinclude", + "include_gen/generated_foo/gen", + "include_gen/generated_foo/gen/protos", + ], arch: { arm64: { srcs: ["arm64/lib/mynativelib.so"], - export_include_dirs: [ - "arm64/include_gen/generated_foo/gen", - "arm64/include_gen/generated_foo/gen/protos", - ], }, arm: { srcs: ["arm/lib/mynativelib.so"], - export_include_dirs: [ - "arm/include_gen/generated_foo/gen", - "arm/include_gen/generated_foo/gen/protos", - ], }, }, } `), checkAllCopyRules(` myinclude/Test.h -> include/myinclude/Test.h +.intermediates/generated_foo/gen/generated_foo/protos/foo/bar.h -> include_gen/generated_foo/gen/generated_foo/protos/foo/bar.h .intermediates/mynativelib/android_arm64_armv8-a_shared/mynativelib.so -> arm64/lib/mynativelib.so -.intermediates/generated_foo/gen/generated_foo/protos/foo/bar.h -> arm64/include_gen/generated_foo/gen/generated_foo/protos/foo/bar.h .intermediates/mynativelib/android_arm_armv7-a-neon_shared/mynativelib.so -> arm/lib/mynativelib.so -.intermediates/generated_foo/gen/generated_foo/protos/foo/bar.h -> arm/include_gen/generated_foo/gen/generated_foo/protos/foo/bar.h `), ) } @@ -1858,7 +1853,10 @@ cc_prebuilt_library_static { host_supported: true, stl: "none", compile_multilib: "64", - export_include_dirs: ["include/myinclude"], + export_include_dirs: [ + "include/myinclude", + "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl", + ], target: { host: { enabled: false, @@ -1866,7 +1864,6 @@ cc_prebuilt_library_static { linux_glibc_x86_64: { enabled: true, srcs: ["x86_64/lib/mynativelib.a"], - export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"], }, }, } @@ -1884,7 +1881,10 @@ cc_prebuilt_library_static { installable: false, stl: "none", compile_multilib: "64", - export_include_dirs: ["include/myinclude"], + export_include_dirs: [ + "include/myinclude", + "include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl", + ], target: { host: { enabled: false, @@ -1892,7 +1892,6 @@ cc_prebuilt_library_static { linux_glibc_x86_64: { enabled: true, srcs: ["x86_64/lib/mynativelib.a"], - export_include_dirs: ["x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl"], }, }, } @@ -1916,10 +1915,10 @@ module_exports_snapshot { `), checkAllCopyRules(` myinclude/Test.h -> include/myinclude/Test.h +.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h +.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h +.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h .intermediates/mynativelib/linux_glibc_x86_64_static/mynativelib.a -> x86_64/lib/mynativelib.a -.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -> x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/Test.h -.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -> x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BnTest.h -.intermediates/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h -> x86_64/include_gen/mynativelib/linux_glibc_x86_64_static/gen/aidl/aidl/foo/bar/BpTest.h `), ) }