Merge "Create bp2build converter for versioned_ndk_headers" into main am: ee557e4c69
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2769119 Change-Id: Ie4240b71b3089ba3fa771ce122fe34c9d6a4f15e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
93cc736f1e
5 changed files with 61 additions and 6 deletions
|
@ -1019,6 +1019,7 @@ var (
|
|||
"ndk_headers",
|
||||
"ndk_library",
|
||||
"sysprop_library",
|
||||
"versioned_ndk_headers",
|
||||
"xsd_config",
|
||||
// go/keep-sorted end
|
||||
}
|
||||
|
|
|
@ -576,7 +576,7 @@ func createBuildConversionMetadata(ctx *android.Context) buildConversionMetadata
|
|||
Dir: ctx.ModuleDir(m),
|
||||
Deps: m.(*bootstrap.GoPackage).Deps(),
|
||||
}
|
||||
} else if moduleType == "ndk_headers" {
|
||||
} else if moduleType == "ndk_headers" || moduleType == "versioned_ndk_headers" {
|
||||
ndkHeaders = append(ndkHeaders, m)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -5198,7 +5198,7 @@ ndk_headers {
|
|||
name: "libfoo_headers",
|
||||
from: "from",
|
||||
to: "to",
|
||||
srcs: ["foo.h", "foo_other.h"]
|
||||
srcs: ["from/foo.h", "from/foo_other.h"]
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
|
@ -5206,11 +5206,42 @@ ndk_headers {
|
|||
"strip_import_prefix": `"from"`,
|
||||
"import_prefix": `"to"`,
|
||||
"hdrs": `[
|
||||
"foo.h",
|
||||
"foo_other.h",
|
||||
"from/foo.h",
|
||||
"from/foo_other.h",
|
||||
]`,
|
||||
}),
|
||||
},
|
||||
}
|
||||
runCcLibraryTestCase(t, tc)
|
||||
}
|
||||
|
||||
func TestVersionedNdkHeadersConversion(t *testing.T) {
|
||||
tc := Bp2buildTestCase{
|
||||
Description: "versioned_ndk_headers conversion",
|
||||
ModuleTypeUnderTest: "versioned_ndk_headers",
|
||||
ModuleTypeUnderTestFactory: cc.VersionedNdkHeadersFactory,
|
||||
Blueprint: `
|
||||
versioned_ndk_headers {
|
||||
name: "libfoo_headers",
|
||||
from: "from",
|
||||
to: "to",
|
||||
}
|
||||
`,
|
||||
Filesystem: map[string]string{
|
||||
"from/foo.h": "",
|
||||
"from/foo_other.h": "",
|
||||
},
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTargetNoRestrictions("ndk_headers", "libfoo_headers", AttrNameToString{
|
||||
"strip_import_prefix": `"from"`,
|
||||
"import_prefix": `"to"`,
|
||||
"hdrs": `[
|
||||
"from/foo.h",
|
||||
"from/foo_other.h",
|
||||
]`,
|
||||
"run_versioner": "True",
|
||||
}),
|
||||
},
|
||||
}
|
||||
runCcLibraryTestCase(t, tc)
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/bazel"
|
||||
|
@ -151,6 +152,7 @@ type bazelNdkHeadersAttributes struct {
|
|||
Strip_import_prefix *string
|
||||
Import_prefix *string
|
||||
Hdrs bazel.LabelListAttribute
|
||||
Run_versioner *bool
|
||||
}
|
||||
|
||||
func (h *headerModule) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
|
||||
|
@ -217,6 +219,7 @@ type versionedHeaderProperties struct {
|
|||
// Note that this is really only built to handle bionic/libc/include.
|
||||
type versionedHeaderModule struct {
|
||||
android.ModuleBase
|
||||
android.BazelModuleBase
|
||||
|
||||
properties versionedHeaderProperties
|
||||
|
||||
|
@ -255,6 +258,25 @@ func (m *versionedHeaderModule) GenerateAndroidBuildActions(ctx android.ModuleCo
|
|||
processHeadersWithVersioner(ctx, fromSrcPath, toOutputPath, m.srcPaths, installPaths)
|
||||
}
|
||||
|
||||
func (h *versionedHeaderModule) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "ndk_headers",
|
||||
Bzl_load_location: "//build/bazel/rules/cc:ndk_headers.bzl",
|
||||
}
|
||||
globPattern := headerGlobPattern(proptools.String(h.properties.From))
|
||||
attrs := &bazelNdkHeadersAttributes{
|
||||
Strip_import_prefix: h.properties.From,
|
||||
Import_prefix: h.properties.To,
|
||||
Run_versioner: proptools.BoolPtr(true),
|
||||
Hdrs: bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, []string{globPattern})),
|
||||
}
|
||||
ctx.CreateBazelTargetModule(
|
||||
props,
|
||||
android.CommonAttributes{Name: h.Name()},
|
||||
attrs,
|
||||
)
|
||||
}
|
||||
|
||||
func processHeadersWithVersioner(ctx android.ModuleContext, srcDir, outDir android.Path,
|
||||
srcPaths android.Paths, installPaths []android.WritablePath) android.Path {
|
||||
// The versioner depends on a dependencies directory to simplify determining include paths
|
||||
|
@ -298,12 +320,13 @@ func processHeadersWithVersioner(ctx android.ModuleContext, srcDir, outDir andro
|
|||
// Unlike the ndk_headers soong module, versioned_ndk_headers operates on a
|
||||
// directory level specified in `from` property. This is only used to process
|
||||
// the bionic/libc/include directory.
|
||||
func versionedNdkHeadersFactory() android.Module {
|
||||
func VersionedNdkHeadersFactory() android.Module {
|
||||
module := &versionedHeaderModule{}
|
||||
|
||||
module.AddProperties(&module.properties)
|
||||
|
||||
android.InitAndroidModule(module)
|
||||
android.InitBazelModule(module)
|
||||
|
||||
return module
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ func init() {
|
|||
func RegisterNdkModuleTypes(ctx android.RegistrationContext) {
|
||||
ctx.RegisterModuleType("ndk_headers", NdkHeadersFactory)
|
||||
ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
|
||||
ctx.RegisterModuleType("versioned_ndk_headers", versionedNdkHeadersFactory)
|
||||
ctx.RegisterModuleType("versioned_ndk_headers", VersionedNdkHeadersFactory)
|
||||
ctx.RegisterModuleType("preprocessed_ndk_headers", preprocessedNdkHeadersFactory)
|
||||
ctx.RegisterParallelSingletonType("ndk", NdkSingleton)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue