MCPcopy Create free account
hub / github.com/pytorch/executorch / query_targets

Function query_targets

scripts/print_public_headers.py:38–68  ·  view source on GitHub ↗

Returns the BuildTargets matching the query, keyed by target name.

(query: str)

Source from the content-addressed store, hash-verified

36
37
38def query_targets(query: str) -> Dict[str, BuildTarget]:
39 """Returns the BuildTargets matching the query, keyed by target name."""
40 args: List[str] = [
41 "buck2",
42 "cquery",
43 query,
44 "--output-attribute",
45 "exported_deps",
46 "--output-attribute",
47 "exported_headers",
48 "--output-attribute",
49 "visibility",
50 ]
51 cp: subprocess.CompletedProcess = subprocess.run(
52 args, capture_output=True, cwd=BUCK_CWD, check=True
53 )
54 # stdout should be a JSON object like P643366873.
55 targets: dict = json.loads(cp.stdout)
56
57 ret: Dict[str, BuildTarget] = {}
58 for name, info in targets.items():
59 # Target strings may have an extra " (mode//config/string)" at the end.
60 name = name.split(" ", 1)[0]
61 exported_deps = [d.split(" ", 1)[0] for d in info.get("exported_deps", [])]
62 ret[name] = BuildTarget(
63 name=name,
64 exported_deps=exported_deps,
65 exported_headers=info.get("exported_headers", []),
66 visibility=info.get("visibility", []),
67 )
68 return ret
69
70
71def targets_exported_by(

Callers 1

mainFunction · 0.85

Calls 5

BuildTargetClass · 0.85
itemsMethod · 0.80
splitMethod · 0.80
runMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected