-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBUILD.bazel
70 lines (64 loc) · 1.52 KB
/
BUILD.bazel
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
package(default_visibility = ["//visibility:private"])
# Targets to document.
# Must have a corresponding `bzl_library` target in `//rules:BUILD.bazel`.
_DOC_SRCS = [
"app_clip",
"app",
"extension",
"features",
"framework",
"hmap",
"import_middleman",
"library",
"plists",
"precompiled_apple_resource_bundle",
"providers",
"substitute_build_settings",
"test",
"transition_support",
"vfs_overlay.doc",
"xcconfig.doc",
]
# Create stardoc targets for each documentation target defined
[
stardoc(
name = file + "_doc",
out = file + ".gen.md",
input = "//rules:%s.bzl" % file,
tags = [
"no-cache",
"no-sandbox", # https://github.com/bazelbuild/stardoc/issues/112
],
deps = ["//rules:" + file],
)
for file in _DOC_SRCS
]
filegroup(
name = "_all_docs",
srcs = ["%s.gen.md" % name for name in _DOC_SRCS],
)
genrule(
name = "docs",
srcs = [
":_all_docs",
],
outs = [
"generate_docs.sh",
],
cmd = """
echo "#!/bin/bash" > $(OUTS)
echo "set -eu" > $(OUTS)
echo 'function copy() {
src_name=$$(basename "$$1")
dest_name=$${src_name%%.*}_doc.md # replace generated extension with '_doc.md'
dest="$${BUILD_WORKSPACE_DIRECTORY}/docs/$${dest_name}"
cp "$$1" "$$dest"
chmod +w "$$dest"
}' >> $(OUTS)
for s in $(SRCS); do
echo "copy '$$s'" >> $(OUTS)
done
""",
executable = 1,
)