18
18
import com .google .devtools .build .lib .actions .Artifact ;
19
19
import com .google .devtools .build .lib .util .FileType ;
20
20
import com .google .devtools .build .lib .util .FileTypeSet ;
21
+ import com .google .devtools .build .lib .vfs .OsPathPolicy ;
21
22
import java .util .regex .Pattern ;
22
-
23
23
/**
24
24
* C++-related file type definitions.
25
25
*/
26
26
public final class CppFileTypes {
27
+ private static final OsPathPolicy OS = OsPathPolicy .getFilePathOs ();
28
+
27
29
// .cu and .cl are CUDA and OpenCL source extensions, respectively. They are expected to only be
28
30
// supported with clang. Bazel is not officially supporting these targets, and the extensions are
29
31
// listed only as long as they work with the existing C++ actions.
@@ -64,7 +66,7 @@ public final class CppFileTypes {
64
66
65
67
@ Override
66
68
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 );
68
70
}
69
71
70
72
@ Override
@@ -79,7 +81,7 @@ public ImmutableList<String> getExtensions() {
79
81
80
82
@ Override
81
83
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 );
83
85
}
84
86
85
87
@ Override
@@ -96,7 +98,7 @@ public ImmutableList<String> getExtensions() {
96
98
97
99
@ Override
98
100
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" );
100
102
}
101
103
102
104
@ Override
@@ -114,11 +116,11 @@ public ImmutableList<String> getExtensions() {
114
116
public boolean apply (String path ) {
115
117
if (PIC_ARCHIVE .matches (path )
116
118
|| ALWAYS_LINK_LIBRARY .matches (path )
117
- || path .endsWith (".if.lib" )) {
119
+ || OS .endsWith (path , ".if.lib" )) {
118
120
return false ;
119
121
}
120
122
for (String ext : extensions ) {
121
- if (path .endsWith (ext )) {
123
+ if (OS .endsWith (path , ext )) {
122
124
return true ;
123
125
}
124
126
}
@@ -138,8 +140,8 @@ public ImmutableList<String> getExtensions() {
138
140
139
141
@ Override
140
142
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" );
143
145
}
144
146
145
147
@ Override
@@ -155,7 +157,7 @@ public ImmutableList<String> getExtensions() {
155
157
156
158
@ Override
157
159
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" );
159
161
}
160
162
161
163
@ Override
@@ -220,7 +222,7 @@ public boolean apply(String path) {
220
222
// The current clang (clang-600.0.57) on Darwin doesn't support 'textual', so we can't
221
223
// have '.inc' files in the module map (since they're implictly textual).
222
224
// 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" );
224
226
}
225
227
};
226
228
0 commit comments