Skip to content

Commit

Permalink
Run buildifier
Browse files Browse the repository at this point in the history
Adds missing loads for Java rules.
Remove unused loads.
Some other minor fixes.

PiperOrigin-RevId: 728701378
  • Loading branch information
protobuf-github-bot authored and comius committed Feb 20, 2025
1 parent 4f4ac6a commit bf712cc
Show file tree
Hide file tree
Showing 25 changed files with 29 additions and 26 deletions.
1 change: 0 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("@rules_license//rules:license.bzl", "license")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
load("//bazel:java_lite_proto_library.bzl", "java_lite_proto_library")
load("//bazel:java_proto_library.bzl", "java_proto_library")
Expand Down
2 changes: 1 addition & 1 deletion bazel/java_lite_proto_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ def java_lite_proto_library(**kwattrs):
if not hasattr(native, "java_lite_proto_library"):
_java_lite_proto_library(**kwattrs)
else:
native.java_lite_proto_library(**kwattrs)
native.java_lite_proto_library(**kwattrs) # buildifier: disable=native-java-lite-proto
2 changes: 1 addition & 1 deletion bazel/java_proto_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ def java_proto_library(**kwattrs):
if not hasattr(native, "java_proto_library"):
_java_proto_library(**kwattrs)
else:
native.java_proto_library(**kwattrs)
native.java_proto_library(**kwattrs) # buildifier: disable=native-java-proto
1 change: 0 additions & 1 deletion bazel/private/toolchains/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("//bazel/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain")
load("//bazel/toolchains:proto_toolchain.bzl", "proto_toolchain")

