Skip to content

Commit a7f9d6c

Browse files
committed
Make Cpp filetypes case insensitive for windows
1 parent 3d31c03 commit a7f9d6c

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/main/java/com/google/devtools/build/lib/rules/cpp/CppFileTypes.java

+12-10
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
import com.google.devtools.build.lib.actions.Artifact;
1919
import com.google.devtools.build.lib.util.FileType;
2020
import com.google.devtools.build.lib.util.FileTypeSet;
21+
import com.google.devtools.build.lib.vfs.OsPathPolicy;
2122
import java.util.regex.Pattern;
22-
2323
/**
2424
* C++-related file type definitions.
2525
*/
2626
public final class CppFileTypes {
27+
private static final OsPathPolicy OS = OsPathPolicy.getFilePathOs();
28+
2729
// .cu and .cl are CUDA and OpenCL source extensions, respectively. They are expected to only be
2830
// supported with clang. Bazel is not officially supporting these targets, and the extensions are
2931
// listed only as long as they work with the existing C++ actions.
@@ -64,7 +66,7 @@ public final class CppFileTypes {
6466

6567
@Override
6668
public boolean apply(String path) {
67-
return path.endsWith(ext) && !PIC_PREPROCESSED_C.matches(path);
69+
return OS.endsWith(path, ext) && !PIC_PREPROCESSED_C.matches(path);
6870
}
6971

7072
@Override
@@ -79,7 +81,7 @@ public ImmutableList<String> getExtensions() {
7981

8082
@Override
8183
public boolean apply(String path) {
82-
return path.endsWith(ext) && !PIC_PREPROCESSED_CPP.matches(path);
84+
return OS.endsWith(path, ext) && !PIC_PREPROCESSED_CPP.matches(path);
8385
}
8486

8587
@Override
@@ -96,7 +98,7 @@ public ImmutableList<String> getExtensions() {
9698

9799
@Override
98100
public boolean apply(String path) {
99-
return (path.endsWith(ext) && !PIC_ASSEMBLER.matches(path)) || path.endsWith(".asm");
101+
return (OS.endsWith(path, ext) && !PIC_ASSEMBLER.matches(path)) || OS.endsWith(path, ".asm");
100102
}
101103

102104
@Override
@@ -114,11 +116,11 @@ public ImmutableList<String> getExtensions() {
114116
public boolean apply(String path) {
115117
if (PIC_ARCHIVE.matches(path)
116118
|| ALWAYS_LINK_LIBRARY.matches(path)
117-
|| path.endsWith(".if.lib")) {
119+
|| OS.endsWith(path, ".if.lib")) {
118120
return false;
119121
}
120122
for (String ext : extensions) {
121-
if (path.endsWith(ext)) {
123+
if (OS.endsWith(path, ext)) {
122124
return true;
123125
}
124126
}
@@ -138,8 +140,8 @@ public ImmutableList<String> getExtensions() {
138140

139141
@Override
140142
public boolean apply(String path) {
141-
return (path.endsWith(ext) && !ALWAYS_LINK_PIC_LIBRARY.matches(path))
142-
|| path.endsWith(".lo.lib");
143+
return (OS.endsWith(path, ext) && !ALWAYS_LINK_PIC_LIBRARY.matches(path))
144+
|| OS.endsWith(path, ".lo.lib");
143145
}
144146

145147
@Override
@@ -155,7 +157,7 @@ public ImmutableList<String> getExtensions() {
155157

156158
@Override
157159
public boolean apply(String path) {
158-
return (path.endsWith(ext) && !PIC_OBJECT_FILE.matches(path)) || path.endsWith(".obj");
160+
return (OS.endsWith(path, ext) && !PIC_OBJECT_FILE.matches(path)) || OS.endsWith(path, ".obj");
159161
}
160162

161163
@Override
@@ -220,7 +222,7 @@ public boolean apply(String path) {
220222
// The current clang (clang-600.0.57) on Darwin doesn't support 'textual', so we can't
221223
// have '.inc' files in the module map (since they're implictly textual).
222224
// TODO(bazel-team): Use HEADERS file type once clang-700 is the base clang we support.
223-
return artifact.getFilename().endsWith(".h");
225+
return OS.endsWith(artifact.getFilename(), ".h");
224226
}
225227
};
226228

0 commit comments

Comments
 (0)