Skip to content

Commit aedc763

Browse files
committed
Fix flag<>targets warning
#82
1 parent 7082b8e commit aedc763

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

refresh.template.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,11 @@ def _get_commands(target: str, flags: str):
799799

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

802-
# Detect any positional args--build targets--in the flags, and issue a warning.
803-
if not all(f.startswith('-') for f in additional_flags) or '--' in additional_flags[:-1]:
802+
# Detect anything that looks like a build target in the flags, and issue a warning.
803+
# Note that positional arguments after -- are all interpreted as target patterns. (If it's at the end, then no worries.)
804+
# 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
805+
if ('--' in additional_flags[:-1]
806+
or any(re.match(r'-?(@|:|//)', f) for f in additional_flags)):
804807
log_warning(""">>> The flags you passed seem to contain targets.
805808
Try adding them as targets in your refresh_compile_commands rather than flags.
806809
[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.]""")

0 commit comments

Comments
 (0)