Skip to content

Commit

Permalink
chore: run buildifier
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Jun 13, 2023
1 parent 7b382c9 commit 47dd4ce
Show file tree
Hide file tree
Showing 24 changed files with 52 additions and 74 deletions.
10 changes: 5 additions & 5 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@

module(
name = "aspect_bazel_lib",
compatibility_level = 1,
version = "0.0.0",
compatibility_level = 1,
)

# Lower-bound versions of our dependencies
bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "platforms", version = "0.0.4")

# 0.5.4 is the first version with bzlmod support
bazel_dep(name = "stardoc", repo_name = "io_bazel_stardoc", version = "0.5.4")
bazel_dep(name = "stardoc", version = "0.5.4", repo_name = "io_bazel_stardoc")

ext = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "ext")

use_repo(ext, "copy_directory_toolchains", "copy_to_directory_toolchains", "jq_toolchains", "yq_toolchains", "coreutils_toolchains", "expand_template_toolchains")
use_repo(ext, "copy_directory_toolchains", "copy_to_directory_toolchains", "coreutils_toolchains", "expand_template_toolchains", "jq_toolchains", "yq_toolchains")

register_toolchains(
"@copy_directory_toolchains//:all",
"@copy_to_directory_toolchains//:all",
"@jq_toolchains//:all",
"@yq_toolchains//:all",
"@coreutils_toolchains//:all",
"@expand_template_toolchains//:all"
"@expand_template_toolchains//:all",
)

# Development-only dependencies
Expand Down
6 changes: 1 addition & 5 deletions docs/strings.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions e2e/bzlmod_write_source_files_external/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
module(
name = "bzlmod_write_source_files_external",
compatibility_level = 1,
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "aspect_bazel_lib", version = "0.0.0")

local_path_override(
module_name = "aspect_bazel_lib",
path = "../..",
)

test_ext = use_extension("//:test_extension.bzl", "test_ext")

use_repo(test_ext, "test")

6 changes: 1 addition & 5 deletions e2e/copy_to_directory/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
module(
name = "copy_to_directory",
compatibility_level = 1,
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "bazel_skylib", version = "1.1.1")

bazel_dep(name = "aspect_bazel_lib", version = "0.0.0")

local_path_override(
module_name = "aspect_bazel_lib",
path = "../..",
)

ext = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "ext")

ext.host()

use_repo(ext, "aspect_bazel_lib_host")
10 changes: 4 additions & 6 deletions e2e/coreutils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@ genrule(

hashes(
name = "hash",
src = "test.bin"
src = "test.bin",
)

filegroup(
name = "md5",
srcs = [":hash"],
output_group = "md5",
srcs = [":hash"]
)

filegroup(
name = "sha1",
srcs = [":hash"],
output_group = "sha1",
srcs = [":hash"]
)


# This tests that the "in" file to write_source_files can be a
# label to an external repository target when bzlmod is enabled.
write_source_files(
Expand All @@ -34,7 +33,6 @@ write_source_files(
"ls.txt.expected": ":ls.txt",
"sha256.txt": ":hash",
"sha1.txt": ":sha1",
"md5.txt": ":md5"
"md5.txt": ":md5",
},
)

5 changes: 2 additions & 3 deletions e2e/coreutils/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
module(
name = "coreutils",
compatibility_level = 1,
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "aspect_bazel_lib", version = "0.0.0")

local_path_override(
module_name = "aspect_bazel_lib",
path = "../..",
)

ext = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "ext")
use_repo(ext, "coreutils_toolchains")
use_repo(ext, "coreutils_toolchains")
2 changes: 1 addition & 1 deletion e2e/smoke/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ diff_test(
"@aspect_bazel_lib//lib:bzlmod": "a_stamp_expected_bzlmod",
"//conditions:default": "a_stamp_expected",
}),
)
)
4 changes: 1 addition & 3 deletions e2e/smoke/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
module(
name = "smoke",
compatibility_level = 1,
version = "0.0.0",
compatibility_level = 1,
)

