cc_cmake_snapshot: improve support for AIDL
- link correct libbinder for AIDL modules
- fix building AIDL interfaces with non-empty AidlRoot
- don't silently drop non-existent dependencies
Bug: 302718225
Test: aosp/3081709
atest binder_sdk_docker_test_clang
Change-Id: I181ef5a994f728f8af19134a6697b065a9aee261
diff --git a/cc/cmake_snapshot.go b/cc/cmake_snapshot.go
index 0635a29..c21a46f 100644
--- a/cc/cmake_snapshot.go
+++ b/cc/cmake_snapshot.go
@@ -192,13 +192,16 @@
},
"getExtraLibs": getExtraLibs,
"getIncludeDirs": getIncludeDirs,
- "mapLibraries": func(libs []string, mapping map[string]LibraryMappingProperty) []string {
+ "mapLibraries": func(ctx android.ModuleContext, m *Module, libs []string, mapping map[string]LibraryMappingProperty) []string {
var mappedLibs []string
for _, lib := range libs {
mappedLib, exists := mapping[lib]
if exists {
lib = mappedLib.Mapped_name
} else {
+ if !ctx.OtherModuleExists(lib) {
+ ctx.OtherModuleErrorf(m, "Dependency %s doesn't exist", lib)
+ }
lib = "android::" + lib
}
if lib == "" {
@@ -210,6 +213,21 @@
mappedLibs = slices.Compact(mappedLibs)
return mappedLibs
},
+ "getAidlSources": func(m *Module) []string {
+ aidlInterface := m.compiler.baseCompilerProps().AidlInterface
+ aidlRoot := aidlInterface.AidlRoot + string(filepath.Separator)
+ if aidlInterface.AidlRoot == "" {
+ aidlRoot = ""
+ }
+ var sources []string
+ for _, src := range aidlInterface.Sources {
+ if !strings.HasPrefix(src, aidlRoot) {
+ panic(fmt.Sprintf("Aidl source '%v' doesn't start with '%v'", src, aidlRoot))
+ }
+ sources = append(sources, src[len(aidlRoot):])
+ }
+ return sources
+ },
}
return template.Must(template.New("").Delims("<<", ">>").Funcs(funcMap).Parse(templateContents))
@@ -282,14 +300,14 @@
var pregeneratedModules []*Module
ctx.WalkDeps(func(dep_a android.Module, parent android.Module) bool {
moduleName := ctx.OtherModuleName(dep_a)
- dep, ok := dep_a.(*Module)
- if !ok {
- return false // not a cc module
- }
if visited := visitedModules[moduleName]; visited {
return false // visit only once
}
visitedModules[moduleName] = true
+ dep, ok := dep_a.(*Module)
+ if !ok {
+ return false // not a cc module
+ }
if mapping, ok := pprop.LibraryMapping[moduleName]; ok {
if mapping.Package_pregenerated != "" {
pregeneratedModules = append(pregeneratedModules, dep)