Loading cc/library_headers.go +13 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,18 @@ import "android/soong/android" func init() { RegisterLibraryHeadersBuildComponents(android.InitRegistrationContext) // Register sdk member types. android.RegisterSdkMemberType(headersLibrarySdkMemberType) } var headersLibrarySdkMemberType = &librarySdkMemberType{ SdkMemberTypeBase: android.SdkMemberTypeBase{ PropertyName: "native_header_libs", SupportsSdk: true, }, prebuiltModuleType: "cc_prebuilt_library_headers", linkTypes: nil, } func RegisterLibraryHeadersBuildComponents(ctx android.RegistrationContext) { Loading @@ -32,6 +44,7 @@ func RegisterLibraryHeadersBuildComponents(ctx android.RegistrationContext) { func LibraryHeaderFactory() android.Module { module, library := NewLibrary(android.HostAndDeviceSupported) library.HeaderOnly() module.sdkMemberTypes = []android.SdkMemberType{headersLibrarySdkMemberType} return module.Init() } Loading cc/library_sdk_member.go +17 −6 Original line number Diff line number Diff line Loading @@ -65,6 +65,12 @@ func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorCont if version == "" { version = LatestStubsVersionFor(mctx.Config(), name) } if mt.linkTypes == nil { mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ {Mutator: "image", Variation: android.CoreVariation}, {Mutator: "version", Variation: version}, }...), dependencyTag, name) } else { for _, linkType := range mt.linkTypes { mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ {Mutator: "image", Variation: android.CoreVariation}, Loading @@ -75,6 +81,7 @@ func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorCont } } } } func (mt *librarySdkMemberType) IsInstance(module android.Module) bool { // Check the module to see if it can be used with this module type. Loading Loading @@ -207,10 +214,14 @@ func (info *nativeLibInfo) generatePrebuiltLibrary(sdkModuleContext android.Modu for _, av := range info.archVariantProperties { archTypeProperties := archProperties.AddPropertySet(av.archType) // If the library has some link types then it produces an output binary file, otherwise it // is header only. if info.memberType.linkTypes != nil { // Copy the generated library to the snapshot and add a reference to it in the .bp module. nativeLibraryPath := nativeLibraryPathFor(av) builder.CopyToSnapshot(av.outputFile, nativeLibraryPath) archTypeProperties.AddProperty("srcs", []string{nativeLibraryPath}) } // Add any arch specific properties inside the appropriate arch: {<arch>: {...}} block addPossiblyArchSpecificProperties(sdkModuleContext, builder, av, archTypeProperties) Loading sdk/cc_sdk_test.go +105 −0 Original line number Diff line number Diff line Loading @@ -840,3 +840,108 @@ include/Test.h -> include/include/Test.h `), ) } func TestSnapshotWithCcHeadersLibrary(t *testing.T) { result := testSdkWithCc(t, ` sdk { name: "mysdk", native_header_libs: ["mynativeheaders"], } cc_library_headers { name: "mynativeheaders", export_include_dirs: ["include"], system_shared_libs: [], stl: "none", } `) result.CheckSnapshot("mysdk", "android_common", "", checkAndroidBpContents(` // This is auto-generated. DO NOT EDIT. cc_prebuilt_library_headers { name: "mysdk_mynativeheaders@current", sdk_member_name: "mynativeheaders", export_include_dirs: ["include/include"], stl: "none", system_shared_libs: [], } cc_prebuilt_library_headers { name: "mynativeheaders", prefer: false, export_include_dirs: ["include/include"], stl: "none", system_shared_libs: [], } sdk_snapshot { name: "mysdk@current", native_header_libs: ["mysdk_mynativeheaders@current"], } `), checkAllCopyRules(` include/Test.h -> include/include/Test.h `), ) } func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) { // b/145598135 - Generating host snapshots for anything other than linux is not supported. SkipIfNotLinux(t) result := testSdkWithCc(t, ` sdk { name: "mysdk", device_supported: false, host_supported: true, native_header_libs: ["mynativeheaders"], } cc_library_headers { name: "mynativeheaders", device_supported: false, host_supported: true, export_include_dirs: ["include"], system_shared_libs: [], stl: "none", } `) result.CheckSnapshot("mysdk", "linux_glibc_common", "", checkAndroidBpContents(` // This is auto-generated. DO NOT EDIT. cc_prebuilt_library_headers { name: "mysdk_mynativeheaders@current", sdk_member_name: "mynativeheaders", device_supported: false, host_supported: true, export_include_dirs: ["include/include"], stl: "none", system_shared_libs: [], } cc_prebuilt_library_headers { name: "mynativeheaders", prefer: false, device_supported: false, host_supported: true, export_include_dirs: ["include/include"], stl: "none", system_shared_libs: [], } sdk_snapshot { name: "mysdk@current", device_supported: false, host_supported: true, native_header_libs: ["mysdk_mynativeheaders@current"], } `), checkAllCopyRules(` include/Test.h -> include/include/Test.h `), ) } Loading
cc/library_headers.go +13 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,18 @@ import "android/soong/android" func init() { RegisterLibraryHeadersBuildComponents(android.InitRegistrationContext) // Register sdk member types. android.RegisterSdkMemberType(headersLibrarySdkMemberType) } var headersLibrarySdkMemberType = &librarySdkMemberType{ SdkMemberTypeBase: android.SdkMemberTypeBase{ PropertyName: "native_header_libs", SupportsSdk: true, }, prebuiltModuleType: "cc_prebuilt_library_headers", linkTypes: nil, } func RegisterLibraryHeadersBuildComponents(ctx android.RegistrationContext) { Loading @@ -32,6 +44,7 @@ func RegisterLibraryHeadersBuildComponents(ctx android.RegistrationContext) { func LibraryHeaderFactory() android.Module { module, library := NewLibrary(android.HostAndDeviceSupported) library.HeaderOnly() module.sdkMemberTypes = []android.SdkMemberType{headersLibrarySdkMemberType} return module.Init() } Loading
cc/library_sdk_member.go +17 −6 Original line number Diff line number Diff line Loading @@ -65,6 +65,12 @@ func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorCont if version == "" { version = LatestStubsVersionFor(mctx.Config(), name) } if mt.linkTypes == nil { mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ {Mutator: "image", Variation: android.CoreVariation}, {Mutator: "version", Variation: version}, }...), dependencyTag, name) } else { for _, linkType := range mt.linkTypes { mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{ {Mutator: "image", Variation: android.CoreVariation}, Loading @@ -75,6 +81,7 @@ func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorCont } } } } func (mt *librarySdkMemberType) IsInstance(module android.Module) bool { // Check the module to see if it can be used with this module type. Loading Loading @@ -207,10 +214,14 @@ func (info *nativeLibInfo) generatePrebuiltLibrary(sdkModuleContext android.Modu for _, av := range info.archVariantProperties { archTypeProperties := archProperties.AddPropertySet(av.archType) // If the library has some link types then it produces an output binary file, otherwise it // is header only. if info.memberType.linkTypes != nil { // Copy the generated library to the snapshot and add a reference to it in the .bp module. nativeLibraryPath := nativeLibraryPathFor(av) builder.CopyToSnapshot(av.outputFile, nativeLibraryPath) archTypeProperties.AddProperty("srcs", []string{nativeLibraryPath}) } // Add any arch specific properties inside the appropriate arch: {<arch>: {...}} block addPossiblyArchSpecificProperties(sdkModuleContext, builder, av, archTypeProperties) Loading
sdk/cc_sdk_test.go +105 −0 Original line number Diff line number Diff line Loading @@ -840,3 +840,108 @@ include/Test.h -> include/include/Test.h `), ) } func TestSnapshotWithCcHeadersLibrary(t *testing.T) { result := testSdkWithCc(t, ` sdk { name: "mysdk", native_header_libs: ["mynativeheaders"], } cc_library_headers { name: "mynativeheaders", export_include_dirs: ["include"], system_shared_libs: [], stl: "none", } `) result.CheckSnapshot("mysdk", "android_common", "", checkAndroidBpContents(` // This is auto-generated. DO NOT EDIT. cc_prebuilt_library_headers { name: "mysdk_mynativeheaders@current", sdk_member_name: "mynativeheaders", export_include_dirs: ["include/include"], stl: "none", system_shared_libs: [], } cc_prebuilt_library_headers { name: "mynativeheaders", prefer: false, export_include_dirs: ["include/include"], stl: "none", system_shared_libs: [], } sdk_snapshot { name: "mysdk@current", native_header_libs: ["mysdk_mynativeheaders@current"], } `), checkAllCopyRules(` include/Test.h -> include/include/Test.h `), ) } func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) { // b/145598135 - Generating host snapshots for anything other than linux is not supported. SkipIfNotLinux(t) result := testSdkWithCc(t, ` sdk { name: "mysdk", device_supported: false, host_supported: true, native_header_libs: ["mynativeheaders"], } cc_library_headers { name: "mynativeheaders", device_supported: false, host_supported: true, export_include_dirs: ["include"], system_shared_libs: [], stl: "none", } `) result.CheckSnapshot("mysdk", "linux_glibc_common", "", checkAndroidBpContents(` // This is auto-generated. DO NOT EDIT. cc_prebuilt_library_headers { name: "mysdk_mynativeheaders@current", sdk_member_name: "mynativeheaders", device_supported: false, host_supported: true, export_include_dirs: ["include/include"], stl: "none", system_shared_libs: [], } cc_prebuilt_library_headers { name: "mynativeheaders", prefer: false, device_supported: false, host_supported: true, export_include_dirs: ["include/include"], stl: "none", system_shared_libs: [], } sdk_snapshot { name: "mysdk@current", device_supported: false, host_supported: true, native_header_libs: ["mysdk_mynativeheaders@current"], } `), checkAllCopyRules(` include/Test.h -> include/include/Test.h `), ) }