Create bp2build converter for versioned_ndk_headers
This module type is used by a single soong module - `common_libc` in bionic/libc Implementation details - Convert this module type to ndk_headers rule. Bazel's ndk_headers rule will have a boolean attribute `run_versioner` to determine if verioner should be run on the headers - Add this module type to the alwaysConvert bp2build list - Add the converted target for `common_libc` to the deps of `ndk_sysroot`. This ensures that unbundled apps link against the versioned NDK headers of libc Test: go test ./bp2build Test: b build //bionic/libc:common_libc --config=android Test: for f in $(find bazel-bin/bionic/libc/common_libc.versioned -type f); do cmp $f ${f/bazel-bin\/bionic\/libc\/common_libc.versioned/out\/soong\/ndk\/sysroot\/usr\/include}; done # no diff Bug: 301169067 Change-Id: I55be202f0589db9bdc743c8be41c9c5afd74c352
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user