Add support for cc_library_headers in sdk/module_exports
Bug: 148933848 Bug: 153306490 Test: m nothing Merged-In: Ife6ee0f736238727a11b4421532eaeb29d46c1b7 Change-Id: Ife6ee0f736238727a11b4421532eaeb29d46c1b7
This commit is contained in:
@@ -18,6 +18,18 @@ import "android/soong/android"
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RegisterLibraryHeadersBuildComponents(android.InitRegistrationContext)
|
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) {
|
func RegisterLibraryHeadersBuildComponents(ctx android.RegistrationContext) {
|
||||||
@@ -32,6 +44,7 @@ func RegisterLibraryHeadersBuildComponents(ctx android.RegistrationContext) {
|
|||||||
func LibraryHeaderFactory() android.Module {
|
func LibraryHeaderFactory() android.Module {
|
||||||
module, library := NewLibrary(android.HostAndDeviceSupported)
|
module, library := NewLibrary(android.HostAndDeviceSupported)
|
||||||
library.HeaderOnly()
|
library.HeaderOnly()
|
||||||
|
module.sdkMemberTypes = []android.SdkMemberType{headersLibrarySdkMemberType}
|
||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,12 +65,19 @@ func (mt *librarySdkMemberType) AddDependencies(mctx android.BottomUpMutatorCont
|
|||||||
if version == "" {
|
if version == "" {
|
||||||
version = LatestStubsVersionFor(mctx.Config(), name)
|
version = LatestStubsVersionFor(mctx.Config(), name)
|
||||||
}
|
}
|
||||||
for _, linkType := range mt.linkTypes {
|
if mt.linkTypes == nil {
|
||||||
mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
|
mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
|
||||||
{Mutator: "image", Variation: android.CoreVariation},
|
{Mutator: "image", Variation: android.CoreVariation},
|
||||||
{Mutator: "link", Variation: linkType},
|
|
||||||
{Mutator: "version", Variation: version},
|
{Mutator: "version", Variation: version},
|
||||||
}...), dependencyTag, name)
|
}...), dependencyTag, name)
|
||||||
|
} else {
|
||||||
|
for _, linkType := range mt.linkTypes {
|
||||||
|
mctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
|
||||||
|
{Mutator: "image", Variation: android.CoreVariation},
|
||||||
|
{Mutator: "link", Variation: linkType},
|
||||||
|
{Mutator: "version", Variation: version},
|
||||||
|
}...), dependencyTag, name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,10 +214,14 @@ func (info *nativeLibInfo) generatePrebuiltLibrary(sdkModuleContext android.Modu
|
|||||||
for _, av := range info.archVariantProperties {
|
for _, av := range info.archVariantProperties {
|
||||||
archTypeProperties := archProperties.AddPropertySet(av.archType)
|
archTypeProperties := archProperties.AddPropertySet(av.archType)
|
||||||
|
|
||||||
// Copy the generated library to the snapshot and add a reference to it in the .bp module.
|
// If the library has some link types then it produces an output binary file, otherwise it
|
||||||
nativeLibraryPath := nativeLibraryPathFor(av)
|
// is header only.
|
||||||
builder.CopyToSnapshot(av.outputFile, nativeLibraryPath)
|
if info.memberType.linkTypes != nil {
|
||||||
archTypeProperties.AddProperty("srcs", []string{nativeLibraryPath})
|
// 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
|
// Add any arch specific properties inside the appropriate arch: {<arch>: {...}} block
|
||||||
addPossiblyArchSpecificProperties(sdkModuleContext, builder, av, archTypeProperties)
|
addPossiblyArchSpecificProperties(sdkModuleContext, builder, av, archTypeProperties)
|
||||||
|
@@ -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
|
||||||
|
`),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user