Remove references to rules_proto

They are not needed after the rules are move into protobuf repo.
Except for the reference to toolchain type, which is currently in rules_proto and can be moved after the implementation is moved into protobuf repo.

PiperOrigin-RevId: 622176865
pull/16374/head
Protobuf Team Bot 2024-04-05 07:45:26 -07:00 committed by Copybara-Service
parent 090525f3f2
commit 21d75f861c
37 changed files with 101 additions and 79 deletions

View File

@ -1,9 +1,12 @@
# Bazel (https://bazel.build/) BUILD file for Protobuf.
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_lite_proto_library", "java_proto_library")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library")
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/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain")
load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS")
load(":protobuf.bzl", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library")
@ -21,7 +24,7 @@ exports_files(["LICENSE"])
#
# java_proto_library(
# name = "any_java_proto",
# deps = ["@com_google_protobuf//:any_proto"],
# deps = ["@protobuf//:any_proto"],
# )
################################################################################

View File

@ -17,7 +17,9 @@ bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_java", version = "4.0.0")
bazel_dep(name = "rules_jvm_external", version = "5.1")
bazel_dep(name = "rules_pkg", version = "0.7.0")
bazel_dep(name = "rules_proto", version = "4.0.0")
bazel_dep(name = "rules_python", version = "0.10.2")
bazel_dep(name = "platforms", version = "0.0.8")
bazel_dep(name = "zlib", version = "1.2.11")
# TODO: remove after toolchain types are moved to protobuf
bazel_dep(name = "rules_proto", version = "4.0.0")

View File

@ -5,6 +5,10 @@ workspace(name = "com_google_protobuf")
# buildifier: disable=duplicated-name
local_repository(name = "com_google_protobuf", path = ".")
# Second self-reference that makes it possible to load proto rules from @protobuf.
# buildifier: disable=duplicated-name
local_repository(name = "protobuf", path = ".")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
local_repository(

View File

@ -22,8 +22,5 @@ bzl_library(
"upb_proto_reflection_library.bzl",
],
visibility = ["//visibility:public"],
deps = [
"//bazel/private:upb_proto_library_internal_bzl",
"@rules_proto//proto:defs",
],
deps = ["//bazel/private:upb_proto_library_internal_bzl"],
)

View File

@ -0,0 +1,12 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
bzl_library(
name = "proto_common_bzl",
srcs = [
"proto_common.bzl",
],
visibility = ["//visibility:public"],
deps = [
"//bazel/private:native_bzl",
],
)

View File

@ -7,10 +7,6 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
# begin:google_only
# package(default_applicable_licenses = ["//upb:license"])
# end:google_only
licenses(["notice"])
bzl_library(
@ -23,8 +19,16 @@ bzl_library(
],
visibility = ["//bazel:__pkg__"],
deps = [
"//bazel/common:proto_common_bzl",
"@bazel_skylib//lib:paths",
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
"@rules_proto//proto:defs",
],
)
bzl_library(
name = "native_bzl",
srcs = [
"native.bzl",
],
visibility = ["//bazel:__subpackages__"],
)

View File

@ -6,7 +6,7 @@ load("//bazel/common:proto_lang_toolchain_info.bzl", "ProtoLangToolchainInfo")
def _impl(ctx):
kwargs = {}
if getattr(proto_common, "INCOMPATIBLE_PASS_TOOLCHAIN_TYPE", False):
kwargs["toolchain_type"] = "//third_party/bazel_rules/rules_proto/proto:toolchain_type"
kwargs["toolchain_type"] = "@rules_proto//proto:toolchain_type"
return [
DefaultInfo(

View File

@ -1,6 +1,6 @@
"""Implementation of the aspect that powers the upb_*_proto_library() rules."""
load("@rules_proto//proto:defs.bzl", "proto_common")
load("//bazel/common:proto_common.bzl", "proto_common")
load(":upb_proto_library_internal/cc_library_func.bzl", "cc_library_func")
load(":upb_proto_library_internal/copts.bzl", "UpbProtoLibraryCoptsInfo")

View File

@ -19,7 +19,7 @@ def proto_toolchain(*, name, proto_compiler, exec_compatible_with = []):
native.toolchain(
name = name + "_toolchain",
toolchain_type = "//third_party/bazel_rules/rules_proto/proto:toolchain_type",
toolchain_type = "@rules_proto//proto:toolchain_type",
exec_compatible_with = exec_compatible_with,
target_compatible_with = [],
toolchain = name,

View File

@ -5,11 +5,9 @@
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd
# begin:google_only
# load("@rules_cc//cc:defs.bzl", "cc_proto_library")
# end:google_only
load("@rules_python//python:defs.bzl", "py_binary")
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
load("//bazel:proto_library.bzl", "proto_library")
load(
"//bazel:upb_proto_library.bzl",
"upb_c_proto_library",
@ -19,7 +17,6 @@ load(
":build_defs.bzl",
"cc_optimizefor_proto_library",
"expand_suffixes",
"proto_library",
"tmpl_cc_binary",
)

View File

@ -29,7 +29,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
load(
"@rules_proto//proto:defs.bzl",
"@protobuf//bazel:proto_library.bzl",
"proto_library",
)

View File

@ -5,24 +5,17 @@
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
load("//bazel:proto_library.bzl", "proto_library")
# begin:google_only
# load("@rules_cc//cc:defs.bzl", _cc_proto_library = "cc_proto_library")
#
# _is_google3 = True
# end:google_only
# begin:github_only
_cc_proto_library = native.cc_proto_library
_is_google3 = False
# end:github_only
def proto_library(**kwargs):
if _is_google3:
kwargs["cc_api_version"] = 2
native.proto_library(
**kwargs
)
def tmpl_cc_binary(name, gen, args, replacements = [], **kwargs):
srcs = [name + ".cc"]
native.genrule(
@ -57,7 +50,7 @@ def cc_optimizefor_proto_library(name, srcs, outs, optimize_for):
srcs = outs,
)
_cc_proto_library(
cc_proto_library(
name = name,
deps = [":" + name + "_proto"],
)

View File

@ -1,8 +1,8 @@
# Internal Starlark definitions for Protobuf.
load("@bazel_skylib//lib:selects.bzl", "selects")
load("@rules_cc//cc:defs.bzl", starlark_cc_proto_library = "cc_proto_library")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("//bazel:cc_proto_library.bzl", starlark_cc_proto_library = "cc_proto_library")
load(":cc_proto_blacklist_test.bzl", "cc_proto_blacklist_test")
load(":compiler_config_setting.bzl", "create_compiler_config_setting")

View File

@ -1,6 +1,6 @@
# Conformance testing for Protobuf.
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library", "objc_library")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "objc_library")
load(
"@rules_pkg//pkg:mappings.bzl",
"pkg_filegroup",
@ -9,6 +9,7 @@ load(
)
load("@rules_ruby//ruby:defs.bzl", "ruby_binary")
load("//:protobuf.bzl", "internal_csharp_proto_library", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library")
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
load("//build_defs:internal_shell.bzl", "inline_sh_binary")
load("//ruby:defs.bzl", "internal_ruby_proto_library")

View File

@ -177,7 +177,7 @@ For example:
```
$ cat gen_file_lists_example/BUILD.bazel
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@protobuf//bazel:proto_library.bzl", "proto_library")
load("//pkg:build_systems.bzl", "gen_cmake_file_lists")
filegroup(

View File

@ -5,10 +5,12 @@
# example.
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_proto_library")
load("@rules_java//java:defs.bzl", "java_binary", "java_lite_proto_library", "java_proto_library")
load("@protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
load("@protobuf//bazel:java_lite_proto_library.bzl", "java_lite_proto_library")
load("@protobuf//bazel:java_proto_library.bzl", "java_proto_library")
load("@protobuf//bazel:proto_library.bzl", "proto_library")
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
# For each .proto file, a proto_library target should be defined. This target
# is not bound to any particular language. Instead, it defines the dependency
@ -19,7 +21,7 @@ load("@rules_proto//proto:defs.bzl", "proto_library")
proto_library(
name = "addressbook_proto",
srcs = ["addressbook.proto"],
deps = ["@com_google_protobuf//:timestamp_proto"],
deps = ["@protobuf//:timestamp_proto"],
)
# The cc_proto_library rule generates C++ code for a proto_library rule. It
@ -39,8 +41,8 @@ cc_binary(
srcs = ["add_person.cc"],
deps = [
":addressbook_cc_proto",
"@com_google_protobuf//:protobuf",
"@com_google_protobuf//src/google/protobuf/util:time_util",
"@protobuf",
"@protobuf//src/google/protobuf/util:time_util",
],
)
@ -49,8 +51,8 @@ cc_binary(
srcs = ["list_people.cc"],
deps = [
":addressbook_cc_proto",
"@com_google_protobuf//:protobuf",
"@com_google_protobuf//src/google/protobuf/util:time_util",
"@protobuf",
"@protobuf//src/google/protobuf/util:time_util",
],
)

View File

@ -1,5 +1,5 @@
"""Bazel module dependencies"""
bazel_dep(name = "protobuf", version = "0.0.0", dev_dependency = True, repo_name = "com_google_protobuf")
bazel_dep(name = "protobuf", version = "0.0.0", dev_dependency = True)
local_path_override(
module_name = "protobuf",
@ -10,4 +10,3 @@ bazel_dep(name = "bazel_skylib", version = "1.0.3")
bazel_dep(name = "rules_cc", version = "0.0.1")
bazel_dep(name = "rules_java", version = "7.3.0")
bazel_dep(name = "rules_pkg", version = "0.7.0")
bazel_dep(name = "rules_proto", version = "4.0.0")

View File

@ -2,14 +2,14 @@ workspace(name = "com_google_protobuf_examples")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# This com_google_protobuf repository is required for proto_library rule.
# This protobuf repository is required for proto_library rule.
# It provides the protocol compiler binary (i.e., protoc).
#
# We declare it as local_repository so we can test changes
# before they get merged. You'll want to use the following instead:
#
# http_archive(
# name = "com_google_protobuf",
# name = "protobuf",
# sha256 = "c29d8b4b79389463c546f98b15aa4391d4ed7ec459340c47bffe15db63eb9126",
# strip_prefix = "protobuf-3.21.3",
# urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.21.3.tar.gz"],
@ -20,6 +20,11 @@ local_repository(
path = "..",
)
local_repository(
name = "protobuf",
path = "..",
)
# Similar to com_google_protobuf but for Java lite. If you are building
# for Android, the lite version should be preferred because it has a much
# smaller code size.
@ -37,6 +42,6 @@ http_archive(
url = "https://github.com/bazelbuild/rules_python/releases/download/0.25.0/rules_python-0.25.0.tar.gz",
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
load("@protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()

View File

@ -1,9 +1,11 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_java//java:defs.bzl", "java_lite_proto_library", "java_proto_library")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library")
load("//:protobuf.bzl", "internal_gen_well_known_protos_java")
load("//:protobuf_version.bzl", "PROTOBUF_JAVA_VERSION")
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/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain")
load("//build_defs:java_opts.bzl", "protobuf_java_export", "protobuf_java_library", "protobuf_versioned_java_library")
load("//conformance:defs.bzl", "conformance_test")
load("//java/internal:testing.bzl", "junit_tests")

View File

@ -1,9 +1,9 @@
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
load("@rules_java//java:defs.bzl", "java_lite_proto_library")
load("@rules_jvm_external//:kt_defs.bzl", "kt_jvm_export")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("//:protobuf.bzl", "internal_gen_kt_protos")
load("//:protobuf_version.bzl", "PROTOBUF_JAVA_VERSION")
load("//bazel:java_lite_proto_library.bzl", "java_lite_proto_library")
java_lite_proto_library(
name = "example_extensible_message_java_proto_lite",

View File

@ -1,10 +1,10 @@
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_jvm_external//:kt_defs.bzl", "kt_jvm_export")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//:protobuf.bzl", "internal_gen_kt_protos")
load("//:protobuf_version.bzl", "PROTOBUF_JAVA_VERSION")
load("//bazel:java_proto_library.bzl", "java_proto_library")
load("//bazel:proto_library.bzl", "proto_library")
exports_files([
"src/test/kotlin/com/google/protobuf/Proto3Test.kt",

View File

@ -1,6 +1,6 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")
load("//bazel/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain")
load("//conformance:defs.bzl", "conformance_test")
load("//java/internal:testing.bzl", "junit_tests")

View File

@ -1,7 +1,7 @@
load("@rules_java//java:defs.bzl", "java_proto_library")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//:protobuf_version.bzl", "PROTOBUF_JAVA_VERSION")
load("//bazel:java_proto_library.bzl", "java_proto_library")
load("//bazel:proto_library.bzl", "proto_library")
load("//build_defs:java_opts.bzl", "protobuf_java_export", "protobuf_versioned_java_library")
load("//java/internal:testing.bzl", "junit_tests")

View File

@ -1,7 +1,7 @@
load("@bazel_skylib//lib:versions.bzl", "versions")
load("@rules_cc//cc:defs.bzl", "objc_library")
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
load("@rules_python//python:defs.bzl", "py_library")
load("//bazel/common:proto_info.bzl", "ProtoInfo")
def _GetPath(ctx, path):
if ctx.label.workspace_root:

View File

@ -83,6 +83,7 @@ def protobuf_deps():
sha256 = "469b7f3b580b4fcf8112f4d6d0d5a4ce8e1ad5e21fee67d8e8335d5f8b3debab",
)
# TODO: remove after toolchain types are moved to protobuf
if not native.existing_rule("rules_proto"):
http_archive(
name = "rules_proto",

View File

@ -6,7 +6,7 @@
# https://developers.google.com/open-source/licenses/bsd
load(
"@rules_cc//cc:defs.bzl",
"//bazel:cc_proto_library.bzl",
"cc_proto_library",
)
load(

View File

@ -16,12 +16,8 @@ business of vending py_proto_library(), so we keep it private to upb.
"""
load("@bazel_skylib//lib:paths.bzl", "paths")
# begin:github_only
load("@rules_proto//proto:defs.bzl", "ProtoInfo")
# end:github_only
load("@rules_python//python:py_info.bzl", "PyInfo")
load("//bazel/common:proto_info.bzl", "ProtoInfo")
# Generic support code #########################################################

View File

@ -1,8 +1,8 @@
# Protobuf Rust runtime packages.
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("//bazel/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain")
package(
default_visibility = [

View File

@ -1,4 +1,4 @@
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
load(
"//rust:defs.bzl",
"rust_cc_proto_library",

View File

@ -1,7 +1,7 @@
"""This module contains unit tests for rust_proto_library and its aspect."""
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
load("//rust:aspects.bzl", "RustProtoInfo")
load("//rust:defs.bzl", "rust_cc_proto_library", "rust_upb_proto_library")
load(":defs.bzl", "ActionsInfo", "attach_cc_aspect", "attach_upb_aspect")

View File

@ -2,9 +2,10 @@
# Protocol Buffers: C++ Runtime and common proto files
################################################################################
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library", "cc_test")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
load("//bazel:proto_library.bzl", "proto_library")
load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS")
load("//upb/cmake:build_defs.bzl", "staleness_test")

View File

@ -1,4 +1,4 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//bazel:proto_library.bzl", "proto_library")
package(
default_visibility = ["//visibility:public"],

View File

@ -2,14 +2,15 @@
# Protocol Buffers Compiler
################################################################################
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library", "cc_test")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load(
"@rules_pkg//pkg:mappings.bzl",
"pkg_attributes",
"pkg_files",
"strip_prefix",
)
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
load("//bazel:proto_library.bzl", "proto_library")
load("//build_defs:arch_tests.bzl", "aarch64_test", "x86_64_test")
load("//build_defs:cpp_opts.bzl", "COPTS")
load("test_plugin_injection.bzl", "inject_plugin_paths")

View File

@ -2,9 +2,10 @@
# Protocol Buffers Compiler - C++ code generator
################################################################################
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library", "cc_test")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
load("//bazel:proto_library.bzl", "proto_library")
load("//build_defs:cpp_opts.bzl", "COPTS")
cc_library(

View File

@ -1,7 +1,7 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")
load("//:protobuf.bzl", "internal_objc_proto_library")
load("//bazel:cc_proto_library.bzl", "cc_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")

View File

@ -1,4 +1,4 @@
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
exports_files(
glob(["*.proto"]) + ["rust_bazel_crate_mapping.txt"],

View File

@ -2,9 +2,10 @@
# Protocol Buffers C++ Utilities
################################################################################
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_proto_library", "cc_test")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("//bazel:cc_proto_library.bzl", "cc_proto_library")
load("//bazel:proto_library.bzl", "proto_library")
load("//build_defs:cpp_opts.bzl", "COPTS")
cc_library(