Delete unused Bazel deep_copy and template_rule files. (#16186)
Searching history points to
https://github.com/openxla/iree/commit/a6bf65ca220c448b2f73454a66da179ee6c2c414
and
https://github.com/openxla/iree/commit/354b6919083e46f4886323d14721327ac83b5d6a
(or
https://github.com/openxla/iree/commit/10b3e1e8b1b11b9eb67f31f4a2fa469c09054ff8)
for when these were last used. These files aren't particularly complex
and could be added back later as needed.
diff --git a/build_tools/bazel/deep_copy.bzl b/build_tools/bazel/deep_copy.bzl
deleted file mode 100644
index 7203495..0000000
--- a/build_tools/bazel/deep_copy.bzl
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright 2020 The IREE Authors
-#
-# 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
-
-def _is_dict(x):
- return type(x) == type({})
-
-def _is_list(x):
- return type(x) == type([])
-
-# Starlark doesn't support recursion, so we 'simulate' it by copying and pasting.
-def _deep_copy_recursion_depth_3(x):
- """Helper method for deep_copy()."""
- if _is_dict(x) or _is_list(x):
- fail("Cannot make a deep copy of containers nested too deeply")
- return x
-
-def _deep_copy_recursion_depth_2(x):
- """Helper method for deep_copy()."""
- if _is_dict(x):
- return {key: _deep_copy_recursion_depth_3(value) for key, value in x.items()}
- if _is_list(x):
- return [_deep_copy_recursion_depth_3(value) for value in x]
- return x
-
-def _deep_copy_recursion_depth_1(x):
- """Helper method for deep_copy()."""
- if _is_dict(x):
- return {key: _deep_copy_recursion_depth_2(value) for key, value in x.items()}
- if _is_list(x):
- return [_deep_copy_recursion_depth_2(value) for value in x]
- return x
-
-def deep_copy(x):
- """Returns a copy of the argument, making a deep copy if it is a container.
-
- Args:
- x: (object) value to copy. If it is a container with nested containers as
- elements, the maximum nesting depth is restricted to three (e.g.,
- [[[3]]] is okay, but not [[[[4]]]]). If it is a struct, it is treated
- as a value type, i.e., only a shallow copy is made.
- Returns:
- A copy of the argument.
- """
- if _is_dict(x):
- return {key: _deep_copy_recursion_depth_1(value) for key, value in x.items()}
- if _is_list(x):
- return [_deep_copy_recursion_depth_1(value) for value in x]
- return x
diff --git a/build_tools/bazel/template_rule.bzl b/build_tools/bazel/template_rule.bzl
deleted file mode 100644
index 973464d..0000000
--- a/build_tools/bazel/template_rule.bzl
+++ /dev/null
@@ -1,48 +0,0 @@
-# Copyright 2020 The IREE Authors
-#
-# 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("//build_tools/bazel:template_rule.bzl", "template_rule")
-# 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,
-)