load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
-SKYLIB_VERSION = "1.0.3"
+SKYLIB_VERSION = "1.3.0"
http_archive(
name = "bazel_skylib",
- sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
+ sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version=SKYLIB_VERSION),
"https://github.com/bazelbuild/bazel-skylib/releases/download/{version}/bazel-skylib-{version}.tar.gz".format(version=SKYLIB_VERSION),
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("//llvm:tblgen.bzl", "gentbl")
load("//llvm:binary_alias.bzl", "binary_alias")
load("//llvm:cc_plugin_library.bzl", "cc_plugin_library")
-load("//llvm:template_rule.bzl", "template_rule")
package(
default_visibility = ["//visibility:public"],
],
)
-template_rule(
+expand_template(
name = "clang_main",
- src = "//llvm:cmake/modules/llvm-driver-template.cpp.in",
out = "clang-driver.cpp",
substitutions = {
"@TOOL_NAME@": "clang",
},
+ template = "//llvm:cmake/modules/llvm-driver-template.cpp.in",
)
cc_library(
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-load(":template_rule.bzl", "template_rule")
+load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load(":tblgen.bzl", "gentbl")
load(":config.bzl", "llvm_config_defines")
load(":targets.bzl", "llvm_targets")
targets = llvm_target_exegesis,
)
-template_rule(
+expand_template(
name = "abi_breaking_h_gen",
- src = "include/llvm/Config/abi-breaking.h.cmake",
out = "include/llvm/Config/abi-breaking.h",
substitutions = {
# Define to enable checks that alter the LLVM C++ ABI
# Define to enable reverse iteration of unordered llvm containers
"#cmakedefine01 LLVM_ENABLE_REVERSE_ITERATION": "#define LLVM_ENABLE_REVERSE_ITERATION 0",
},
+ template = "include/llvm/Config/abi-breaking.h.cmake",
)
# To enable diff testing out of tree
td_srcs = ["include/llvm/Option/OptParser.td"],
)
-template_rule(
+expand_template(
name = "dsymutil_main",
- src = "cmake/modules/llvm-driver-template.cpp.in",
out = "dsymutil-driver.cpp",
substitutions = {
"@TOOL_NAME@": "dsymutil",
},
+ template = "cmake/modules/llvm-driver-template.cpp.in",
)
cc_binary(
],
)
-template_rule(
+expand_template(
name = "ar_main",
- src = "cmake/modules/llvm-driver-template.cpp.in",
out = "llvm-ar-driver.cpp",
substitutions = {
"@TOOL_NAME@": "llvm_ar",
},
+ template = "cmake/modules/llvm-driver-template.cpp.in",
)
cc_binary(
td_srcs = ["include/llvm/Option/OptParser.td"],
)
-template_rule(
+expand_template(
name = "cxxfilt_main",
- src = "cmake/modules/llvm-driver-template.cpp.in",
out = "llvm-cxxfilt-driver.cpp",
substitutions = {
"@TOOL_NAME@": "llvm_cxxfilt",
},
+ template = "cmake/modules/llvm-driver-template.cpp.in",
)
cc_binary(
],
)
-template_rule(
+expand_template(
name = "objcopy_main",
- src = "cmake/modules/llvm-driver-template.cpp.in",
out = "llvm-objcopy-driver.cpp",
substitutions = {
"@TOOL_NAME@": "llvm_objcopy",
},
+ template = "cmake/modules/llvm-driver-template.cpp.in",
)
cc_binary(
+++ /dev/null
-# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
-# See https://llvm.org/LICENSE.txt for license information.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-# Rule for simple expansion of template files. This performs a simple
-# search over the template file for the keys in substitutions,
-# and replaces them with the corresponding values.
-#
-# Typical usage:
-# load("/tools/build_rules/template_rule", "expand_header_template")
-# template_rule(
-# name = "ExpandMyTemplate",
-# src = "my.template",
-# out = "my.txt",
-# substitutions = {
-# "$VAR1": "foo",
-# "$VAR2": "bar",
-# }
-# )
-#
-# Args:
-# name: The name of the rule.
-# template: The template file to expand
-# out: The destination of the expanded file
-# substitutions: A dictionary mapping strings to their substitutions
-
-def template_rule_impl(ctx):
- ctx.actions.expand_template(
- template = ctx.file.src,
- output = ctx.outputs.out,
- substitutions = ctx.attr.substitutions,
- )
-
-template_rule = rule(
- attrs = {
- "src": attr.label(
- mandatory = True,
- allow_single_file = True,
- ),
- "substitutions": attr.string_dict(mandatory = True),
- "out": attr.output(mandatory = True),
- },
- # output_to_genfiles is required for header files.
- output_to_genfiles = True,
- implementation = template_rule_impl,
-)
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-load("//llvm:template_rule.bzl", "template_rule")
+load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("//llvm:lit_test.bzl", "lit_test", "package_path")
-template_rule(
+expand_template(
name = "lit_site_cfg",
testonly = True,
- src = "lit.site.cfg.in",
out = "lit.site.cfg",
substitutions = {
"@LIT_SITE_CFG_IN_HEADER@": "# Autogenerated, do not edit.",
"@LLVM_BINARY_DIR@": package_path("//llvm:BUILD"),
"@LLVM_TOOLS_DIR@": package_path("//llvm:BUILD"),
},
+ template = "lit.site.cfg.in",
)
[
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library")
load("//llvm:lit_test.bzl", "package_path")
-load("//llvm:template_rule.bzl", "template_rule")
package(
default_visibility = ["//visibility:public"],
licenses(["notice"])
-template_rule(
+expand_template(
name = "lit_site_cfg_py",
testonly = True,
- src = "lit.site.cfg.py.in",
out = "lit.site.cfg.py",
substitutions = {
"@LIT_SITE_CFG_IN_HEADER@": "# Autogenerated, do not edit.",
"@MLIR_RUN_CUDA_TENSOR_CORE_TESTS@": "0",
"@MLIR_INCLUDE_INTEGRATION_TESTS@": "0",
},
+ template = "lit.site.cfg.py.in",
)
# Common data used by most lit tests.