Support cc_library as LLNDK without llndk_library
Allow cc_library modules to configure themselves as an LLNDK library
using llndk.symbol_file instead of llndk_stubs pointing to an
llndk_library module.
Bug: 170784825
Test: TestEmbeddedLlndkLibrary
Change-Id: Id884cdada7094bbea6809a98e687e039778c5dc6
diff --git a/cc/library.go b/cc/library.go
index 618825f..dbfca3f 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -960,9 +960,8 @@
if ctx.IsLlndk() {
// LLNDK libraries ignore most of the properties on the cc_library and use the
// LLNDK-specific properties instead.
- deps.HeaderLibs = append(deps.HeaderLibs, library.Properties.Llndk.Export_llndk_headers...)
- deps.ReexportHeaderLibHeaders = append(deps.ReexportHeaderLibHeaders,
- library.Properties.Llndk.Export_llndk_headers...)
+ deps.HeaderLibs = append([]string(nil), library.Properties.Llndk.Export_llndk_headers...)
+ deps.ReexportHeaderLibHeaders = append([]string(nil), library.Properties.Llndk.Export_llndk_headers...)
return deps
}
@@ -1407,6 +1406,12 @@
library.reexportDeps(timestampFiles...)
}
+ // override the module's export_include_dirs with llndk.override_export_include_dirs
+ // if it is set.
+ if override := library.Properties.Llndk.Override_export_include_dirs; override != nil {
+ library.flagExporter.Properties.Export_include_dirs = override
+ }
+
if Bool(library.Properties.Llndk.Export_headers_as_system) {
library.flagExporter.Properties.Export_system_include_dirs = append(
library.flagExporter.Properties.Export_system_include_dirs,
@@ -1668,6 +1673,13 @@
// hasLLNDKStubs returns true if this cc_library module has a variant that will build LLNDK stubs.
func (library *libraryDecorator) hasLLNDKStubs() bool {
+ return library.hasVestigialLLNDKLibrary() || String(library.Properties.Llndk.Symbol_file) != ""
+}
+
+// hasVestigialLLNDKLibrary returns true if this cc_library module has a corresponding llndk_library
+// module containing properties describing the LLNDK variant.
+// TODO(b/170784825): remove this once there are no more llndk_library modules.
+func (library *libraryDecorator) hasVestigialLLNDKLibrary() bool {
return String(library.Properties.Llndk_stubs) != ""
}