diff --git a/utils/bazel/WORKSPACE b/utils/bazel/WORKSPACE --- a/utils/bazel/WORKSPACE +++ b/utils/bazel/WORKSPACE @@ -5,11 +5,11 @@ 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), diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel @@ -2,10 +2,10 @@ # 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"], @@ -1949,13 +1949,13 @@ ], ) -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( diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel @@ -2,7 +2,7 @@ # 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") @@ -108,9 +108,8 @@ 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 @@ -119,6 +118,7 @@ # 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 @@ -2640,13 +2640,13 @@ 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( @@ -2744,13 +2744,13 @@ ], ) -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( @@ -2946,13 +2946,13 @@ 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( @@ -3515,13 +3515,13 @@ ], ) -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( diff --git a/utils/bazel/llvm-project-overlay/llvm/template_rule.bzl b/utils/bazel/llvm-project-overlay/llvm/template_rule.bzl deleted file mode 100644 --- a/utils/bazel/llvm-project-overlay/llvm/template_rule.bzl +++ /dev/null @@ -1,46 +0,0 @@ -# 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, -) diff --git a/utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel @@ -2,13 +2,12 @@ # 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.", @@ -17,6 +16,7 @@ "@LLVM_BINARY_DIR@": package_path("//llvm:BUILD"), "@LLVM_TOOLS_DIR@": package_path("//llvm:BUILD"), }, + template = "lit.site.cfg.in", ) [ diff --git a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel @@ -2,9 +2,9 @@ # 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"], @@ -13,10 +13,9 @@ 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.", @@ -40,6 +39,7 @@ "@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.