diff --git a/refresh.template.py b/refresh.template.py index 194f365..ad56da7 100644 --- a/refresh.template.py +++ b/refresh.template.py @@ -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') + # 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 diff --git a/refresh_compile_commands.bzl b/refresh_compile_commands.bzl index 0210d42..821ab70 100644 --- a/refresh_compile_commands.bzl +++ b/refresh_compile_commands.bzl @@ -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 )