bazel_dep(name = "bazel_skylib", version = "1.1.1")

bazel_dep(name = "aspect_bazel_lib", version = "0.0.0")

local_path_override(
module_name = "aspect_bazel_lib",
path = "../..",
Expand Down
7 changes: 3 additions & 4 deletions lib/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,19 @@ bzl_library(
name = "expand_make_vars",
srcs = ["expand_make_vars.bzl"],
deps = [
":expand_template",
"//lib/private/docs:expand_locations",
"//lib/private/docs:expand_variables",
":expand_template",
],
)


bzl_library(
name = "expand_template",
srcs = ["expand_template.bzl"],
deps = [
"//lib/private/docs:expand_locations",
"//lib/private/docs:expand_variables",
"//lib/private/docs:expand_template",
"//lib/private/docs:expand_variables",
],
)

Expand Down Expand Up @@ -273,4 +272,4 @@ bzl_library(
name = "strings",
srcs = ["strings.bzl"],
deps = ["//lib/private/docs:strings"],
)
)
1 change: 1 addition & 0 deletions lib/expand_make_vars.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ load(":expand_template.bzl", _expand_template = "expand_template")

expand_locations = _expand_locations
expand_variables = _expand_variables

# TODO: 2.0 remove re-export from this file.
expand_template = _expand_template
2 changes: 1 addition & 1 deletion lib/expand_template.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

load("//lib/private:expand_template.bzl", _expand_template = "expand_template")

expand_template = _expand_template
expand_template = _expand_template
6 changes: 3 additions & 3 deletions lib/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ load(
"@aspect_bazel_lib//lib:repositories.bzl",
"register_copy_directory_toolchains",
"register_copy_to_directory_toolchains",
"register_jq_toolchains",
"register_yq_toolchains",
"register_coreutils_toolchains",
"register_expand_template_toolchains",
"register_jq_toolchains",
"register_yq_toolchains",
)
load("//lib/private:host_repo.bzl", "host_repo")

Expand All @@ -18,7 +18,7 @@ def _toolchain_extension(mctx):
register_yq_toolchains(register = False)
register_coreutils_toolchains(register = False)
register_expand_template_toolchains(register = False)

create_host_repo = False
for module in mctx.modules:
if len(module.tags.host) > 0:
Expand Down
4 changes: 2 additions & 2 deletions lib/private/base64.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Implementation based on https://gist.github.com/trondhumbor/ce57c0c2816bb45a8fbb
the subset of python available in Starlark.
"""

load(":strings.bzl", "ord", "chr")
load(":strings.bzl", "chr", "ord")

def decode(data):
"""Decode a Base64 encoded string.
Expand Down Expand Up @@ -339,4 +339,4 @@ def _int_to_binary(i, digits = 8):
fail("expected a int between 0 and 255 (inclusive)")
if digits < 1 or digits > 8:
fail("expected digits to be between 1 and 8 (inclusive)")
return INT_TO_BINARY[i][8 - digits:]
return INT_TO_BINARY[i][8 - digits:]
8 changes: 4 additions & 4 deletions lib/private/docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ bzl_library(
srcs = ["//lib/private:expand_template.bzl"],
deps = [
":expand_locations",
"//lib:stamping",
"@bazel_skylib//lib:dicts",
"//lib:stamping"
],
)

Expand Down Expand Up @@ -229,8 +229,8 @@ bzl_library(
name = "base64",
srcs = ["//lib/private:base64.bzl"],
deps = [
":strings"
]
":strings",
],
)

