forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefs.bzl
49 lines (44 loc) · 1.67 KB
/
defs.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# This file contains build macros and constants that help define Drake's
# documentation targets (i.e., these should only be used for BUILD files
# within @drake//doc/...).
# Unless `setup/ubuntu/install_prereqs.sh --with-doc-only` has been run, most
# tests in //doc/... will fail to pass, so by default we'll disable them.
#
# A developer will have to explicitly opt-in in order to test these.
DEFAULT_TEST_TAGS = [
"manual",
# None of our documentation tools should hit the internet, but their
# ecosystems might be doing so without us being aware.
"block-network",
]
def _enumerate_filegroup_impl(ctx):
out = ctx.actions.declare_file(ctx.attr.name)
runpaths = {}
for x in ctx.attr.data:
for y in x.data_runfiles.files.to_list():
if y.short_path.startswith("../"):
runpath = y.short_path[3:]
else:
runpath = ctx.workspace_name + "/" + y.short_path
runpaths[runpath] = True
result = sorted(runpaths.keys())
ctx.actions.write(out, "\n".join(result) + "\n")
# Return the new file to our caller.
return [DefaultInfo(
files = depset([out]),
data_runfiles = ctx.runfiles(files = [out]),
)]
enumerate_filegroup = rule(
implementation = _enumerate_filegroup_impl,
doc = """
Creates a text file listing the files incorporated into the given filegroup.
The listing is transitive (includes both filegroup.srcs and filegroup.data).
https://docs.bazel.build/versions/master/be/general.html#filegroup
""",
attrs = {
"data": attr.label_list(
allow_empty = False,
doc = "Filegroup whose data we should enumerate",
),
},
)