Skip to content

Commit

Permalink
misc: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
rrbutani committed Oct 22, 2023
1 parent a49e833 commit 35c601b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
12 changes: 7 additions & 5 deletions toolchain/internal/configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ load(
)
load(
"//toolchain/internal:common.bzl",
_BZLMOD_ENABLED = "BZLMOD_ENABLED",
_arch = "arch",
_canonical_dir_path = "canonical_dir_path",
_check_os_arch_keys = "check_os_arch_keys",
Expand All @@ -31,7 +32,6 @@ load(
_pkg_path_from_label = "pkg_path_from_label",
_supported_targets = "SUPPORTED_TARGETS",
_toolchain_tools = "toolchain_tools",
_BZLMOD_ENABLED = "BZLMOD_ENABLED",
)
load(
"//toolchain/internal:sysroot.bzl",
Expand All @@ -42,7 +42,9 @@ load(
def _make_string_label(repository, package, target):
return "{prefix}{repo}//{package}:{target}".format(
prefix = "@@" if _BZLMOD_ENABLED else "@",
repo = repository, package = package, target = target,
repo = repository,
package = package,
target = target,
)

def llvm_config_impl(rctx):
Expand All @@ -66,7 +68,7 @@ def llvm_register_toolchains():
if not rctx.attr.toolchain_roots:
# target name does not matter here; it's dropped later
toolchain_root = struct(
label = Label(_make_string_label("%s_llvm" % rctx.attr.name, "", "BUILD.bazel"))
label = Label(_make_string_label("%s_llvm" % rctx.attr.name, "", "BUILD.bazel")),
)
else:
(_key, toolchain_root_val) = _host_os_arch_dict_value(rctx, "toolchain_roots")
Expand All @@ -83,7 +85,7 @@ def llvm_register_toolchains():
# Otherwise, interpret as a key into `toolchain_roots_label_map`:

# Flip the map (note: no error on duplicate "keys" for now)
label_map = { key: label for label, key in rctx.attr.toolchain_roots_label_map.items() }
label_map = {key: label for label, key in rctx.attr.toolchain_roots_label_map.items()}

if not toolchain_root_val in label_map:
fail(("Value in `toolchain_roots` {key} was interpreted as a `toolchain_roots_label_map` " +
Expand Down Expand Up @@ -154,7 +156,7 @@ def llvm_register_toolchains():
symlinked_tools_str = ""

# Flip the sysroot label map (note: no error on duplicate "keys" for now)
_sysroot_label_map = { key: label for label, key in rctx.attr.sysroot_label_map.items() }
_sysroot_label_map = {key: label for label, key in rctx.attr.sysroot_label_map.items()}
sysroot_paths_dict, sysroot_labels_dict = _sysroot_paths_dict(
rctx,
rctx.attr.sysroot,
Expand Down
10 changes: 5 additions & 5 deletions toolchain/internal/repo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ llvm_config_attrs.update({
# This map is inverted (Label -> key instead of key -> Label) because
# there isn't a `string_keyed_label_dict`.
doc = ("Inverted map from toolchain root Label to string identifier.\n" +
"This attribute is to be used with `toolchain_roots` in order to specify roots " +
"that come from a Bazel package. Keys can be any identifier that do not start " +
"with a forward slash '/`.\n" +
"Note that the target name in the Label to the root provided here is ignored: " +
"only the Label's repository and package are used."),
"This attribute is to be used with `toolchain_roots` in order to specify roots " +
"that come from a Bazel package. Keys can be any identifier that do not start " +
"with a forward slash '/`.\n" +
"Note that the target name in the Label to the root provided here is ignored: " +
"only the Label's repository and package are used."),
),
"absolute_paths": attr.bool(
default = False,
Expand Down
5 changes: 3 additions & 2 deletions toolchain/internal/sysroot.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ def _sysroot_path(sysroot_dict, label_map, os, arch):
# Otherwise, consult the label map:
if sysroot not in label_map:
fail(("Value in `sysroot` {key} was interpreted as a `sysroot_label_map` " +
"key but it is not present in the map: {map}").format(
key = sysroot, map = label_map,
"key but it is not present in the map: {map}").format(
key = sysroot,
map = label_map,
))
label = label_map[sysroot]

Expand Down

0 comments on commit 35c601b

Please sign in to comment.