# Keep this file as small as possible and free of any unnecessary loads
Expand Down
2 changes: 1 addition & 1 deletion bazel/proto_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ def proto_library(**kwattrs):
_proto_library(**kwattrs)
else:
# On older Bazel versions keep using native rules, so that mismatch in ProtoInfo doesn't happen
native.proto_library(**kwattrs)
native.proto_library(**kwattrs) # buildifier: disable=native-proto
2 changes: 1 addition & 1 deletion bazel/toolchains/proto_lang_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def proto_lang_toolchain(*, name, toolchain_type = None, exec_compatible_with =
_proto_lang_toolchain_rule(name = name, **attrs)
else:
# On older Bazel versions keep using native rules, so that mismatch in ProtoInfo doesn't happen
native.proto_lang_toolchain(name = name, **attrs)
native.proto_lang_toolchain(name = name, **attrs) # buildifier: disable=native-proto-lang-toolchain

if toolchain_type:
native.toolchain(
Expand Down
1 change: 1 addition & 0 deletions compatibility/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_buf//buf:defs.bzl", "buf_breaking_test")
load("@rules_java//java:java_library.bzl", "java_library")

# Simple build tests for compatibility of gencode from previous major versions
# with the current runtime.
Expand Down
1 change: 1 addition & 0 deletions conformance/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# Conformance testing for Protobuf.

load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "objc_library")
load("@rules_java//java:java_binary.bzl", "java_binary")
load(
"@rules_pkg//pkg:mappings.bzl",
"pkg_filegroup",
Expand Down
1 change: 0 additions & 1 deletion conformance/test_protos/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
load("@rules_cc//cc:defs.bzl", "objc_library")
load("//:protobuf.bzl", "internal_csharp_proto_library", "internal_objc_proto_library", "internal_py_proto_library")
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
load("//bazel:java_lite_proto_library.bzl", "java_lite_proto_library")
Expand Down
1 change: 0 additions & 1 deletion editions/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ load("//bazel:cc_proto_library.bzl", "cc_proto_library")
load("//bazel:java_lite_proto_library.bzl", "java_lite_proto_library")
load("//bazel:java_proto_library.bzl", "java_proto_library")
load("//bazel:proto_library.bzl", "proto_library")
load("//bazel:py_proto_library.bzl", "py_proto_library")
load("//bazel:upb_proto_library.bzl", "upb_c_proto_library", "upb_proto_reflection_library")
load(":defaults.bzl", "compile_edition_defaults", "embed_edition_defaults")

Expand Down
2 changes: 2 additions & 0 deletions examples/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
# example.

load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
load("@com_google_protobuf//bazel:java_lite_proto_library.bzl", "java_lite_proto_library")
load("@com_google_protobuf//bazel:java_proto_library.bzl", "java_proto_library")
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library")
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_java//java:java_binary.bzl", "java_binary")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_python//python:py_binary.bzl", "py_binary")

Expand Down
1 change: 1 addition & 0 deletions java/internal/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_java//java:java_test.bzl", "java_test")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")

package(default_visibility = ["//java:__subpackages__"])
Expand Down
1 change: 1 addition & 0 deletions java/kotlin-lite/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_java//java:java_test.bzl", "java_test")
load("@rules_jvm_external//:kt_defs.bzl", "kt_jvm_export")
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
Expand Down
1 change: 1 addition & 0 deletions java/kotlin/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_java//java:java_test.bzl", "java_test")
load("@rules_jvm_external//:kt_defs.bzl", "kt_jvm_export")
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
Expand Down
2 changes: 1 addition & 1 deletion java/lite/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("//bazel/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain")
load("//conformance:defs.bzl", "conformance_test")
load("//java/internal:testing.bzl", "junit_tests")
Expand Down
1 change: 1 addition & 0 deletions java/util/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_java//java:java_library.bzl", "java_library")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("//:protobuf_version.bzl", "PROTOBUF_JAVA_VERSION")
load("//bazel:java_proto_library.bzl", "java_proto_library")
Expand Down
1 change: 1 addition & 0 deletions lua/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd

load("//bazel:proto_library.bzl", "proto_library")
load(
"//lua:lua_proto_library.bzl",
"lua_proto_library",
Expand Down
14 changes: 7 additions & 7 deletions protobuf.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,21 @@ def _proto_gen_impl(ctx):
if source_dir:
has_sources = any([src.is_source for src in srcs])
if has_sources:
import_flags += ["-I" + source_dir]
import_flags.append("-I" + source_dir)
else:
import_flags += ["-I."]
import_flags.append("-I.")

has_generated = any([not src.is_source for src in srcs])
if has_generated:
import_flags += ["-I" + gen_dir]
import_flags.append("-I" + gen_dir)

if ctx.attr.includes:
for include in ctx.attr.includes:
if include == ".":
# This is effectively source_dir, which has already been handled,
# and may be generated incorrectly here.
continue
import_flags += ["-I" + _GetPath(ctx, include)]
import_flags.append("-I" + _GetPath(ctx, include))

import_flags = depset(direct = import_flags)

Expand Down Expand Up @@ -160,7 +160,7 @@ def _proto_gen_impl(ctx):
outs.extend(_RubyOuts([src.basename]))

# Otherwise, rely on user-supplied outs.
args += [("--%s_out=" + path_tpl) % (lang, gen_dir)]
args.append(("--%s_out=" + path_tpl) % (lang, gen_dir))

if ctx.attr.outs:
outs.extend(ctx.attr.outs)
Expand All @@ -181,8 +181,8 @@ def _proto_gen_impl(ctx):

if ctx.attr.plugin_options:
outdir = ",".join(ctx.attr.plugin_options) + ":" + outdir
args += [("--plugin=protoc-gen-%s=" + path_tpl) % (lang, plugin.path)]
args += ["--%s_out=%s" % (lang, outdir)]
args.append(("--plugin=protoc-gen-%s=" + path_tpl) % (lang, plugin.path))
args.append("--%s_out=%s" % (lang, outdir))
tools.append(plugin)

if not in_gen_dir:
Expand Down
1 change: 0 additions & 1 deletion python/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

load("@bazel_skylib//lib:selects.bzl", "selects")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
load("//python:build_targets.bzl", "build_targets")
load("//python:py_extension.bzl", "py_extension")
load("//upb/bazel:build_defs.bzl", "UPB_DEFAULT_COPTS")
Expand Down
1 change: 1 addition & 0 deletions ruby/lib/google/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@rules_java//java:java_binary.bzl", "java_binary")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_ruby//ruby:defs.bzl", "ruby_library")

Expand Down
1 change: 0 additions & 1 deletion rust/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("//bazel/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain")
load("//rust:dist.bzl", "pkg_cross_compiled_binaries")

licenses(["notice"])

Expand Down
6 changes: 6 additions & 0 deletions rust/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ def _rust_proto_library_impl(ctx):
dep = deps[0]
rust_proto_info = dep[RustProtoInfo]

proto_common.check_collocated(
ctx.label,
dep[ProtoInfo],
ctx.attr._proto_lang_toolchain[proto_common.ProtoLangToolchainInfo],
)

if len(rust_proto_info.dep_variant_infos) != 1:
fail(
"{}: rust_proto_library does not support src-less proto_library targets."
Expand Down
1 change: 1 addition & 0 deletions rust/test/cpp/interop/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

load("@rules_rust//rust:defs.bzl", "rust_test")
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
load("//bazel:proto_library.bzl", "proto_library")
load(
"//rust:defs.bzl",
"rust_cc_proto_library",
Expand Down
4 changes: 0 additions & 4 deletions upb/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
load("@bazel_skylib//lib:selects.bzl", "selects")
load("@rules_python//python:defs.bzl", "py_binary")

package(default_applicable_licenses = ["//:license"])

licenses(["notice"])

py_binary(
name = "amalgamate",
srcs = ["amalgamate.py"],
Expand Down
4 changes: 0 additions & 4 deletions upb/cmake/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
# https://developers.google.com/open-source/licenses/bsd

load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load(
"//upb/bazel:build_defs.bzl",
"make_shell_script",
)
load(
":build_defs.bzl",
"staleness_test",
Expand Down

0 comments on commit bf712cc

Please sign in to comment.