summaryrefslogtreecommitdiffhomepage
path: root/tools/show_paths.bzl
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2021-08-23 10:50:37 -0700
committergVisor bot <gvisor-bot@google.com>2021-08-23 10:53:38 -0700
commit8dc3be7a61c9d8199c66260cd2d416c8e3e0bc96 (patch)
treec2b67a6b00f04364aad5698a42b79af6016ecb06 /tools/show_paths.bzl
parent0a15a216daab9523a5f0c7b93bbceae98dbcbcc1 (diff)
Use --output=starlark trick for all build path parsing.
There is no reason to limit this to debian paths. PiperOrigin-RevId: 392469415
Diffstat (limited to 'tools/show_paths.bzl')
-rw-r--r--tools/show_paths.bzl25
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/show_paths.bzl b/tools/show_paths.bzl
new file mode 100644
index 000000000..ba78d3494
--- /dev/null
+++ b/tools/show_paths.bzl
@@ -0,0 +1,25 @@
+"""Formatter to extract the output files from a target."""
+
+def format(target):
+ provider_map = providers(target)
+ outputs = dict()
+
+ # Try to resolve in order.
+ files_to_run = provider_map.get("FilesToRunProvider", None)
+ default_info = provider_map.get("DefaultInfo", None)
+ output_group_info = provider_map.get("OutputGroupInfo", None)
+ if files_to_run and files_to_run.executable:
+ outputs[files_to_run.executable.path] = True
+ elif default_info:
+ for x in default_info.files:
+ outputs[x.path] = True
+ elif output_group_info:
+ for entry in dir(output_group_info):
+ # Filter out all built-ins and anything that is not a depset.
+ if entry.startswith("_") or not hasattr(getattr(output_group_info, entry), "to_list"):
+ continue
+ for x in getattr(output_group_info, entry).to_list():
+ outputs[x.path] = True
+
+ # Return all found files.
+ return "\n".join(outputs.keys())