blob: 31b5e6cc27bc1d3d948c1d2dc0d08b265063f517 [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
Jingwen Chen762c27d2020-05-14 03:07:03 -070031# Required to move the shared CSS Files from the external repo's execroot location
32# to the _sass location expected by the local css/main.scss imports.
33genrule(
34 name = "style-common",
35 srcs = ["@bazel_website//:_sass/style.scss"],
36 outs = ["_sass/style.scss"],
37 cmd = "cp $< $@",
38)
39
David Chen8a142fe2016-05-06 07:57:17 +000040filegroup(
41 name = "jekyll-srcs",
42 srcs = glob(
43 ["**/*"],
44 exclude = [
45 "BUILD",
46 "jekyll-tree.sh",
47 "*.swp",
Ulf Adams9e24ebd2016-06-23 09:24:57 +000048 "command-line-reference-prefix.html",
49 "command-line-reference-suffix.html",
David Chenf328fde2016-07-27 00:12:32 +000050 "site/README.md",
Kristina Chodorowa028ae22016-12-13 18:59:51 +000051 ] + DOT_GRAPH_HTML_FILES,
Jingwen Chen762c27d2020-05-14 03:07:03 -070052 ) + [
53 ":style-common",
54 ],
David Chen8a142fe2016-05-06 07:57:17 +000055)
56
57pkg_tar(
58 name = "jekyll-files",
John Cater214a7ae2017-08-09 17:24:53 +020059 srcs = [":jekyll-srcs"],
David Chen8a142fe2016-05-06 07:57:17 +000060 strip_prefix = ".",
61)
62
63pkg_tar(
64 name = "bootstrap-css",
John Cater214a7ae2017-08-09 17:24:53 +020065 srcs = ["//third_party/css/bootstrap:bootstrap_css"],
David Chen8a142fe2016-05-06 07:57:17 +000066 package_dir = "assets",
67 strip_prefix = "/third_party/css/bootstrap",
68)
69
70pkg_tar(
71 name = "bootstrap-images",
John Cater214a7ae2017-08-09 17:24:53 +020072 srcs = ["//third_party/css/bootstrap:bootstrap_images"],
David Chen8a142fe2016-05-06 07:57:17 +000073 package_dir = "assets",
74 strip_prefix = "/third_party/css/bootstrap",
75)
76
77pkg_tar(
78 name = "font-awesome-css",
fwe60c1db32020-12-15 07:01:09 -080079 srcs = ["//third_party/css/font_awesome:font_awesome_css"],
David Chen8a142fe2016-05-06 07:57:17 +000080 package_dir = "assets",
81 strip_prefix = "/third_party/css/font_awesome",
82)
83
84pkg_tar(
85 name = "font-awesome-font",
fwe60c1db32020-12-15 07:01:09 -080086 srcs = ["//third_party/css/font_awesome:font_awesome_font"],
David Chen8a142fe2016-05-06 07:57:17 +000087 package_dir = "assets",
88 strip_prefix = "/third_party/css/font_awesome",
89)
90
91pkg_tar(
92 name = "bootstrap-js",
John Cater214a7ae2017-08-09 17:24:53 +020093 srcs = ["//third_party/javascript/bootstrap:bootstrap_js"],
David Chen8a142fe2016-05-06 07:57:17 +000094 package_dir = "assets",
95 strip_prefix = "/third_party/javascript/bootstrap",
96)
97
98pkg_tar(
David Chen3f697512016-05-09 08:46:21 +000099 name = "jekyll-base",
David Chen8a142fe2016-05-06 07:57:17 +0000100 deps = [
101 ":bootstrap-css",
102 ":bootstrap-images",
103 ":bootstrap-js",
Kristina Chodorowa028ae22016-12-13 18:59:51 +0000104 ":dot-graphs",
David Chen8a142fe2016-05-06 07:57:17 +0000105 ":font-awesome-css",
106 ":font-awesome-font",
107 ":jekyll-files",
108 ],
109)
David Chen3f697512016-05-09 08:46:21 +0000110
111pkg_tar(
112 name = "skylark-rule-docs",
John Cater214a7ae2017-08-09 17:24:53 +0200113 srcs = [
David Chen3f697512016-05-09 08:46:21 +0000114 "//tools/build_defs/pkg:README.md",
115 ],
116 strip_prefix = "/tools/build_defs",
117)
118
119genrule(
Kristina Chodorowa028ae22016-12-13 18:59:51 +0000120 name = "dot-graphs",
121 srcs = DOT_GRAPH_HTML_FILES,
122 outs = ["dot.tar"],
123 cmd = """
124origdir=$$PWD
125tmpdir=$$(mktemp -d)
126for f in $(SRCS); do
127 mkdir -p $$tmpdir/$$(dirname $$f)
Klaus Aehlig7ed28be2017-03-02 15:26:38 +0000128 if which dot > /dev/null; then
Kristina Chodorowfc9750c2017-02-09 21:13:13 +0000129 $(location //scripts/docs:generate_dot_graphs) < $$f > $$tmpdir/$$f
130 else
Kristina Chodorow762576e2017-02-10 17:16:28 +0000131 cp $$f $$tmpdir/$$f
Kristina Chodorowfc9750c2017-02-09 21:13:13 +0000132 fi
Kristina Chodorowa028ae22016-12-13 18:59:51 +0000133done
134cd $$tmpdir/site
135tar cf $$origdir/$@ *
136""",
137 tools = ["//scripts/docs:generate_dot_graphs"],
138)
139
Jingwen Chen186bdcd2018-12-14 10:27:23 -0800140# Generate the documentation tree in the current git worktree
Kristina Chodorowa028ae22016-12-13 18:59:51 +0000141genrule(
David Chen3f697512016-05-09 08:46:21 +0000142 name = "jekyll-tree",
143 srcs = [
144 ":jekyll-base",
145 ":skylark-rule-docs",
146 "//src/main/java/com/google/devtools/build/lib:gen_buildencyclopedia",
147 "//src/main/java/com/google/devtools/build/lib:gen_skylarklibrary",
Ulf Adams9e24ebd2016-06-23 09:24:57 +0000148 "//src/main/java/com/google/devtools/build/lib:gen_command-line-reference",
Klaus Aehlig6f52fca2019-03-18 03:43:40 -0700149 "//tools/build_defs/repo:doc",
David Chen3f697512016-05-09 08:46:21 +0000150 ],
151 outs = ["jekyll-tree.tar"],
152 cmd = ("$(location jekyll-tree.sh) $@ " +
wyv565f7742020-05-29 00:41:43 -0700153 DOC_VERSIONS[0]["version"].split("-")[0] + " " +
David Chen3f697512016-05-09 08:46:21 +0000154 "$(location :jekyll-base) " +
155 "$(location :skylark-rule-docs) " +
156 "$(location //src/main/java/com/google/devtools/build/lib:gen_buildencyclopedia) " +
Ulf Adams9e24ebd2016-06-23 09:24:57 +0000157 "$(location //src/main/java/com/google/devtools/build/lib:gen_skylarklibrary) " +
Klaus Aehlig6f52fca2019-03-18 03:43:40 -0700158 "$(location //src/main/java/com/google/devtools/build/lib:gen_command-line-reference) " +
159 "$(location //tools/build_defs/repo:doc)"),
David Chen3f697512016-05-09 08:46:21 +0000160 tools = [
161 "jekyll-tree.sh",
162 ],
163)
Damien Martin-Guillerez49a3e4b2017-11-03 15:30:52 +0100164
165jekyll_build(
166 name = "site",
Jingwen Chen186bdcd2018-12-14 10:27:23 -0800167 srcs = [
Jingwen Chend3a5fd62020-05-05 14:43:23 -0700168 "@jekyll_tree_%s//file" % DOC_VERSION["version"].split("-")[0].replace(".", "_")
Jingwen Chen186bdcd2018-12-14 10:27:23 -0800169 for DOC_VERSION in DOC_VERSIONS
Tony Aiutob2dd6fb2021-06-09 10:29:29 -0700170 ] + [":jekyll-tree"], # jekyll-tree *must* come last to use layouts and includes at head
Damien Martin-Guillerez49a3e4b2017-11-03 15:30:52 +0100171 bucket = "docs.bazel.build",
172)
Jingwen Chen2b237592020-04-08 11:16:00 -0700173
Tony Aiutob2dd6fb2021-06-09 10:29:29 -0700174# A smaller site build target. Contains just the docs for latest released version and head.
Jingwen Chen2b237592020-04-08 11:16:00 -0700175jekyll_build(
176 name = "site_latest",
177 srcs = [
Jingwen Chend3a5fd62020-05-05 14:43:23 -0700178 "@jekyll_tree_%s//file" % DOC_VERSIONS[0]["version"].split("-")[0].replace(".", "_"),
Tony Aiutob2dd6fb2021-06-09 10:29:29 -0700179 ":jekyll-tree", # jekyll-tree *must* come last to use layouts and includes at head
Jingwen Chen2b237592020-04-08 11:16:00 -0700180 ],
181)