Skip to content
Merged
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
12 changes: 10 additions & 2 deletions build/print_exported_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@
raise SystemExit("Error: " + str(e))


# Cache to store results for exported headers per target.
_exported_headers_cache = {}

Check failure on line 42 in build/print_exported_headers.py

View workflow job for this annotation

GitHub Actions / lintrunner / linux-job

MYPY var-annotated

Need type annotation for "_exported_headers_cache" (hint: "_exported_headers_cache: dict[<type>, <type>] = ...") To disable, use ` # type: ignore[var-annotated]`


def exported_headers(buck2: str, target: str) -> Set[str]:
"""Get all exported headers of a target and its dependencies."""
"""Get all exported headers of a target and its dependencies, with caching."""
if target in _exported_headers_cache:
return _exported_headers_cache[target]

deps = query(buck2, target, "exported_deps")
headers = set(query(buck2, target, "exported_headers"))
headers.update(
Expand All @@ -48,13 +55,14 @@
for header in exported_headers(buck2, dep.split()[0])
if header.endswith(".h")
)
_exported_headers_cache[target] = headers
return headers


def expand_target(buck2: str, target: str) -> List[str]:
"""Expand a target into a list of targets if applicable."""
output = run([buck2, "cquery", target])
# Buck's output format is "<target> (<build platform>)", we take only the target part.
# Buck's output format is "<target> (<build platform>)", so we take only the target part.
targets = [line.split(" ")[0] for line in output.strip().split("\n")]
return targets

Expand Down
Loading