kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/docs/schema/asciidoc_with_verifier.bzl (about)

     1  load("//kythe/docs:asciidoc.bzl", "asciidoc")
     2  
     3  def asciidoc_with_verifier(name, src, tags = None):
     4      """Invoke the asciidoc tool on the specified source file, filtering examples to
     5      be passed to the verifier. If the verifier does not succeed, the build will fail.
     6      """
     7  
     8      asciidoc(
     9          name = name,
    10          src = src,
    11          confs = ["kythe-filter.conf"],
    12          example_script = ":example_sh",
    13          data = [
    14              "example-clike.sh",
    15              "example-cxx.sh",
    16              "example-objc.sh",
    17              "example-dot.sh",
    18              "example-go.sh",
    19              "example-java.sh",
    20              "//kythe/cxx/indexer/cxx:indexer",
    21              "//kythe/go/indexer/cmd/go_example:go_example",
    22              "//kythe/go/platform/tools/shasum_tool",
    23              "//kythe/java/com/google/devtools/kythe/analyzers/java:indexer",
    24              "//kythe/cxx/verifier",
    25              "//kythe/java/com/google/devtools/kythe/extractors/java/standalone:javac_extractor",
    26          ],
    27          tags = tags,
    28      )
    29  
    30  def build_example_sh():
    31      """This rule must be executed once to set up the genrule used to plug in tool
    32      paths to the verifier scripts.
    33      """
    34      tools = {
    35          "CXX_INDEXER_BIN": "//kythe/cxx/indexer/cxx:indexer",
    36          "GO_INDEXER_BIN": "//kythe/go/indexer/cmd/go_example:go_example",
    37          "JAVA_INDEXER_BIN": "//kythe/java/com/google/devtools/kythe/analyzers/java:indexer",
    38          "JAVA_EXTRACTOR_BIN": "//kythe/java/com/google/devtools/kythe/extractors/java/standalone:javac_extractor",
    39          "SHASUM_TOOL": "//kythe/go/platform/tools/shasum_tool:shasum_tool",
    40          "VERIFIER_BIN": "//kythe/cxx/verifier",
    41      }
    42      fixes = [
    43          "-e '/^export %s=/{i\\\n_p=($(locations %s))\ns#$$#\"$$ROOT/$${_p[0]}\"#\n}'" % (key, target)
    44          for (key, target) in tools.items()
    45      ]
    46      native.genrule(
    47          name = "example_sh",
    48          srcs = ["example-base.sh"] + tools.values(),
    49          outs = ["example.sh"],
    50          cmd = " ".join(["sed"] + fixes + ["$(location example-base.sh)", ">$@"]),
    51      )