Skip to content

Commit

Permalink
fix: remove use of label ctor in repo rule impl to avoid restarts (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattem authored May 25, 2023
1 parent b397ad2 commit ceeedcc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
12 changes: 6 additions & 6 deletions toolchain/internal/configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def llvm_register_toolchains():
# Convenience macro to register all generated toolchains.
rctx.template(
"toolchains.bzl",
Label("//toolchain:toolchains.bzl.tpl"),
rctx.attr._toolchains_bzl_tpl,
{
"%{toolchain_labels}": toolchain_labels_str,
},
Expand All @@ -198,7 +198,7 @@ def llvm_register_toolchains():
# BUILD file with all the generated toolchain definitions.
rctx.template(
"BUILD.bazel",
Label("//toolchain:BUILD.toolchain.tpl"),
rctx.attr._build_toolchain_tpl,
{
"%{cc_toolchain_config_bzl}": str(rctx.attr._cc_toolchain_config_bzl),
"%{cc_toolchains}": cc_toolchains_str,
Expand All @@ -210,12 +210,12 @@ def llvm_register_toolchains():

# CC wrapper script; see comments near the definition of `wrapper_bin_prefix`.
if os == "darwin":
cc_wrapper_tpl = "//toolchain:osx_cc_wrapper.sh.tpl"
cc_wrapper_tpl = rctx.attr._darwin_cc_wrapper_sh_tpl
else:
cc_wrapper_tpl = "//toolchain:cc_wrapper.sh.tpl"
cc_wrapper_tpl = rctx.attr._cc_wrapper_sh_tpl
rctx.template(
"bin/cc_wrapper.sh",
Label(cc_wrapper_tpl),
cc_wrapper_tpl,
{
"%{toolchain_path_prefix}": llvm_dist_path_prefix,
},
Expand All @@ -224,7 +224,7 @@ def llvm_register_toolchains():
# libtool wrapper; used if the host libtool doesn't support arg files:
rctx.template(
"bin/host_libtool_wrapper.sh",
Label("//toolchain:host_libtool_wrapper.sh.tpl"),
rctx.attr._host_libtool_wrapper_sh_tpl,
{
"%{libtool_path}": "/usr/bin/libtool",
},
Expand Down
15 changes: 15 additions & 0 deletions toolchain/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,21 @@ _llvm_config_attrs.update({
"_cc_toolchain_config_bzl": attr.label(
default = "//toolchain:cc_toolchain_config.bzl",
),
"_toolchains_bzl_tpl": attr.label(
default = "//toolchain:toolchains.bzl.tpl",
),
"_build_toolchain_tpl": attr.label(
default = "//toolchain:BUILD.toolchain.tpl",
),
"_darwin_cc_wrapper_sh_tpl": attr.label(
default = "//toolchain:osx_cc_wrapper.sh.tpl",
),
"_cc_wrapper_sh_tpl": attr.label(
default = "//toolchain:cc_wrapper.sh.tpl",
),
"_host_libtool_wrapper_sh_tpl": attr.label(
default = "//toolchain:host_libtool_wrapper.sh.tpl",
),
})

llvm = repository_rule(
Expand Down

0 comments on commit ceeedcc

Please sign in to comment.