1# Copyright 2024 The Bazel Authors. All rights reserved. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15load("@bazel_skylib//rules:diff_test.bzl", "diff_test") 16load("@bazel_skylib//rules:expand_template.bzl", "expand_template") 17load("@stardoc//stardoc:stardoc.bzl", "stardoc") 18load("//cc/toolchains/impl:documented_api.bzl", "DOCUMENTED_TOOLCHAIN_RULES") 19load("//cc/toolchains/impl:markdown_helpers.bzl", "xref_substitutions") 20 21filegroup( 22 name = "srcs", 23 srcs = glob([ 24 "**/*.bzl", 25 "**/BUILD", 26 ]), 27 visibility = ["//visibility:public"], 28) 29 30stardoc( 31 name = "toolchain_api", 32 out = "raw_generated_toolchain_api.md", 33 input = "//cc/toolchains/impl:documented_api.bzl", 34 deps = ["//cc/toolchains:toolchain_rules"], 35) 36 37expand_template( 38 name = "toolchain_api_md", 39 out = "generated_toolchain_api.md", 40 # Dictionary order 100% matters here! 41 # buildifier: disable=unsorted-dict-items 42 substitutions = { 43 # Strip @rules_cc to prevent instances of @rules_cc@rules_cc//cc. 44 "@rules_cc//cc": "//cc", 45 # In GitHub, we prefer to clarify all the labels that come from 46 # rules_cc. 47 "//cc": "@rules_cc//cc", 48 } | xref_substitutions({ 49 "`{}`".format(rule_name): "#{}".format(rule_name) 50 for rule_name in DOCUMENTED_TOOLCHAIN_RULES 51 }), 52 # buildifier: enable=unsorted-dict-items 53 template = ":raw_generated_toolchain_api.md", 54) 55 56diff_test( 57 name = "toolchain_api_diff_test", 58 file1 = ":generated_toolchain_api.md", 59 file2 = ":toolchain_api.md", 60) 61