Be more explicit about headers in cc_library_static targets.

Test: bp2build-sync.py write; bazel build //bionic/...
Change-Id: I253b55f4d3cbe76805691b32e761016950871601
diff --git a/cc/library.go b/cc/library.go
index b49f1e5..18f9fae 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -2104,7 +2104,22 @@
 			break
 		}
 	}
-	srcsLabels := bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, srcs))
+
+	// Soong implicitly includes headers from the module's directory.
+	// For Bazel builds to work we have to make these header includes explicit.
+	if module.compiler.(*libraryDecorator).includeBuildDirectory() {
+		localIncludeDirs = append(localIncludeDirs, ".")
+	}
+
+	srcsLabels := android.BazelLabelForModuleSrc(ctx, srcs)
+
+	// For Bazel, be more explicit about headers - list all header files in include dirs as srcs
+	for _, includeDir := range includeDirs {
+		srcsLabels.Append(bp2BuildListHeadersInDir(ctx, includeDir))
+	}
+	for _, localIncludeDir := range localIncludeDirs {
+		srcsLabels.Append(bp2BuildListHeadersInDir(ctx, localIncludeDir))
+	}
 
 	var staticLibs []string
 	var wholeStaticLibs []string
@@ -2135,7 +2150,7 @@
 
 	attrs := &bazelCcLibraryStaticAttributes{
 		Copts:      copts,
-		Srcs:       srcsLabels,
+		Srcs:       bazel.MakeLabelListAttribute(srcsLabels),
 		Deps:       bazel.MakeLabelListAttribute(depsLabels),
 		Linkstatic: true,
 		Includes:   allIncludes,