Skip to content

Commit d3c702d

Browse files
authored
Run buildifier to add missing loads (#581)
Run `buildifier --lint=fix -r -v .` Manually add dependencies to rules_cc where they are missing. See: bazelbuild/bazel#25755
1 parent 1935ada commit d3c702d

File tree

53 files changed

+113
-43
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+113
-43
lines changed

android/firebase-cloud-messaging/WORKSPACE

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ http_archive(
1010
sha256 = RULES_JVM_EXTERNAL_SHA,
1111
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
1212
url =
13-
"https://github.com/bazelbuild/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz" % (RULES_JVM_EXTERNAL_TAG, RULES_JVM_EXTERNAL_TAG)
13+
"https://github.com/bazelbuild/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz" % (RULES_JVM_EXTERNAL_TAG, RULES_JVM_EXTERNAL_TAG),
1414
)
1515

1616
load("@rules_jvm_external//:defs.bzl", "maven_install")
1717

1818
maven_install(
19+
aar_import_bzl_label = "@rules_android//rules:rules.bzl",
1920
artifacts = [
2021
"com.google.firebase:firebase-messaging:17.0.0",
2122
"com.android.support:appcompat-v7:26.1.0",
@@ -30,9 +31,8 @@ maven_install(
3031
"https://maven.google.com",
3132
"https://repo1.maven.org/maven2",
3233
],
33-
version_conflict_policy = "pinned",
3434
use_starlark_android_rules = True,
35-
aar_import_bzl_label = "@rules_android//rules:rules.bzl",
35+
version_conflict_policy = "pinned",
3636
)
3737

3838
load("@maven//:compat.bzl", "compat_repositories")
@@ -61,11 +61,15 @@ http_archive(
6161
)
6262

6363
load("@rules_android//:prereqs.bzl", "rules_android_prereqs")
64+
6465
rules_android_prereqs()
66+
6567
load("@rules_android//:defs.bzl", "rules_android_workspace")
68+
6669
rules_android_workspace()
6770

6871
load("@rules_android//rules:rules.bzl", "android_sdk_repository")
72+
6973
# Requires that the ANDROID_HOME environment variable is set to the Android SDK path.
7074
android_sdk_repository(
7175
name = "androidsdk",

android/jetpack-compose/WORKSPACE

-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@ kotlin_repositories(
4040
load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
4141

4242
kt_register_toolchains()
43-

android/ndk/MODULE.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ bazel_dep(name = "rules_android", version = "0.5.1")
77

88
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
99
maven.install(
10+
aar_import_bzl_label = "@rules_android//rules:rules.bzl",
1011
artifacts = [
1112
"androidx.appcompat:appcompat:1.5.1",
1213
"androidx.constraintlayout:constraintlayout:2.1.4",
@@ -25,6 +26,5 @@ maven.install(
2526
"https://repo1.maven.org/maven2",
2627
],
2728
use_starlark_android_rules = True,
28-
aar_import_bzl_label = "@rules_android//rules:rules.bzl",
2929
)
3030
use_repo(maven, "maven")

android/ndk/WORKSPACE

+4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ http_archive(
1010
)
1111

1212
load("@rules_android//:prereqs.bzl", "rules_android_prereqs")
13+
1314
rules_android_prereqs()
15+
1416
load("@rules_android//:defs.bzl", "rules_android_workspace")
17+
1518
rules_android_workspace()
1619

1720
load("@rules_android//rules:rules.bzl", "android_sdk_repository")
21+
1822
# Requires that the ANDROID_HOME environment variable is set to the Android SDK path.
1923
android_sdk_repository(
2024
name = "androidsdk",

android/robolectric-testing/MODULE.bazel

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ bazel_dep(name = "rules_jvm_external", version = "5.3")
55

66
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
77
maven.install(
8-
artifacts = [
8+
artifacts = [
99
"org.robolectric:robolectric:4.9",
1010
"junit:junit:4.13.2",
1111
"com.google.truth:truth:1.1.3",
@@ -19,5 +19,4 @@ maven.install(
1919
"https://repo1.maven.org/maven2",
2020
],
2121
)
22-
2322
use_repo(maven, "maven")

bzlmod/01-depend_on_bazel_module/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
2+
13
cc_binary(
24
name = "main",
35
srcs = ["main.cc"],

bzlmod/01-depend_on_bazel_module/MODULE.bazel

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ module(
33
version = "0.0.1",
44
)
55

6+
bazel_dep(name = "rules_cc", version = "0.0.17")
7+
68
# 1. The metadata of glog is fetched from the BCR, including its dependencies (gflags).
79
# 2. The `repo_name` attribute allows users to reference this dependency via the `com_github_google_glog` repo name.
810
bazel_dep(name = "glog", version = "0.5.0", repo_name = "com_github_google_glog")

bzlmod/01-depend_on_bazel_module/WORKSPACE

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
22

3+
http_archive(
4+
name = "rules_cc",
5+
sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
6+
strip_prefix = "rules_cc-0.0.17",
7+
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"],
8+
)
9+
310
http_archive(
411
name = "com_github_google_glog",
512
sha256 = "eede71f28371bf39aa69b45de23b329d37214016e2055269b3b5e7cfd40b59f5",

bzlmod/02-override_bazel_module/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@bazel_skylib//:version.bzl", "hello_msg")
2+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
23

34
# buildifier: disable=print
45
print(hello_msg)

bzlmod/02-override_bazel_module/MODULE.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module(
33
version = "0.0.1",
44
)
55

6+
bazel_dep(name = "rules_cc", version = "0.0.17")
67
bazel_dep(name = "glog", version = "0.5.0", repo_name = "com_github_google_glog")
78

89
# Override glog to a fork version with archive_override.

bzlmod/02-override_bazel_module/WORKSPACE

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
22
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
33

4+
http_archive(
5+
name = "rules_cc",
6+
sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
7+
strip_prefix = "rules_cc-0.0.17",
8+
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"],
9+
)
10+
411
# Use a fork version of glog with http_archive.
512
http_archive(
613
name = "com_github_google_glog",

bzlmod/02-override_bazel_module/lib_a/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
2+
13
package(default_visibility = ["//visibility:public"])
24

35
cc_library(

bzlmod/02-override_bazel_module/lib_a/MODULE.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ module(
33
version = "0.0.1",
44
)
55

6+
bazel_dep(name = "rules_cc", version = "0.0.17")
67
bazel_dep(name = "glog", version = "0.5.0", repo_name = "com_github_google_glog")

configurations/MODULE.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
"Bazel dependencies, see https://registry.bazel.build"
22

3+
bazel_dep(name = "rules_cc", version = "0.0.17")
34
bazel_dep(name = "bazel_skylib", version = "1.7.1")

configurations/cc_binary_selectable_copts/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
2+
13
# This load statement replaces the native cc_binary (which has no "set_features"
24
# attribute) with a macro that strings together the logic to make that work,
35
# then passes everything else back to the native cc_binary.

configurations/cc_binary_selectable_copts/defs.bzl

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_cc//cc:cc_binary.bzl", _cc_binary = "cc_binary")
2+
13
# buildifier: disable=module-docstring
24
def _copt_transition_impl(_, attr):
35
# settings provides read access to existing flags. But
@@ -84,7 +86,7 @@ def cc_binary(name, set_features = None, **kwargs):
8486
actual_binary = ":%s" % cc_binary_name,
8587
set_features = set_features,
8688
)
87-
native.cc_binary(
89+
_cc_binary(
8890
name = cc_binary_name,
8991
**kwargs
9092
)

configurations/cc_test/defs.bzl

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
2+
13
# buildifier: disable=module-docstring
24
# We can transition on native options using this
35
# //command_line_option:<option-name> syntax
@@ -49,4 +51,4 @@ def test_arg_cc_test(name, **kwargs):
4951

5052
# The native test is built as usual, but mark as "manual" so that blaze test :all
5153
# does not run it.
52-
native.cc_test(name = cc_test_name, tags = kwargs.pop("tags", []) + ["manual"], **kwargs)
54+
cc_test(name = cc_test_name, tags = kwargs.pop("tags", []) + ["manual"], **kwargs)

cpp-tutorial/stage1/MODULE.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bazel_dep(name = "rules_cc", version = "0.0.17")

cpp-tutorial/stage1/main/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
2+
13
cc_binary(
24
name = "hello-world",
35
srcs = ["hello-world.cc"],

cpp-tutorial/stage2/MODULE.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bazel_dep(name = "rules_cc", version = "0.0.17")

cpp-tutorial/stage2/main/BUILD

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
2+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
3+
14
cc_library(
25
name = "hello-greet",
36
srcs = ["hello-greet.cc"],

cpp-tutorial/stage3/MODULE.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bazel_dep(name = "rules_cc", version = "0.0.17")

cpp-tutorial/stage3/lib/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
2+
13
cc_library(
24
name = "hello-time",
35
srcs = ["hello-time.cc"],

cpp-tutorial/stage3/main/BUILD

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
2+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
3+
14
cc_library(
25
name = "hello-greet",
36
srcs = ["hello-greet.cc"],

frontend/react-webpack/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
load("@aspect_rules_js//js:defs.bzl", "js_test")
2-
load("@npm//:defs.bzl", "npm_link_all_packages")
32
load("@aspect_rules_webpack//webpack:defs.bzl", "webpack_bundle", "webpack_devserver")
3+
load("@npm//:defs.bzl", "npm_link_all_packages")
44

55
npm_link_all_packages()
66

macros/fancy_word_counter/defs.bzl

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ def _impl(name, visibility, srcs, out, make_it_loud, _shout_tool, **kwargs):
4545
fancy_count_words = macro(
4646
implementation = _impl,
4747
attrs = {
48-
"srcs": attr.label_list(mandatory=True),
49-
"out": attr.output(mandatory=True),
48+
"srcs": attr.label_list(mandatory = True),
49+
"out": attr.output(mandatory = True),
5050
# `configurable=False` means it can't be set to a select() by the user,
5151
# and won't be promoted to a select() when passed to the implementation
5252
# function. Morally, this should be used whenever the value is consumed
5353
# by the macro logic itself as opposed to being passed through to the
5454
# underlying targets.
55-
"make_it_loud": attr.bool(default=False, configurable=False),
56-
"_shout_tool": attr.label(default="//shout:shout.py", configurable=False),
55+
"make_it_loud": attr.bool(default = False, configurable = False),
56+
"_shout_tool": attr.label(default = "//shout:shout.py", configurable = False),
5757
},
5858
doc = """
5959
Wraps the count_words macro, adding a shouting (capitalization) feature.

macros/letter_metrics/defs.bzl

+5-6
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ def _impl(name, visibility, deps, out, _aggregate_tool):
2222
generate_letter_frequencies = macro(
2323
implementation = _impl,
2424
attrs = {
25-
"deps": attr.label_list(mandatory=True, configurable=False),
26-
"out": attr.output(mandatory=True),
27-
"_aggregate_tool": attr.label(default=":aggregate.py", configurable=False),
25+
"deps": attr.label_list(mandatory = True, configurable = False),
26+
"out": attr.output(mandatory = True),
27+
"_aggregate_tool": attr.label(default = ":aggregate.py", configurable = False),
2828
},
2929
doc = """
3030
Emits a file summarizing letter frequency data generated by the count_words
@@ -33,7 +33,6 @@ generate_letter_frequencies = macro(
3333
""",
3434
)
3535

36-
3736
def _gather_impl(name, visibility, out):
3837
suffix = "_letter_freq"
3938
deps = []
@@ -52,12 +51,12 @@ def _gather_impl(name, visibility, out):
5251
gather_all_letter_frequencies = macro(
5352
implementation = _gather_impl,
5453
attrs = {
55-
"out": attr.output(mandatory=True),
54+
"out": attr.output(mandatory = True),
5655
},
5756
finalizer = True,
5857
doc = """
5958
Convenience finalizer form of generate_letter_frequencies, that
6059
automatically infers deps by grabbing targets named *_letter_freq
6160
from the current package.
62-
"""
61+
""",
6362
)

macros/main/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
load("//word_counter:defs.bzl", "count_words")
21
load("//fancy_word_counter:defs.bzl", "fancy_count_words")
32
load("//letter_metrics:defs.bzl", "gather_all_letter_frequencies", "generate_letter_frequencies")
3+
load("//word_counter:defs.bzl", "count_words")
44

55
# A simple symbolic macro.
66
count_words(

macros/word_counter/defs.bzl

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def _impl(name, visibility, srcs, out, _count_tool):
4343
count_words = macro(
4444
implementation = _impl,
4545
attrs = {
46-
"srcs": attr.label_list(mandatory=True),
47-
"out": attr.output(mandatory=True),
46+
"srcs": attr.label_list(mandatory = True),
47+
"out": attr.output(mandatory = True),
4848
# An alternative to having _count_tool be an implicit dependency attribute
4949
# would be to just reference the label directly in the implementation
5050
# function. There, we could create a local variable
@@ -57,7 +57,7 @@ count_words = macro(
5757
#
5858
# since that would resolve relative to the package this macro is
5959
# instantiated in, rather than relative to this .bzl file.
60-
"_count_tool": attr.label(default=":counter.py", configurable=False),
60+
"_count_tool": attr.label(default = ":counter.py", configurable = False),
6161
},
6262
doc = """
6363
Emits a file containing a few of the most frequently occurring words in the

make-variables/WORKSPACE

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
http_archive(
2+
name = "rules_cc",
3+
sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
4+
strip_prefix = "rules_cc-0.0.17",
5+
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"],
6+
)

make-variables/testapp/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
12
load("//testapp:defs.bzl", "var_providing_rule")
23

34
# Targets demonstrating predefined variables available to all rules:

query-quickstart/src/main/java/com/example/customers/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_java//java:java_library.bzl", "java_library")
2+
13
java_library(
24
name = "amir",
35
srcs = ["Amir.java"],

query-quickstart/src/main/java/com/example/dishes/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_java//java:java_library.bzl", "java_library")
2+
13
java_library(
24
name = "macAndCheese",
35
srcs = ["MacAndCheese.java"],

query-quickstart/src/main/java/com/example/ingredients/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_java//java:java_library.bzl", "java_library")
2+
13
java_library(
24
name = "cheese",
35
srcs = ["Cheese.java"],

query-quickstart/src/main/java/com/example/restaurant/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_java//java:java_library.bzl", "java_library")
2+
13
java_library(
24
name = "chef",
35
srcs = [

query-quickstart/src/main/java/com/example/reviews/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_java//java:java_binary.bzl", "java_binary")
2+
13
java_binary(
24
name = "review",
35
srcs = [

rules/MODULE.bazel

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
bazel_dep(name = "bazel_skylib", version = "1.7.1")
44
bazel_dep(name = "rules_python", version = "0.25.0")
5-
bazel_dep(name = "rules_cc", version = "0.0.9")
5+
bazel_dep(name = "rules_cc", version = "0.0.17")
66
bazel_dep(name = "platforms", version = "0.0.10")
7-
7+
bazel_dep(name = "rules_shell", version = "0.4.0")

rules/actions_run/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
12
load(":execute.bzl", "concat")
23

34
concat(

rules/computed_dependencies/BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
12
load(":hash.bzl", "md5_sum")
23

34
# Run 'bazel build :hash_no_space' to compute the md5 sum of 'hello.txt'

rules/generating_code/BUILD

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
2+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
3+
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
14
load("//generating_code/gen:enum_maker.bzl", "enum_maker")
25

36
enum_maker(

rules/generating_code/gen/BUILD

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#
33
# enum_maker is a tool that turns a list of values into an enum.
44

5+
load("@rules_python//python:defs.bzl", "py_binary")
6+
57
py_binary(
68
name = "enum_maker",
79
srcs = ["enum_maker.py"],

0 commit comments

Comments
 (0)