Skip to content

Commit

Permalink
Fix flag<>targets warning
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsauer committed Nov 3, 2022
1 parent 7082b8e commit aedc763
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions refresh.template.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,11 @@ def _get_commands(target: str, flags: str):

additional_flags = shlex.split(flags) + sys.argv[1:]

# Detect any positional args--build targets--in the flags, and issue a warning.
if not all(f.startswith('-') for f in additional_flags) or '--' in additional_flags[:-1]:
# Detect anything that looks like a build target in the flags, and issue a warning.
# Note that positional arguments after -- are all interpreted as target patterns. (If it's at the end, then no worries.)
# And that we have to look for targets. checking for a - prefix is not enough. Consider the case of `-c opt` leading to a false positive
if ('--' in additional_flags[:-1]
or any(re.match(r'-?(@|:|//)', f) for f in additional_flags)):
log_warning(""">>> The flags you passed seem to contain targets.
Try adding them as targets in your refresh_compile_commands rather than flags.
[Specifying targets at runtime isn't supported yet, and in a moment, Bazel will likely fail to parse without our help. If you need to be able to specify targets at runtime, and can't easily just add them to your refresh_compile_commands, please open an issue or file a PR. You may also want to refer to https://github.com/hedronvision/bazel-compile-commands-extractor/issues/62.]""")
Expand Down

0 comments on commit aedc763

Please sign in to comment.