Skip to content

Commit 58e5d2e

Browse files
committed
file based filter
1 parent a426081 commit 58e5d2e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

refresh.template.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,9 @@ def _get_commands(target: str, flags: str):
834834
# Log clear completion messages
835835
log_info(f">>> Analyzing commands used in {target}")
836836

837-
additional_flags = shlex.split(flags) + sys.argv[1:]
837+
additional_flags = shlex.split(flags) + [arg for arg in sys.argv[1:] if not arg.startswith('--file=')]
838+
file_flags = [arg for arg in sys.argv[1:] if arg.startswith('--file=')]
839+
assert len(file_flags) < 2, f"Only one or zero --file is supported current args = {sys.argv[1:]}"
838840

839841
# Detect anything that looks like a build target in the flags, and issue a warning.
840842
# Note that positional arguments after -- are all interpreted as target patterns. (If it's at the end, then no worries.)
@@ -857,6 +859,16 @@ def _get_commands(target: str, flags: str):
857859
if {exclude_external_sources}:
858860
# For efficiency, have bazel filter out external targets (and therefore actions) before they even get turned into actions or serialized and sent to us. Note: this is a different mechanism than is used for excluding just external headers.
859861
target_statment = f"filter('^//',{target_statment})"
862+
if (len(file_flags) == 1):
863+
# Strip --file=
864+
file_path = file_flags[0][7:]
865+
# For header file we try to find from hdrs and srcs to get the targets
866+
if file_path.endswith('.h'):
867+
# Since attr function can't query with full path, get the file name to query
868+
head, tail = os.path.split(file_path)
869+
target_statment = f"attr(hdrs, '{tail}', {target_statment}) + attr(srcs, '{tail}', {target_statment})"
870+
else:
871+
target_statment = f"inputs('{file_path}', {target_statment})"
860872
aquery_args = [
861873
'bazel',
862874
'aquery',

0 commit comments

Comments
 (0)