-
Notifications
You must be signed in to change notification settings - Fork 7
/
BUILD.bazel
68 lines (62 loc) · 1.54 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
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier", "buildifier_test")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
sh_binary(
name = "skyscope",
srcs = ["//release:entrypoint.sh"],
data = ["//backend:skyscope"],
env = {
"SKYSCOPE_BINARY": "$(rootpath //backend:skyscope)",
},
visibility = ["//visibility:public"],
)
buildifier(
name = "buildifier",
)
buildifier_test(
name = "buildifier_test",
srcs = glob([
"**/*.bazel",
"**/*.bzl",
]),
)
sh_binary(
name = "update-readme-toc",
srcs = [":update-toc.sh"],
args = ["$(execpath :extract-toc.sed)"],
data = [":extract-toc.sed"],
)
write_file(
name = "write-update-toc.sh",
out = "update-toc.sh",
content = [
"set -eux",
"SANDBOX=$PWD",
"cd $BUILD_WORKSPACE_DIRECTORY",
"(",
" sed -n '1,/BEGIN-TOC/ p' README.md",
" sed -n -f ${1?missing script arg} README.md",
" sed -n '/END-TOC/,$ p' README.md",
") >$SANDBOX/README.md",
"mv -v $SANDBOX/README.md .",
],
)
write_file(
name = "write-extract-toc",
out = "extract-toc.sed",
content = [
"/END-TOC/,$ {",
" s/^##\\(#*\\) /\\1- /",
" T",
" s/#/ /",
" h",
" s/\\s*- \\(.*\\)/\\L\\1/",
" s/[`]//g",
" s/ /-/g",
" s/.*/(#&)/",
" x",
" G",
" s/- \\([^\\n]*\\)\\n\\(.*\\)/- [\\1]\\2/",
" p",
"}",
],
)