Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions refresh.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ def _get_headers_gcc(compile_action, source_path: str, action_key: str):
header_cmd = (arg for arg in header_cmd
if arg != '-o' and not arg.endswith('.o'))

# Strip -c flag which is unused during dependency generation (-M) and causes
# "argument unused during compilation" warnings with clang -Werror.
# See https://github.com/hedronvision/bazel-compile-commands-extractor/issues/273
header_cmd = (arg for arg in header_cmd if arg != '-c')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: also strip '/c' (similar situation in windows).


# Strip sanitizer ignore lists...so they don't show up in the dependency list.
# See https://clang.llvm.org/docs/SanitizerSpecialCaseList.html and https://github.com/hedronvision/bazel-compile-commands-extractor/issues/34 for more context.
header_cmd = (arg for arg in header_cmd
Expand Down
8 changes: 8 additions & 0 deletions refresh_compile_commands.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,20 @@ def refresh_compile_commands(
_expand_template(name = script_name, labels_to_flags = targets, exclude_headers = exclude_headers, exclude_external_sources = exclude_external_sources, **kwargs)

# Combine them so the wrapper calls the main script
# Add "manual" tag to prevent this target from being built with `bazel build //...`
# when cross-compiling, which would fail due to missing toolchain for the target platform.
# This target is meant to be run with `bazel run`, not built as part of regular builds.
# See https://github.com/hedronvision/bazel-compile-commands-extractor/issues/255
tags = kwargs.pop("tags", [])
if "manual" not in tags:
tags = tags + ["manual"]
native.py_binary(
name = name,
main = version_checker_script_name,
srcs = [version_checker_script_name, script_name],
data = ["@hedron_compile_commands//:print_args"],
imports = [''], # Allows binary to import templated script, even if this macro is being called inside a sub package. See https://github.com/hedronvision/bazel-compile-commands-extractor/issues/137
tags = tags,
**kwargs
)

Expand Down