bzl_library(
Expand All @@ -251,7 +251,7 @@ bzl_library(
bzl_library(
name = "expand_template_toolchain",
srcs = ["//lib/private:expand_template_toolchain.bzl"],
deps = ["//lib:stamping"]
deps = ["//lib:stamping"],
)

bzl_library(
Expand Down
10 changes: 5 additions & 5 deletions lib/private/expand_template.bzl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"expand_template rule"

load("@bazel_skylib//lib:dicts.bzl", "dicts")
load(":expand_locations.bzl", _expand_locations = "expand_locations")
load(":expand_variables.bzl", _expand_variables = "expand_variables")
load("//lib:stamping.bzl", "STAMP_ATTRS", "maybe_stamp")


def _expand_substitutions(ctx, substitutions):
result = {}
for k, v in substitutions.items():
Expand All @@ -23,7 +23,7 @@ def _expand_template_impl(ctx):
substitutions_out = ctx.actions.declare_file("{}_substitutions.json".format(ctx.label.name))
ctx.actions.write(
output = substitutions_out,
content = json.encode(substitutions)
content = json.encode(substitutions),
)

inputs = [
Expand Down Expand Up @@ -90,15 +90,15 @@ such as `$(BINDIR)`, `$(TARGET_CPU)`, and `$(COMPILATION_MODE)` as documented in
There are overlayed on top of substitutions when stamping is enabled
for the target.
Substitutions can contain $(execpath :target) and $(rootpath :target)
expansions, $(MAKEVAR) expansions and {{STAMP_VAR}} expansions when
stamping is enabled for the target.
""",
),
"substitutions": attr.string_dict(
doc = """Mapping of strings to substitutions.
Substitutions can contain $(execpath :target) and $(rootpath :target)
expansions, $(MAKEVAR) expansions and {{STAMP_VAR}} expansions when
stamping is enabled for the target.
Expand All @@ -109,7 +109,7 @@ such as `$(BINDIR)`, `$(TARGET_CPU)`, and `$(COMPILATION_MODE)` as documented in
mandatory = True,
allow_single_file = True,
),
}, **STAMP_ATTRS),
}, **STAMP_ATTRS),
)

expand_template = rule(
Expand Down
9 changes: 4 additions & 5 deletions lib/private/strings.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def ord(c):
Args:
c: character whose codepoint to be returned.
Returns:
codepoint of `c` argument.
"""
Expand Down Expand Up @@ -561,11 +561,11 @@ def _to_char(n):
def hex(number):
"""Format integer to hexdecimal representation
Args:
Args:
number: number to format
Returns:
hexdecimal representation of the number argument
hexdecimal representation of the number argument
"""

hex_string = ""
Expand All @@ -578,9 +578,8 @@ def hex(number):
r //= 16
else:
break

if not hex_string:
hex_string = "0"

return "{}0x{}".format("-" if is_signed else "", hex_string)

1 change: 0 additions & 1 deletion lib/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ def register_copy_to_directory_toolchains(name = "copy_to_directory", register =
user_repository_name = name,
)


def register_expand_template_toolchains(name = "expand_template", register = True):
"""Registers expand_template toolchain and repositories
Expand Down
4 changes: 1 addition & 3 deletions lib/strings.bzl
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@


"Utilities for strings"

load("//lib/private:strings.bzl", _chr = "chr", _ord = "ord", _hex = "hex")
load("//lib/private:strings.bzl", _chr = "chr", _hex = "hex", _ord = "ord")

chr = _chr
ord = _ord
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/copy_to_directory/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ copy_to_directory(
":d",
":e/e1",
":e/e2",
"//lib/tests/copy_to_directory/f/f2",
"//lib/tests/copy_to_directory/f/f2:f1",
"//lib/tests/copy_to_directory/f/f2:f2",
"@external_test_repo//:test_c",
"@external_test_repo//:test_d",
] + make_directory_paths(
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/expand_template/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ assert_contains(
name = "default_info_test",
actual = ":a_tmpl_stamp",
expected = "WORKSPACE:",
)
)
Loading

0 comments on commit 47dd4ce

Please sign in to comment.