2
0
Fork 0
mirror of https://github.com/bazel-contrib/rules_foreign_cc synced 2024-11-30 16:42:07 +00:00
rules_foreign_cc/docs/BUILD.bazel

90 lines
2.4 KiB
Python
Raw Normal View History

load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@io_bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
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,
)
stardoc(
name = "flatten_docs",
out = "flatten.md",
header_template = ":flatten_header_vm",
input = "docs.bzl",
deps = ["@rules_foreign_cc//:bzl_srcs"],
)
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"],
)
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(
name = "generate_docs_src",
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
""",
)
sh_binary(
name = "generate_docs",
srcs = [":generate_docs_src"],
data = DOCS_TARGETS,
)