Support explicit header-only libraries

To date we have been using static libraries with no source files as
header-only libraries.  Switch to using header_libs to make the user's
expectations clear, in case we need to differentiate the semantics of
static libraries and header-only libraries when we enable transitive
static library dependencies.

Test: mma -j external/llvm
Change-Id: I3ce16df11076b637bd192880e86ec9027738b9e7
diff --git a/cc/cc.go b/cc/cc.go
index 0ea4713..3fc694f 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -54,8 +54,9 @@
 type Deps struct {
 	SharedLibs, LateSharedLibs                  []string
 	StaticLibs, LateStaticLibs, WholeStaticLibs []string
+	HeaderLibs                                  []string
 
-	ReexportSharedLibHeaders, ReexportStaticLibHeaders []string
+	ReexportSharedLibHeaders, ReexportStaticLibHeaders, ReexportHeaderLibHeaders []string
 
 	ObjFiles []string
 
@@ -221,6 +222,7 @@
 	staticExportDepTag    = dependencyTag{name: "static", library: true, reexportFlags: true}
 	lateStaticDepTag      = dependencyTag{name: "late static", library: true}
 	wholeStaticDepTag     = dependencyTag{name: "whole static", library: true, reexportFlags: true}
+	headerDepTag          = dependencyTag{name: "header", library: true, reexportFlags: true}
 	genSourceDepTag       = dependencyTag{name: "gen source"}
 	genHeaderDepTag       = dependencyTag{name: "gen header"}
 	genHeaderExportDepTag = dependencyTag{name: "gen header", reexportFlags: true}
@@ -556,6 +558,7 @@
 	deps.LateStaticLibs = lastUniqueElements(deps.LateStaticLibs)
 	deps.SharedLibs = lastUniqueElements(deps.SharedLibs)
 	deps.LateSharedLibs = lastUniqueElements(deps.LateSharedLibs)
+	deps.HeaderLibs = lastUniqueElements(deps.HeaderLibs)
 
 	for _, lib := range deps.ReexportSharedLibHeaders {
 		if !inList(lib, deps.SharedLibs) {
@@ -569,6 +572,12 @@
 		}
 	}
 
+	for _, lib := range deps.ReexportHeaderLibHeaders {
+		if !inList(lib, deps.HeaderLibs) {
+			ctx.PropertyErrorf("export_header_lib_headers", "Header library not in header_libs: '%s'", lib)
+		}
+	}
+
 	for _, gen := range deps.ReexportGeneratedHeaders {
 		if !inList(gen, deps.GeneratedHeaders) {
 			ctx.PropertyErrorf("export_generated_headers", "Generated header module not in generated_headers: '%s'", gen)
@@ -644,6 +653,8 @@
 		deps.LateSharedLibs, variantLateNdkLibs = rewriteNdkLibs(deps.LateSharedLibs)
 	}
 
+	actx.AddVariationDependencies(nil, headerDepTag, deps.HeaderLibs...)
+
 	actx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, wholeStaticDepTag,
 		deps.WholeStaticLibs...)
 
@@ -910,6 +921,8 @@
 				ctx.AddMissingDependencies(missingDeps)
 			}
 			depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLib.objs())
+		case headerDepTag:
+			// Nothing
 		case objDepTag:
 			depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path())
 		case crtBeginDepTag: