Require libraries in header_libs to be cc_library_header
Allowing header_libs to refer to a cc_library, cc_library_static
or cc_library_shared was unintentional, make it an error.
Fixes: 173252016
Test: m checkbuild
Change-Id: I9f7986f6ca37deddf1f208b15a87d3c0cff25585
diff --git a/cc/cc.go b/cc/cc.go
index ae75c1d..f5f2d04 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -2446,7 +2446,14 @@
switch {
case libDepTag.header():
- // nothing
+ if !ctx.OtherModuleHasProvider(dep, HeaderLibraryInfoProvider) {
+ if !ctx.Config().AllowMissingDependencies() {
+ ctx.ModuleErrorf("module %q is not a header library", depName)
+ } else {
+ ctx.AddMissingDependencies([]string{depName})
+ }
+ return
+ }
case libDepTag.shared():
if !ctx.OtherModuleHasProvider(dep, SharedLibraryInfoProvider) {
if !ctx.Config().AllowMissingDependencies() {
diff --git a/cc/library.go b/cc/library.go
index b796aaf..3244db7 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -940,16 +940,22 @@
ctx.CheckbuildFile(outputFile)
- ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{
- StaticLibrary: outputFile,
- ReuseObjects: library.reuseObjects,
- Objects: library.objects,
+ if library.static() {
+ ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{
+ StaticLibrary: outputFile,
+ ReuseObjects: library.reuseObjects,
+ Objects: library.objects,
- TransitiveStaticLibrariesForOrdering: android.NewDepSetBuilder(android.TOPOLOGICAL).
- Direct(outputFile).
- Transitive(deps.TranstiveStaticLibrariesForOrdering).
- Build(),
- })
+ TransitiveStaticLibrariesForOrdering: android.NewDepSetBuilder(android.TOPOLOGICAL).
+ Direct(outputFile).
+ Transitive(deps.TranstiveStaticLibrariesForOrdering).
+ Build(),
+ })
+ }
+
+ if library.header() {
+ ctx.SetProvider(HeaderLibraryInfoProvider, HeaderLibraryInfo{})
+ }
return outputFile
}
diff --git a/cc/linkable.go b/cc/linkable.go
index ddf3950..94b5a54 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -125,6 +125,13 @@
var StaticLibraryInfoProvider = blueprint.NewProvider(StaticLibraryInfo{})
+// HeaderLibraryInfo is a marker provider that identifies a module as a header library.
+type HeaderLibraryInfo struct {
+}
+
+// HeaderLibraryInfoProvider is a marker provider that identifies a module as a header library.
+var HeaderLibraryInfoProvider = blueprint.NewProvider(HeaderLibraryInfo{})
+
// FlagExporterInfo is a provider to propagate transitive library information
// pertaining to exported include paths and flags.
type FlagExporterInfo struct {
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index 37df4ba..df71340 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -190,6 +190,12 @@
}
}
+ if p.header() {
+ ctx.SetProvider(HeaderLibraryInfoProvider, HeaderLibraryInfo{})
+
+ return nil
+ }
+
return nil
}