From 74fc190d90a996e54d7c97d9e4731da82d9437cb Mon Sep 17 00:00:00 2001 From: Paul Duffin Date: Thu, 23 Jan 2020 11:45:03 +0000 Subject: [PATCH] Dedup adding of arch/common properties to cc library snapshot Some additional, possibly arch specific, properties need adding to cc library (e.g. recovery_available). This dedups and cleans up the code involved to simply the addition of those new properties. Bug: 142918168 Test: m nothing Change-Id: I0963aa02e9504af1ae9b427ff1016e7c481465f4 --- cc/library_sdk_member.go | 44 ++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go index fd5a4dace..165901d26 100644 --- a/cc/library_sdk_member.go +++ b/cc/library_sdk_member.go @@ -241,39 +241,43 @@ func buildSharedNativeLibSnapshot(sdkModuleContext android.ModuleContext, info * func (info *nativeLibInfo) generatePrebuiltLibrary(sdkModuleContext android.ModuleContext, builder android.SnapshotBuilder, member android.SdkMember) { - // a function for emitting include dirs - addExportedDirsForNativeLibs := func(lib nativeLibInfoProperties, properties android.BpPropertySet, systemInclude bool) { - includeDirs := nativeIncludeDirPathsFor(lib, systemInclude) - if len(includeDirs) == 0 { - return - } - var propertyName string - if !systemInclude { - propertyName = "export_include_dirs" - } else { - propertyName = "export_system_include_dirs" - } - properties.AddProperty(propertyName, includeDirs) - } - pbm := builder.AddPrebuiltModule(member, info.memberType.prebuiltModuleType) - addExportedDirsForNativeLibs(info.commonProperties, pbm, false /*systemInclude*/) - addExportedDirsForNativeLibs(info.commonProperties, pbm, true /*systemInclude*/) + addPossiblyArchSpecificProperties(info.commonProperties, pbm) archProperties := pbm.AddPropertySet("arch") for _, av := range info.archVariantProperties { archTypeProperties := archProperties.AddPropertySet(av.archType) + // Add any arch specific properties inside the appropriate arch: {: {...}} block archTypeProperties.AddProperty("srcs", []string{nativeLibraryPathFor(av)}) - // export_* properties are added inside the arch: {: {...}} block - addExportedDirsForNativeLibs(av, archTypeProperties, false /*systemInclude*/) - addExportedDirsForNativeLibs(av, archTypeProperties, true /*systemInclude*/) + addPossiblyArchSpecificProperties(av, archTypeProperties) } pbm.AddProperty("stl", "none") pbm.AddProperty("system_shared_libs", []string{}) } +// Add properties that may, or may not, be arch specific. +func addPossiblyArchSpecificProperties(libInfo nativeLibInfoProperties, outputProperties android.BpPropertySet) { + addExportedDirsForNativeLibs(libInfo, outputProperties, false /*systemInclude*/) + addExportedDirsForNativeLibs(libInfo, outputProperties, true /*systemInclude*/) +} + +// a function for emitting include dirs +func addExportedDirsForNativeLibs(lib nativeLibInfoProperties, properties android.BpPropertySet, systemInclude bool) { + includeDirs := nativeIncludeDirPathsFor(lib, systemInclude) + if len(includeDirs) == 0 { + return + } + var propertyName string + if !systemInclude { + propertyName = "export_include_dirs" + } else { + propertyName = "export_system_include_dirs" + } + properties.AddProperty(propertyName, includeDirs) +} + const ( nativeIncludeDir = "include" nativeGeneratedIncludeDir = "include_gen"