blob: d9b4b153d6f4ca90d8ef58a32affde1cb966f6bd [file] [log] [blame]
aiuto11462d12019-07-23 14:46:46 -07001load("@rules_pkg//:pkg.bzl", "pkg_tar")
Damien Martin-Guillerez49a3e4b2017-11-03 15:30:52 +01002load("//scripts/docs:jekyll.bzl", "jekyll_build")
Jingwen Chen186bdcd2018-12-14 10:27:23 -08003load("//scripts/docs:doc_versions.bzl", "DOC_VERSIONS")
David Chen8a142fe2016-05-06 07:57:17 +00004
Dmitry Lomov251d7542015-11-18 16:16:22 +00005exports_files(
Ulf Adams9e24ebd2016-06-23 09:24:57 +00006 [
dmartingcdb8a632017-09-04 11:43:35 +02007 "docs/user-manual.html",
Ulf Adams9e24ebd2016-06-23 09:24:57 +00008 "command-line-reference-prefix.html",
9 "command-line-reference-suffix.html",
10 ],
Dmitry Lomov251d7542015-11-18 16:16:22 +000011)
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +000012
Laszlo Csomor3d215782017-07-27 11:34:09 +020013exports_files(
14 [
15 "images/favicon.ico",
16 ],
17 visibility = ["//src/main/native/windows:__pkg__"],
18)
19
Kristina Chodorowa028ae22016-12-13 18:59:51 +000020DOT_GRAPH_HTML_FILES = [
dzc22b85a22017-05-31 20:37:50 +020021 "docs/query.html",
22 "docs/build-ref.html",
Kristina Chodorowa028ae22016-12-13 18:59:51 +000023]
24
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +000025filegroup(
26 name = "srcs",
27 srcs = glob(["**"]),
28 visibility = ["//:__pkg__"],
29)
David Chen8a142fe2016-05-06 07:57:17 +000030
31filegroup(
32 name = "jekyll-srcs",
33 srcs = glob(
34 ["**/*"],
35 exclude = [
36 "BUILD",
37 "jekyll-tree.sh",
38 "*.swp",
Ulf Adams9e24ebd2016-06-23 09:24:57 +000039 "command-line-reference-prefix.html",
40 "command-line-reference-suffix.html",
David Chenf328fde2016-07-27 00:12:32 +000041 "site/README.md",
Kristina Chodorowa028ae22016-12-13 18:59:51 +000042 ] + DOT_GRAPH_HTML_FILES,
David Chen8a142fe2016-05-06 07:57:17 +000043 ),
44)
45
46pkg_tar(
47 name = "jekyll-files",
John Cater214a7ae2017-08-09 17:24:53 +020048 srcs = [":jekyll-srcs"],
David Chen8a142fe2016-05-06 07:57:17 +000049 strip_prefix = ".",
50)
51
52pkg_tar(
53 name = "bootstrap-css",
John Cater214a7ae2017-08-09 17:24:53 +020054 srcs = ["//third_party/css/bootstrap:bootstrap_css"],
David Chen8a142fe2016-05-06 07:57:17 +000055 package_dir = "assets",
56 strip_prefix = "/third_party/css/bootstrap",
57)
58
59pkg_tar(
60 name = "bootstrap-images",
John Cater214a7ae2017-08-09 17:24:53 +020061 srcs = ["//third_party/css/bootstrap:bootstrap_images"],
David Chen8a142fe2016-05-06 07:57:17 +000062 package_dir = "assets",
63 strip_prefix = "/third_party/css/bootstrap",
64)
65
66pkg_tar(
67 name = "font-awesome-css",
John Cater214a7ae2017-08-09 17:24:53 +020068 srcs = ["//third_party/css/font_awesome:font_awesome_css"],
David Chen8a142fe2016-05-06 07:57:17 +000069 package_dir = "assets",
70 strip_prefix = "/third_party/css/font_awesome",
71)
72
73pkg_tar(
74 name = "font-awesome-font",
John Cater214a7ae2017-08-09 17:24:53 +020075 srcs = ["//third_party/css/font_awesome:font_awesome_font"],
David Chen8a142fe2016-05-06 07:57:17 +000076 package_dir = "assets",
77 strip_prefix = "/third_party/css/font_awesome",
78)
79
80pkg_tar(
81 name = "bootstrap-js",
John Cater214a7ae2017-08-09 17:24:53 +020082 srcs = ["//third_party/javascript/bootstrap:bootstrap_js"],
David Chen8a142fe2016-05-06 07:57:17 +000083 package_dir = "assets",
84 strip_prefix = "/third_party/javascript/bootstrap",
85)
86
87pkg_tar(
David Chen3f697512016-05-09 08:46:21 +000088 name = "jekyll-base",
David Chen8a142fe2016-05-06 07:57:17 +000089 deps = [
90 ":bootstrap-css",
91 ":bootstrap-images",
92 ":bootstrap-js",
Kristina Chodorowa028ae22016-12-13 18:59:51 +000093 ":dot-graphs",
David Chen8a142fe2016-05-06 07:57:17 +000094 ":font-awesome-css",
95 ":font-awesome-font",
96 ":jekyll-files",
97 ],
98)
David Chen3f697512016-05-09 08:46:21 +000099
100pkg_tar(
101 name = "skylark-rule-docs",
John Cater214a7ae2017-08-09 17:24:53 +0200102 srcs = [
David Chen3f697512016-05-09 08:46:21 +0000103 "//tools/build_defs/pkg:README.md",
104 ],
105 strip_prefix = "/tools/build_defs",
106)
107
108genrule(
Kristina Chodorowa028ae22016-12-13 18:59:51 +0000109 name = "dot-graphs",
110 srcs = DOT_GRAPH_HTML_FILES,
111 outs = ["dot.tar"],
112 cmd = """
113origdir=$$PWD
114tmpdir=$$(mktemp -d)
115for f in $(SRCS); do
116 mkdir -p $$tmpdir/$$(dirname $$f)
Klaus Aehlig7ed28be2017-03-02 15:26:38 +0000117 if which dot > /dev/null; then
Kristina Chodorowfc9750c2017-02-09 21:13:13 +0000118 $(location //scripts/docs:generate_dot_graphs) < $$f > $$tmpdir/$$f
119 else
Kristina Chodorow762576e2017-02-10 17:16:28 +0000120 cp $$f $$tmpdir/$$f
Kristina Chodorowfc9750c2017-02-09 21:13:13 +0000121 fi
Kristina Chodorowa028ae22016-12-13 18:59:51 +0000122done
123cd $$tmpdir/site
124tar cf $$origdir/$@ *
125""",
126 tools = ["//scripts/docs:generate_dot_graphs"],
127)
128
Jingwen Chen186bdcd2018-12-14 10:27:23 -0800129# Generate the documentation tree in the current git worktree
Kristina Chodorowa028ae22016-12-13 18:59:51 +0000130genrule(
David Chen3f697512016-05-09 08:46:21 +0000131 name = "jekyll-tree",
132 srcs = [
133 ":jekyll-base",
134 ":skylark-rule-docs",
135 "//src/main/java/com/google/devtools/build/lib:gen_buildencyclopedia",
136 "//src/main/java/com/google/devtools/build/lib:gen_skylarklibrary",
Ulf Adams9e24ebd2016-06-23 09:24:57 +0000137 "//src/main/java/com/google/devtools/build/lib:gen_command-line-reference",
Klaus Aehlig6f52fca2019-03-18 03:43:40 -0700138 "//tools/build_defs/repo:doc",
David Chen3f697512016-05-09 08:46:21 +0000139 ],
140 outs = ["jekyll-tree.tar"],
141 cmd = ("$(location jekyll-tree.sh) $@ " +
142 "$(location :jekyll-base) " +
143 "$(location :skylark-rule-docs) " +
144 "$(location //src/main/java/com/google/devtools/build/lib:gen_buildencyclopedia) " +
Ulf Adams9e24ebd2016-06-23 09:24:57 +0000145 "$(location //src/main/java/com/google/devtools/build/lib:gen_skylarklibrary) " +
Klaus Aehlig6f52fca2019-03-18 03:43:40 -0700146 "$(location //src/main/java/com/google/devtools/build/lib:gen_command-line-reference) " +
147 "$(location //tools/build_defs/repo:doc)"),
David Chen3f697512016-05-09 08:46:21 +0000148 tools = [
149 "jekyll-tree.sh",
150 ],
151)
Damien Martin-Guillerez49a3e4b2017-11-03 15:30:52 +0100152
153jekyll_build(
154 name = "site",
Jingwen Chen186bdcd2018-12-14 10:27:23 -0800155 srcs = [
156 "@jekyll_tree_%s//file" % DOC_VERSION["version"].replace(".", "_")
157 for DOC_VERSION in DOC_VERSIONS
158 ] + [":jekyll-tree"], # jekyll-tree *must* come last to be the default.
Damien Martin-Guillerez49a3e4b2017-11-03 15:30:52 +0100159 bucket = "docs.bazel.build",
160)