Repository: bazelbuild/bazel
Issue: Accept .h++ as an extension for C++ headers
Labels: P3
team-Rules-CPP

### Description of the problem / feature request:

This is very similar to #302. I am trying to build an existing project ([libconfig](https://github.com/hyperrealm/libconfig)) which uses `.h++` as the extension for C++ header files but this extension is not supported by Bazel. This would affect anyone else working with a legacy code base using that naming.

For me, the error looks like this:

> ERROR: /private/var/tmp/_bazel_mark/85b990e918dfdf17ac335343d25f30e0/external/libconfig/BUILD.bazel:4:9: in srcs attribute of cc_library rule @libconfig//:lib: source file '@libconfig//:lib/libconfig.h++' is misplaced here (expected .cc, .cpp, .cxx, .c++, .C, .c, .h, .hh, .hpp, .ipp, .hxx, .inc, .inl, .H, .S, .s, .asm, .a, .lib, .pic.a, .lo, .lo.lib, .pic.lo, .so, .dylib, .dll, .o, .obj or .pic.o)

Ideally, I would be able to build libconfig with Bazel (without modifying the libconfig source).

### Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Here is `WORKSPACE`, I expect there are other issues affecting the build:

```
http_archive(
  name = "libconfig",
  urls = [ "https://github.com/hyperrealm/libconfig/archive/v1.7.2.zip" ],
  build_file_content = """
cc_library(
  name = "lib",
  srcs= glob([
    "lib/*.c",
    "lib/*.c++",
    "lib/*.h",
    "lib/*.h++"
  ]),
  hdrs = [\"lib/libconfig.h++\"],
  visibility = [\"//visibility:public\"]
)
""",
  sha256 = "a3ae202153fafb40558c26831429ce39845b2395ad8d30269a50e309a7585a8c",
  strip_prefix = "libconfig-1.7.2",
)
```

The issue can be triggered by specifying libconfig as a dependency:

```
cc_library(
        ...,
        deps = [
            ...,
            "@libconfig//:lib"
        ],
)
```

### What operating system are you running Bazel on?

MacOS and Ubuntu Xenial.

### What's the output of `bazel info release`?

release 0.24.1

###  Have you found anything relevant by searching the web?

I found #302 which is the same issue but for files with `.c++` extension. I have not found anything related to header files. I imagine that this naming system is fairly rare.



Issue comments:
We could accept this. Could you please send a PR?
@oquenchil, there is a linked PR, I've just updated it to resolve a conflict.

Pull request review comments:

Patch that resolved the issue:
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java
index 1ccaf58a3ee020..2db8ed95ca1de7 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java
@@ -41,7 +41,7 @@ public final class CppFileTypes {
       FileTypeSet.of(CppFileTypes.CPP_SOURCE, CppFileTypes.C_SOURCE);
 
   public static final FileType CPP_HEADER =
-      FileType.of(".h", ".hh", ".hpp", ".ipp", ".hxx", ".inc", ".inl", ".tlh", ".tli", ".H");
+      FileType.of(".h", ".hh", ".hpp", ".ipp", ".hxx", ".h++", ".inc", ".inl", ".tlh", ".tli", ".H");
   public static final FileType PCH = FileType.of(".pch");
   public static final FileTypeSet OBJC_HEADER = FileTypeSet.of(CPP_HEADER, PCH);
 


Test patch: