Capture libeigen's header correctly
libeigen exports entire directory, but only two directories contain
actual exported headers. And some of headers have no extension. This
adds a special behaviour for external/eigen when capturing snapshot.
Exempt-From-Owner-Approval: cherry-pick from internal branch
Bug: 157106227
Test: m vendor-snapshot captures libeigen's headers
Change-Id: I82f27d4c6c4d472f47d54c545328150697b8cda3
Merged-In: I82f27d4c6c4d472f47d54c545328150697b8cda3
(cherry picked from commit 67f3dbca2f246cc52b0f696eff9d113ae44038f5)
diff --git a/cc/library.go b/cc/library.go
index 47485ce..ba8b0f4 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -407,6 +407,31 @@
if strings.HasPrefix(dir, android.PathForOutput(ctx).String()) {
continue
}
+ // libeigen wrongly exports the root directory "external/eigen". But only two
+ // subdirectories "Eigen" and "unsupported" contain exported header files. Even worse
+ // some of them have no extension. So we need special treatment for libeigen in order
+ // to glob correctly.
+ if dir == "external/eigen" {
+ // Only these two directories contains exported headers.
+ for _, subdir := range []string{"Eigen", "unsupported/Eigen"} {
+ glob, err := ctx.GlobWithDeps("external/eigen/"+subdir+"/**/*", nil)
+ if err != nil {
+ ctx.ModuleErrorf("glob failed: %#v", err)
+ return
+ }
+ for _, header := range glob {
+ if strings.HasSuffix(header, "/") {
+ continue
+ }
+ ext := filepath.Ext(header)
+ if ext != "" && ext != ".h" {
+ continue
+ }
+ ret = append(ret, android.PathForSource(ctx, header))
+ }
+ }
+ continue
+ }
exts := headerExts
// Glob all files under this special directory, because of C++ headers.
if strings.HasPrefix(dir, "external/libcxx/include") {