Skip to content

Commit 6f0f6e4

Browse files
committed
Update patch to include .ipp and use configs instead of repeating them.
Ignore MODULE.bazel.lock
1 parent 74e9804 commit 6f0f6e4

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33

44
# Ignore links to Bazel's output. The pattern needs the `*` because people can change the name of the directory into which the repository is cloned (changing the `bazel-<workspace_name>` symlink), and must not end with a trailing `/` because it's a symlink on macOS/Linux.
55
/bazel-*
6+
7+
MODULE.bazel.lock

refresh.template.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def _parse_headers_from_makefile_deps(d_file_content: str, source_path_for_sanit
173173
# For example, `d_file_content` might be: `"foo.o : foo.cc bar.h \\\n baz.hpp"`.
174174
target, dependencies = d_file_content.split(': ', 1) # Needs to handle absolute Windows paths, like C:\
175175
target = target.strip() # Remove the optional trailing space.
176-
assert target.endswith(('.o', '.obj', '.processed')), "Something went wrong in makefile parsing to get headers. The target should be an object file. Output:\n" + d_file_content
176+
assert target.endswith(_get_headers.output_extensions), "Something went wrong in makefile parsing to get headers. The target should be an object file. Output:\n" + d_file_content
177177
# Undo shell-like line wrapping because the newlines aren't eaten by shlex.join. Note also that it's the line wrapping is inconsistently generated across compilers and depends on the lengths of the filenames, so you can't just split on the escaped newlines.
178178
dependencies = dependencies.replace('\\\n', '')
179179
# On Windows, swap out (single) backslash path directory separators for forward slash. Shlex otherwise eats the separators...and Windows gcc intermixes backslash separators with backslash escaped spaces. For a real example of gcc run from Windows, see https://github.com/hedronvision/bazel-compile-commands-extractor/issues/81
@@ -267,13 +267,17 @@ def _get_headers_gcc(compile_action, source_path: str, action_key: str):
267267

268268
# Strip output flags. Apple clang tries to do a full compile if you don't.
269269
header_cmd = (arg for arg in header_cmd
270-
if arg != '-o' and not arg.endswith('.o'))
270+
if arg != '-o' and not arg.endswith(_get_headers.output_extensions))
271271

272272
# Strip sanitizer ignore lists...so they don't show up in the dependency list.
273273
# See https://clang.llvm.org/docs/SanitizerSpecialCaseList.html and https://github.com/hedronvision/bazel-compile-commands-extractor/issues/34 for more context.
274274
header_cmd = (arg for arg in header_cmd
275275
if not arg.startswith('-fsanitize'))
276276

277+
# Strip syntax-only option since it is ignored when running pre-processor only, and will create noisy warnings.
278+
header_cmd = (arg for arg in header_cmd
279+
if not arg.startswith('-fsyntax-only'))
280+
277281
# Dump system and user headers to stdout...in makefile format.
278282
# Relies on our having made the workspace directory simulate a complete version of the execroot with //external symlink
279283
header_cmd = list(header_cmd)
@@ -422,6 +426,9 @@ def _get_headers_msvc(compile_action, source_path: str):
422426
'/EP', # Preprocess (only, no compilation for speed), writing to stdout where we can easily ignore it instead of a file. https://docs.microsoft.com/en-us/cpp/build/reference/ep-preprocess-to-stdout-without-hash-line-directives
423427
]
424428

429+
# Strip syntax-only (/Zs) option since it is ignored when running pre-processor only, and will create noisy warnings.
430+
header_cmd = (arg for arg in header_cmd if arg != '/Zs')
431+
425432
# cl.exe needs the `INCLUDE` environment variable to find the system headers, since they aren't specified in the action command
426433
# Bazel neglects to include INCLUDE per action, so we'll do the best we can and infer them from the default (host) cc toolchain.
427434
# These are set in https://github.com/bazelbuild/bazel/bloc/master/tools/cpp/windows_cc_configure.bzl. Search INCLUDE.
@@ -608,6 +615,7 @@ def _get_headers(compile_action, source_path: str):
608615

609616
return headers
610617
_get_headers.has_logged = False
618+
_get_headers.output_extensions = ('.o', '.obj', '.processed')
611619

612620

613621
def _get_files(compile_action):
@@ -692,7 +700,7 @@ def _get_files(compile_action):
692700
# Setup extensions and flags for the whole C-language family.
693701
# Clang has a list: https://github.com/llvm/llvm-project/blob/b9f3b7f89a4cb4cf541b7116d9389c73690f78fa/clang/lib/Driver/Types.cpp#L293
694702
_get_files.c_source_extensions = ('.c', '.i', '.h', '.inl')
695-
_get_files.cpp_source_extensions = ('.cc', '.cpp', '.cxx', '.c++', '.C', '.CC', '.cp', '.CPP', '.C++', '.CXX', '.ii', '.hh', '.hpp', '.hxx')
703+
_get_files.cpp_source_extensions = ('.cc', '.cpp', '.cxx', '.c++', '.C', '.CC', '.cp', '.CPP', '.C++', '.CXX', '.ii', '.ipp', '.hh', '.hpp', '.hxx')
696704
_get_files.objc_source_extensions = ('.m',)
697705
_get_files.objcpp_source_extensions = ('.mm', '.M')
698706
_get_files.cuda_source_extensions = ('.cu', '.cui')

0 commit comments

Comments
 (0)