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 47a1110 commit c6862fd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
23 changes: 15 additions & 8 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 Down Expand Up @@ -77,12 +79,13 @@ 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 in label_map:
fail(("Value in `toolchain_roots` {key} was interpreted as a `toolchain_roots_label_map` " +
"key but it is not present in `toolchain_roots_label_map`: {map}").format(
key = toolchain_root, map = label_map,
"key but it is not present in `toolchain_roots_label_map`: {map}").format(
key = toolchain_root,
map = label_map,
))
toolchain_root = label_map[toolchain_root]

Expand All @@ -101,7 +104,9 @@ def llvm_register_toolchains():
#
# TODO: should we just use the target name in the Label that was given?
llvm_dist_label = Label(_make_string_label(
toolchain_root.workspace_name, toolchain_root.package, "BUILD.bazel",
toolchain_root.workspace_name,
toolchain_root.package,
"BUILD.bazel",
))
if use_absolute_paths_llvm:
llvm_dist_path_prefix = _canonical_dir_path(str(rctx.path(llvm_dist_label).dirname))
Expand All @@ -111,7 +116,9 @@ def llvm_register_toolchains():
if not use_absolute_paths_llvm:
llvm_dist_rel_path = _canonical_dir_path("../../" + llvm_dist_path_prefix)
llvm_dist_label_prefix = _make_string_label(
toolchain_root.workspace_name, toolchain_root.package, "",
toolchain_root.workspace_name,
toolchain_root.package,
"",
)

# tools can only be defined as absolute paths or in a subdirectory of
Expand Down Expand Up @@ -146,7 +153,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 c6862fd

Please sign in to comment.