2021-06-02 18:58:56 +00:00
|
|
|
load("@bazel_skylib//rules:build_test.bzl", "build_test")
|
2021-02-02 20:09:33 +00:00
|
|
|
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
|
2021-01-22 14:25:49 +00:00
|
|
|
|
2021-01-24 23:23:19 +00:00
|
|
|
genrule(
|
|
|
|
name = "flatten_header_vm",
|
|
|
|
srcs = [
|
|
|
|
"gen_header.sh",
|
|
|
|
"docs.bzl",
|
|
|
|
],
|
|
|
|
outs = ["flatten_header.vm"],
|
|
|
|
cmd = "$(location gen_header.sh) $(location docs.bzl) $@",
|
|
|
|
output_to_bindir = True,
|
|
|
|
)
|
|
|
|
|
2021-01-22 14:25:49 +00:00
|
|
|
stardoc(
|
2021-06-02 18:58:56 +00:00
|
|
|
name = "flatten_docs",
|
|
|
|
out = "flatten.md",
|
2021-01-24 23:23:19 +00:00
|
|
|
header_template = ":flatten_header_vm",
|
2021-01-22 14:25:49 +00:00
|
|
|
input = "docs.bzl",
|
|
|
|
deps = ["@rules_foreign_cc//:bzl_srcs"],
|
|
|
|
)
|
|
|
|
|
2021-06-02 18:58:56 +00:00
|
|
|
stardoc(
|
|
|
|
name = "cmake_docs",
|
|
|
|
out = "cmake.md",
|
|
|
|
header_template = "common_header.vm",
|
|
|
|
input = "@rules_foreign_cc//foreign_cc:cmake.bzl",
|
|
|
|
deps = ["@rules_foreign_cc//:bzl_srcs"],
|
|
|
|
)
|
|
|
|
|
|
|
|
stardoc(
|
|
|
|
name = "make_docs",
|
|
|
|
out = "make.md",
|
|
|
|
header_template = "common_header.vm",
|
|
|
|
input = "@rules_foreign_cc//foreign_cc:make.bzl",
|
|
|
|
deps = ["@rules_foreign_cc//:bzl_srcs"],
|
|
|
|
)
|
|
|
|
|
|
|
|
stardoc(
|
|
|
|
name = "ninja_docs",
|
|
|
|
out = "ninja.md",
|
|
|
|
header_template = "common_header.vm",
|
|
|
|
input = "@rules_foreign_cc//foreign_cc:ninja.bzl",
|
|
|
|
deps = ["@rules_foreign_cc//:bzl_srcs"],
|
2021-01-22 14:25:49 +00:00
|
|
|
)
|
|
|
|
|
2021-06-02 18:58:56 +00:00
|
|
|
stardoc(
|
|
|
|
name = "configure_make_docs",
|
|
|
|
out = "configure_make.md",
|
|
|
|
header_template = "common_header.vm",
|
|
|
|
input = "@rules_foreign_cc//foreign_cc:configure.bzl",
|
|
|
|
deps = ["@rules_foreign_cc//:bzl_srcs"],
|
|
|
|
)
|
|
|
|
|
|
|
|
DOCS_TARGETS = [
|
|
|
|
":flatten_docs",
|
|
|
|
":cmake_docs",
|
|
|
|
":ninja_docs",
|
|
|
|
":make_docs",
|
|
|
|
":configure_make_docs",
|
|
|
|
]
|
|
|
|
|
|
|
|
build_test(
|
|
|
|
name = "docs_build_test",
|
|
|
|
targets = DOCS_TARGETS,
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
|
|
|
|
genrule(
|
2021-01-22 14:25:49 +00:00
|
|
|
name = "generate_docs_src",
|
2021-06-02 18:58:56 +00:00
|
|
|
srcs = DOCS_TARGETS,
|
|
|
|
outs = ["generate_docs.sh"],
|
|
|
|
cmd = """cat << EOF > $@
|
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(location //:flatten_docs) > \\$${BUILD_WORKSPACE_DIRECTORY}/flatten.md
|
|
|
|
cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(location //:cmake_docs) > \\$${BUILD_WORKSPACE_DIRECTORY}/cmake.md
|
|
|
|
cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(location //:ninja_docs) > \\$${BUILD_WORKSPACE_DIRECTORY}/ninja.md
|
|
|
|
cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(location //:make_docs) > \\$${BUILD_WORKSPACE_DIRECTORY}/make.md
|
|
|
|
cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(location //:configure_make_docs) > \\$${BUILD_WORKSPACE_DIRECTORY}/configure_make.md
|
|
|
|
EOF
|
|
|
|
""",
|
2021-01-22 14:25:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
sh_binary(
|
|
|
|
name = "generate_docs",
|
|
|
|
srcs = [":generate_docs_src"],
|
2021-06-02 18:58:56 +00:00
|
|
|
data = DOCS_TARGETS,
|
2021-01-22 14:25:49 +00:00
|
|
|
)
|