Convert ndkSingleton, apexDepsInfoSingleton, allTeamsSingleton,
apexPrebuiltInfo to use ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: I77b05e8b54843bfa8b91376a6796c2b5c69be3c1
diff --git a/cc/cc.go b/cc/cc.go
index 238827e..f9ff065 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -93,6 +93,9 @@
type LibraryDecoratorInfo struct {
ExportIncludeDirs []string
InjectBsslHash bool
+ // Location of the static library in the sysroot. Empty if the library is
+ // not included in the NDK.
+ NdkSysrootPath android.Path
}
type SnapshotInfo struct {
@@ -108,9 +111,14 @@
AbiDumpPath android.OutputPath
HasAbiDump bool
AbiDiffPaths android.Paths
+ InstallPath android.Path
}
-type ObjectLinkerInfo struct{}
+type ObjectLinkerInfo struct {
+ // Location of the object in the sysroot. Empty if the object is not
+ // included in the NDK.
+ NdkSysrootPath android.Path
+}
type LibraryInfo struct {
BuildStubs bool
@@ -2343,6 +2351,7 @@
case *libraryDecorator:
ccInfo.LinkerInfo.LibraryDecoratorInfo = &LibraryDecoratorInfo{
InjectBsslHash: Bool(c.linker.(*libraryDecorator).Properties.Inject_bssl_hash),
+ NdkSysrootPath: c.linker.(*libraryDecorator).ndkSysrootPath,
}
case *testBinary:
ccInfo.LinkerInfo.TestBinaryInfo = &TestBinaryInfo{
@@ -2351,7 +2360,9 @@
case *benchmarkDecorator:
ccInfo.LinkerInfo.BenchmarkDecoratorInfo = &BenchmarkDecoratorInfo{}
case *objectLinker:
- ccInfo.LinkerInfo.ObjectLinkerInfo = &ObjectLinkerInfo{}
+ ccInfo.LinkerInfo.ObjectLinkerInfo = &ObjectLinkerInfo{
+ NdkSysrootPath: c.linker.(*objectLinker).ndkSysrootPath,
+ }
case *stubDecorator:
ccInfo.LinkerInfo.StubDecoratorInfo = &StubDecoratorInfo{}
}
@@ -2378,6 +2389,7 @@
HasAbiDump: installer.hasAbiDump,
AbiDumpPath: installer.abiDumpPath,
AbiDiffPaths: installer.abiDiffPaths,
+ InstallPath: installer.installPath,
}
}
}
diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go
index 7481954..6e26d4c 100644
--- a/cc/ndk_headers.go
+++ b/cc/ndk_headers.go
@@ -80,6 +80,20 @@
licensePath android.Path
}
+type NdkHeaderInfo struct {
+ SrcPaths android.Paths
+ InstallPaths android.Paths
+ LicensePath android.Path
+ // Set to true if the headers installed by this module should skip
+ // verification. This step ensures that each header is self-contained (can
+ // be #included alone) and is valid C. This should not be disabled except in
+ // rare cases. Outside bionic and external, if you're using this option
+ // you've probably made a mistake.
+ SkipVerification bool
+}
+
+var NdkHeaderInfoProvider = blueprint.NewProvider[NdkHeaderInfo]()
+
func getHeaderInstallDir(ctx android.ModuleContext, header android.Path, from string,
to string) android.OutputPath {
// Output path is the sysroot base + "usr/include" + to directory + directory component
@@ -135,6 +149,13 @@
if len(m.installPaths) == 0 {
ctx.ModuleErrorf("srcs %q matched zero files", m.properties.Srcs)
}
+
+ android.SetProvider(ctx, NdkHeaderInfoProvider, NdkHeaderInfo{
+ SrcPaths: m.srcPaths,
+ InstallPaths: m.installPaths,
+ LicensePath: m.licensePath,
+ SkipVerification: Bool(m.properties.Skip_verification),
+ })
}
// ndk_headers installs the sets of ndk headers defined in the srcs property
@@ -203,6 +224,8 @@
licensePath android.Path
}
+var NdkPreprocessedHeaderInfoProvider = blueprint.NewProvider[NdkHeaderInfo]()
+
func (m *preprocessedHeadersModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if String(m.properties.License) == "" {
ctx.PropertyErrorf("license", "field is required")
@@ -231,6 +254,13 @@
if len(m.installPaths) == 0 {
ctx.ModuleErrorf("srcs %q matched zero files", m.properties.Srcs)
}
+
+ android.SetProvider(ctx, NdkPreprocessedHeaderInfoProvider, NdkHeaderInfo{
+ SrcPaths: m.srcPaths,
+ InstallPaths: m.installPaths,
+ LicensePath: m.licensePath,
+ SkipVerification: Bool(m.properties.Skip_verification),
+ })
}
// preprocessed_ndk_headers preprocesses all the ndk headers listed in the srcs
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index a5f014b..34f6195 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -53,11 +53,12 @@
// TODO(danalbert): Write `ndk_static_library` rule.
import (
- "android/soong/android"
"fmt"
"path/filepath"
"strings"
+ "android/soong/android"
+
"github.com/google/blueprint"
)
@@ -209,57 +210,61 @@
var headerCCompatVerificationTimestampPaths android.Paths
var installPaths android.Paths
var licensePaths android.Paths
- ctx.VisitAllModules(func(module android.Module) {
- if m, ok := module.(android.Module); ok && !m.Enabled(ctx) {
+ ctx.VisitAllModuleProxies(func(module android.ModuleProxy) {
+
+ if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoKey).Enabled {
return
}
- if m, ok := module.(*headerModule); ok {
- headerSrcPaths = append(headerSrcPaths, m.srcPaths...)
- headerInstallPaths = append(headerInstallPaths, m.installPaths...)
- if !Bool(m.properties.Skip_verification) {
- for i, installPath := range m.installPaths {
+ if m, ok := android.OtherModuleProvider(ctx, module, NdkHeaderInfoProvider); ok {
+ headerSrcPaths = append(headerSrcPaths, m.SrcPaths...)
+ headerInstallPaths = append(headerInstallPaths, m.InstallPaths...)
+ if !m.SkipVerification {
+ for i, installPath := range m.InstallPaths {
headersToVerify = append(headersToVerify, srcDestPair{
- src: m.srcPaths[i],
+ src: m.SrcPaths[i],
dest: installPath,
})
}
}
- installPaths = append(installPaths, m.installPaths...)
- licensePaths = append(licensePaths, m.licensePath)
+ installPaths = append(installPaths, m.InstallPaths...)
+ licensePaths = append(licensePaths, m.LicensePath)
}
- if m, ok := module.(*preprocessedHeadersModule); ok {
- headerSrcPaths = append(headerSrcPaths, m.srcPaths...)
- headerInstallPaths = append(headerInstallPaths, m.installPaths...)
- if !Bool(m.properties.Skip_verification) {
- for i, installPath := range m.installPaths {
+ if m, ok := android.OtherModuleProvider(ctx, module, NdkPreprocessedHeaderInfoProvider); ok {
+ headerSrcPaths = append(headerSrcPaths, m.SrcPaths...)
+ headerInstallPaths = append(headerInstallPaths, m.InstallPaths...)
+ if !m.SkipVerification {
+ for i, installPath := range m.InstallPaths {
headersToVerify = append(headersToVerify, srcDestPair{
- src: m.srcPaths[i],
+ src: m.SrcPaths[i],
dest: installPath,
})
}
}
- installPaths = append(installPaths, m.installPaths...)
- licensePaths = append(licensePaths, m.licensePath)
+ installPaths = append(installPaths, m.InstallPaths...)
+ licensePaths = append(licensePaths, m.LicensePath)
}
- if m, ok := module.(*Module); ok {
- if installer, ok := m.installer.(*stubDecorator); ok && m.library.BuildStubs() {
- installPaths = append(installPaths, installer.installPath)
+ if ccInfo, ok := android.OtherModuleProvider(ctx, module, CcInfoProvider); ok {
+ if installer := ccInfo.InstallerInfo; installer != nil && installer.StubDecoratorInfo != nil &&
+ ccInfo.LibraryInfo != nil && ccInfo.LibraryInfo.BuildStubs {
+ installPaths = append(installPaths, installer.StubDecoratorInfo.InstallPath)
}
- if library, ok := m.linker.(*libraryDecorator); ok {
- if library.ndkSysrootPath != nil {
- staticLibInstallPaths = append(
- staticLibInstallPaths, library.ndkSysrootPath)
+ if ccInfo.LinkerInfo != nil {
+ if library := ccInfo.LinkerInfo.LibraryDecoratorInfo; library != nil {
+ if library.NdkSysrootPath != nil {
+ staticLibInstallPaths = append(
+ staticLibInstallPaths, library.NdkSysrootPath)
+ }
}
- }
- if object, ok := m.linker.(*objectLinker); ok {
- if object.ndkSysrootPath != nil {
- staticLibInstallPaths = append(
- staticLibInstallPaths, object.ndkSysrootPath)
+ if object := ccInfo.LinkerInfo.ObjectLinkerInfo; object != nil {
+ if object.NdkSysrootPath != nil {
+ staticLibInstallPaths = append(
+ staticLibInstallPaths, object.NdkSysrootPath)
+ }
}
}
}