diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 000000000..c679f56ab --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,82 @@ +module( + name = "verible", +) + +bazel_dep(name = "platforms", version = "0.0.8") +bazel_dep(name = "bazel_skylib", version = "1.5.0") + +bazel_dep(name = "rules_license", version = "0.0.8") +bazel_dep(name = "rules_proto", version = "6.0.0-rc2") +bazel_dep(name = "rules_cc", version = "0.0.9") + +# Register m4 rules and toolchain. +bazel_dep(name = "rules_m4", version = "0.2.3") +m4 = use_extension( + "@rules_m4//m4/extensions:m4_repository_ext.bzl", + "m4_repository_ext", +) +m4.repository( + name = "m4", + version = "1.4.18", + extra_copts = ["-O3"], +) +use_repo(m4, "m4") +register_toolchains("@m4//:toolchain") + +# Register bison rules and toolchain. +bazel_dep(name = "rules_bison", version = "0.2.2") +bison = use_extension( + "@rules_bison//bison/extensions:bison_repository_ext.bzl", + "bison_repository_ext", +) +bison.repository( + name = "bison", + version = "3.3.2", + extra_copts = ["-O3"], +) +use_repo(bison, "bison") +register_toolchains("@bison//:toolchain") + +# Register flex rules and toolchain. +bazel_dep(name = "rules_flex", version = "0.2.1") +flex = use_extension( + "@rules_flex//flex/extensions:flex_repository_ext.bzl", + "flex_repository_ext", +) +flex.repository( + name = "flex", + version = "2.6.4", + extra_copts = ["-O3"], +) +use_repo(flex, "flex") +register_toolchains("@flex//:toolchain") + +bazel_dep(name = "abseil-cpp", version = "20240116.1", repo_name="com_google_absl") +single_version_override( + module_name = "abseil-cpp", + patch_strip = 1, + version = "20240116.1", + patches = ["//bazel:absl.patch"], +) + +bazel_dep(name = "re2", version = "2023-09-01", repo_name="com_googlesource_code_re2") +bazel_dep(name = "googletest", version = "1.14.0.bcr.1", repo_name="com_google_googletest") + +bazel_dep(name = "protobuf", version = "25.2", repo_name="com_google_protobuf") +# This override can be removed once https://registry.bazel.build/modules/protobuf +# supports a compatible protobuf version for abseil. +archive_override( + module_name = "protobuf", + urls = [ + "https://github.com/protocolbuffers/protobuf/releases/download/v25.2/protobuf-25.2.tar.gz", + ], + strip_prefix="protobuf-25.2", + integrity = "sha256-j/URpk/EbueS0/5JpaG8rW99xQ37uloosOW5ecF/mHE=", + patches = [ + "//bazel:proto-add-module-bazel.patch", + ], + patch_strip = 1, +) + +bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name="jsonhpp") +bazel_dep(name = "zlib", version = "1.3.1") diff --git a/README.md b/README.md index 033161f8c..6fe80f661 100644 --- a/README.md +++ b/README.md @@ -183,10 +183,8 @@ the nix package manager simply run `nix-shell` to get a build environment. ```bash # Build all tools and libraries -# bazel 5/6 +# bazel 5/6/7 bazel build -c opt //... -# bazel 7 -bazel build --noenable_bzlmod -c opt //... ``` You can access the generated artifacts under `bazel-bin/`. For instance the diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod new file mode 100644 index 000000000..61d94c7ac --- /dev/null +++ b/WORKSPACE.bzlmod @@ -0,0 +1,41 @@ +workspace(name = "com_google_verible") + +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +# +# External tools needed +# + +# 'make install' equivalent rule 2023-02-21 +http_archive( + name = "com_github_google_rules_install", + # The installer uses an option -T that is not available on MacOS, but + # it is benign to leave out. + # Upstream bug https://github.com/google/bazel_rules_install/issues/31 + patch_args = ["-p1"], + patches = ["//bazel:installer.patch"], + sha256 = "aba3c1ae179beb92c1fc4502d66d7d7c648f90eb51897aa4b0ae4a76ce225eec", + strip_prefix = "bazel_rules_install-6001facc1a96bafed0e414a529b11c1819f0cdbe", + urls = ["https://github.com/google/bazel_rules_install/archive/6001facc1a96bafed0e414a529b11c1819f0cdbe.zip"], +) + +load("@com_github_google_rules_install//:deps.bzl", "install_rules_dependencies") + +install_rules_dependencies() + +load("@com_github_google_rules_install//:setup.bzl", "install_rules_setup") + +install_rules_setup() + +# 2024-02-06 +http_archive( + name = "rules_compdb", + sha256 = "70232adda61e89a4192be43b4719d35316ed7159466d0ab4f3da0ecb1fbf00b2", + strip_prefix = "bazel-compilation-database-fa872dd80742b3dccd79a711f52f286cbde33676", + urls = ["https://github.com/grailbio/bazel-compilation-database/archive/fa872dd80742b3dccd79a711f52f286cbde33676.tar.gz"], +) + +load("@rules_compdb//:deps.bzl", "rules_compdb_deps") + +rules_compdb_deps() diff --git a/bazel/proto-add-module-bazel.patch b/bazel/proto-add-module-bazel.patch new file mode 100644 index 000000000..f1542c639 --- /dev/null +++ b/bazel/proto-add-module-bazel.patch @@ -0,0 +1,519 @@ +diff --git a/BUILD.bazel b/BUILD.bazel +index 23efee4..1c7ff6e 100644 +--- a/BUILD.bazel ++++ b/BUILD.bazel +@@ -5,7 +5,7 @@ load("@rules_java//java:defs.bzl", "java_lite_proto_library", "java_proto_librar + load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") + load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library") + load("//build_defs:cpp_opts.bzl", "COPTS", "LINK_OPTS") +-load(":protobuf.bzl", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library", "internal_ruby_proto_library") ++load(":protobuf.bzl", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library") + + licenses(["notice"]) + +@@ -150,17 +150,6 @@ filegroup( + visibility = ["//visibility:public"], + ) + +-internal_ruby_proto_library( +- name = "well_known_ruby_protos", +- srcs = [":well_known_protos"], +- default_runtime = "", +- includes = ["src"], +- visibility = [ +- "//conformance:__pkg__", +- "//ruby:__subpackages__", +- ], +-) +- + ################################################################################ + # Protocol Buffers Compiler + ################################################################################ +@@ -525,33 +514,6 @@ internal_php_proto_library( + ], + ) + +-internal_ruby_proto_library( +- name = "test_messages_proto2_ruby_proto", +- testonly = 1, +- srcs = ["//src/google/protobuf:test_messages_proto2.proto"], +- includes = ["src/google/protobuf"], +- visibility = [ +- "//conformance:__pkg__", +- "//ruby:__subpackages__", +- ], +-) +- +-internal_ruby_proto_library( +- name = "test_messages_proto3_ruby_proto", +- testonly = 1, +- srcs = ["//src/google/protobuf:test_messages_proto3.proto"], +- includes = [ +- "src/google/protobuf", +- # The above must come first. +- "src", +- ], +- visibility = [ +- "//conformance:__pkg__", +- "//ruby:__subpackages__", +- ], +- deps = [":well_known_ruby_protos"], +-) +- + filegroup( + name = "bzl_srcs", + srcs = glob(["**/*.bzl"]), +diff --git a/MODULE.bazel b/MODULE.bazel +index 2d43e46..2185fc4 100644 +--- a/MODULE.bazel ++++ b/MODULE.bazel +@@ -1,2 +1,49 @@ +-# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel +-# https://github.com/protocolbuffers/protobuf/issues/14313 ++module( ++ name = "protobuf", ++ compatibility_level = 1, ++ version = "25.2", ++) ++ ++bazel_dep(name = "bazel_skylib", version = "1.0.3") ++bazel_dep(name = "rules_python", version = "0.10.2") ++bazel_dep(name = "rules_cc", version = "0.0.1") ++bazel_dep(name = "rules_proto", version = "4.0.0") ++bazel_dep(name = "rules_java", version = "4.0.0") ++bazel_dep(name = "rules_pkg", version = "0.7.0") ++bazel_dep(name = "platforms", version = "0.0.8") ++bazel_dep(name = "abseil-cpp", repo_name = "com_google_absl", version = "20240116.1") ++bazel_dep(name = "zlib", version = "1.2.11") ++bazel_dep(name = "upb", version = "0.0.0-20230516-61a97ef") ++bazel_dep(name = "rules_ruby", version = "0.6.0") ++ ++# Do not take the effort to convert utf8_range to Bzlmod as this has been moved to protobuf/third_party ++# See https://github.com/protocolbuffers/utf8_range/commit/1d1ea7e3fedf482d4a12b473c1ed25fe0f371a45 ++non_module_deps = use_extension("//:non_module_deps.bzl", "non_module_deps") ++use_repo(non_module_deps, "utf8_range") ++ ++# TODO: Add missing rules_kotlin ++ ++# Maven dependencies ++bazel_dep(name = "rules_jvm_external", version = "4.4.2") ++ ++maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") ++ ++maven.install( ++ name = "maven", ++ artifacts = [ ++ "com.google.code.findbugs:jsr305:3.0.2", ++ "com.google.code.gson:gson:2.8.9", ++ "com.google.errorprone:error_prone_annotations:2.3.2", ++ "com.google.j2objc:j2objc-annotations:1.3", ++ "com.google.guava:guava:31.1-jre", ++ "com.google.guava:guava-testlib:31.1-jre", ++ "com.google.truth:truth:1.1.2", ++ "junit:junit:4.13.2", ++ "org.mockito:mockito-core:4.3.1", ++ ], ++) ++ ++use_repo(maven, "maven") ++ ++# Dependencies needed in tests ++bazel_dep(name = "googletest", version = "1.14.0.bcr.1", repo_name="com_google_googletest") +diff --git a/conformance/BUILD.bazel b/conformance/BUILD.bazel +index c495504..26f37d4 100644 +--- a/conformance/BUILD.bazel ++++ b/conformance/BUILD.bazel +@@ -2,7 +2,8 @@ + + load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library", "objc_library") + 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", "internal_ruby_proto_library") ++load("//ruby:defs.bzl", "internal_ruby_proto_library") ++load("//:protobuf.bzl", "internal_csharp_proto_library", "internal_objc_proto_library", "internal_php_proto_library", "internal_py_proto_library") + load("//build_defs:internal_shell.bzl", "inline_sh_binary") + load( + "@rules_pkg//:mappings.bzl", +@@ -331,8 +332,7 @@ ruby_binary( + visibility = ["//ruby:__subpackages__"], + deps = [ + ":conformance_ruby_proto", +- "//:test_messages_proto2_ruby_proto", +- "//:test_messages_proto3_ruby_proto", ++ "//ruby:conformance_test_ruby_proto", + ], + ) + +diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel +new file mode 100644 +index 0000000..7e7f44f +--- /dev/null ++++ b/examples/MODULE.bazel +@@ -0,0 +1,10 @@ ++bazel_dep(name = "rules_cc", version = "0.0.1") ++bazel_dep(name = "rules_proto", version = "4.0.0") ++bazel_dep(name = "rules_java", version = "4.0.0") ++bazel_dep(name = "rules_pkg", version = "0.7.0") ++bazel_dep(name = "protobuf", repo_name = "com_google_protobuf") ++ ++local_path_override( ++ module_name = "protobuf", ++ path = "..", ++) +diff --git a/non_module_deps.bzl b/non_module_deps.bzl +new file mode 100644 +index 0000000..5cc13d7 +--- /dev/null ++++ b/non_module_deps.bzl +@@ -0,0 +1,19 @@ ++load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") ++ ++def _github_archive(repo, commit, **kwargs): ++ repo_name = repo.split("/")[-1] ++ http_archive( ++ urls = [repo + "/archive/" + commit + ".zip"], ++ strip_prefix = repo_name + "-" + commit, ++ **kwargs ++ ) ++ ++def _non_module_deps_impl(ctx): ++ _github_archive( ++ name = "utf8_range", ++ repo = "https://github.com/protocolbuffers/utf8_range", ++ commit = "de0b4a8ff9b5d4c98108bdfe723291a33c52c54f", ++ sha256 = "5da960e5e5d92394c809629a03af3c7709d2d3d0ca731dacb3a9fb4bf28f7702", ++ ) ++ ++non_module_deps = module_extension(implementation = _non_module_deps_impl) +diff --git a/p.patch b/p.patch +new file mode 100644 +index 0000000..869fbff +--- /dev/null ++++ b/p.patch +@@ -0,0 +1,69 @@ ++From 2b8f46ed079f54cecfd29115d3be0296da2738a4 Mon Sep 17 00:00:00 2001 ++From: Benjamin Peterson ++Date: Mon, 31 Jul 2023 08:04:21 -0700 ++Subject: [PATCH 7/7] bazel: Get rid of exec_tools. (#13401) ++ ++Bazel has removed this attribute in bazelbuild/bazel@c061e57a7004a88eeb2f84d094d9a88b56c146b6. ++ ++Closes #13401 ++ ++COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/13401 from benjaminp:exec_tools 9e718ff0fd11ff1fe70ed3e2536373792504c9c5 ++PiperOrigin-RevId: 552482730 ++ ++Backport of commit 1bee4578b8a812faed90432798222670f6df2a9b ++--- ++ build_defs/internal_shell.bzl | 4 ++-- ++ objectivec/BUILD.bazel | 2 +- ++ src/google/protobuf/BUILD.bazel | 2 +- ++ 3 files changed, 4 insertions(+), 4 deletions(-) ++ ++diff --git a/build_defs/internal_shell.bzl b/build_defs/internal_shell.bzl ++index 649184a51..91628a5e5 100644 ++--- a/build_defs/internal_shell.bzl +++++ b/build_defs/internal_shell.bzl ++@@ -32,7 +32,7 @@ def inline_sh_binary( ++ native.genrule( ++ name = name + "_genrule", ++ srcs = srcs, ++- exec_tools = tools, +++ tools = tools, ++ outs = [name + ".sh"], ++ cmd = "cat <<'EOF' >$(OUTS)\n#!/bin/bash -exu\n%s\nEOF\n" % cmd, ++ visibility = ["//visibility:private"], ++@@ -77,7 +77,7 @@ def inline_sh_test( ++ native.genrule( ++ name = name + "_genrule", ++ srcs = srcs, ++- exec_tools = tools, +++ tools = tools, ++ outs = [name + ".sh"], ++ cmd = "cat <<'EOF' >$(OUTS)\n#!/bin/bash -exu\n%s\nEOF\n" % cmd, ++ visibility = ["//visibility:private"], ++diff --git a/objectivec/BUILD.bazel b/objectivec/BUILD.bazel ++index 107983806..c59bf0e60 100644 ++--- a/objectivec/BUILD.bazel +++++ b/objectivec/BUILD.bazel ++@@ -42,7 +42,7 @@ genrule( ++ for wkt in _OBJC_WKT_NAMES ++ for ext in _OBJC_EXTS ++ ]), ++- exec_tools = ["//:protoc"], +++ tools = ["//:protoc"], ++ tags = ["manual"], ++ ) ++ ++diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel ++index f7f1c7b48..735610170 100644 ++--- a/src/google/protobuf/BUILD.bazel +++++ b/src/google/protobuf/BUILD.bazel ++@@ -138,7 +138,7 @@ genrule( ++ --proto_path=$$(dirname $$(dirname $$(dirname $(location any.proto)))) \ ++ $(SRCS) ++ """, ++- exec_tools = ["//:protoc"], +++ tools = ["//:protoc"], ++ visibility = ["//visibility:private"], ++ ) ++ ++-- ++2.42.1 +diff --git a/protobuf.bzl b/protobuf.bzl +index d96eeb4..3f7e001 100644 +--- a/protobuf.bzl ++++ b/protobuf.bzl +@@ -2,7 +2,6 @@ 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("@rules_ruby//ruby:defs.bzl", "ruby_library") + + def _GetPath(ctx, path): + if ctx.label.workspace_root: +@@ -490,11 +489,12 @@ def internal_objc_proto_library( + + def internal_ruby_proto_library( + name, ++ ruby_library, + srcs = [], + deps = [], + includes = ["."], +- default_runtime = "@com_google_protobuf//ruby:protobuf", +- protoc = "@com_google_protobuf//:protoc", ++ default_runtime = Label("//ruby:protobuf"), ++ protoc = Label("//:protoc"), + testonly = None, + visibility = ["//visibility:public"], + **kwargs): +@@ -506,6 +506,7 @@ def internal_ruby_proto_library( + + Args: + name: the name of the ruby_proto_library. ++ ruby_library: the ruby library rules to use. + srcs: the .proto files to compile. + deps: a list of dependency labels; must be a internal_ruby_proto_library. + includes: a string indicating the include path of the .proto files. +diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl +index d055eed..c960909 100644 +--- a/protobuf_deps.bzl ++++ b/protobuf_deps.bzl +@@ -109,14 +109,6 @@ def protobuf_deps(): + sha256 = "f9e4f6acf82449324d56669bda4bdb28b48688ad2990d8b39fa5b93ed39c9ad1", + ) + +- if not native.existing_rule("rules_ruby"): +- _github_archive( +- name = "rules_ruby", +- repo = "https://github.com/protocolbuffers/rules_ruby", +- commit = "b7f3e9756f3c45527be27bc38840d5a1ba690436", +- sha256 = "347927fd8de6132099fcdc58e8f7eab7bde4eb2fd424546b9cd4f1c6f8f8bad8", +- ) +- + if not native.existing_rule("rules_jvm_external"): + _github_archive( + name = "rules_jvm_external", +diff --git a/ruby/BUILD.bazel b/ruby/BUILD.bazel +index cc4b477..ed523c8 100755 +--- a/ruby/BUILD.bazel ++++ b/ruby/BUILD.bazel +@@ -7,7 +7,8 @@ load("@bazel_skylib//rules:common_settings.bzl", "string_flag") + load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") + load("@rules_ruby//ruby:defs.bzl", "ruby_library") + load("//build_defs:internal_shell.bzl", "inline_sh_binary") +-load("//:protobuf.bzl", "internal_ruby_proto_library") ++load("//python:internal.bzl", "internal_copy_files") ++load("//ruby:defs.bzl", "internal_ruby_proto_library") + load("//conformance:defs.bzl", "conformance_test") + load("//:protobuf_version.bzl", "PROTOBUF_RUBY_VERSION") + +@@ -15,6 +16,49 @@ load("//:protobuf_version.bzl", "PROTOBUF_RUBY_VERSION") + # Ruby Runtime + ################################################################################ + ++internal_copy_files( ++ name = "copied_wkt_proto_files", ++ srcs = [ ++ "//:well_known_type_protos", ++ "//src/google/protobuf:descriptor_proto_srcs", ++ "//src/google/protobuf/compiler:plugin.proto", ++ ], ++ strip_prefix = "src", ++) ++ ++internal_ruby_proto_library( ++ name = "well_known_ruby_protos", ++ srcs = [":copied_wkt_proto_files"], ++ default_runtime = "", ++ includes = ["."], ++ visibility = [ ++ "//conformance:__pkg__", ++ "//ruby:__subpackages__", ++ ], ++) ++ ++internal_copy_files( ++ name = "copied_conformance_test_files", ++ testonly = 1, ++ srcs = [ ++ "//src/google/protobuf:test_messages_proto2.proto", ++ "//src/google/protobuf:test_messages_proto3.proto", ++ ], ++ strip_prefix = "src", ++) ++ ++internal_ruby_proto_library( ++ name = "conformance_test_ruby_proto", ++ testonly = 1, ++ srcs = [":copied_conformance_test_files"], ++ includes = ["."], ++ visibility = [ ++ "//conformance:__pkg__", ++ "//ruby:__subpackages__", ++ ], ++ deps = [":well_known_ruby_protos"], ++) ++ + string_flag( + name = "ffi", + build_setting_default = "disabled", +@@ -105,7 +149,7 @@ genrule( + "//ruby/lib/google:copy_jar", + "//ruby/lib/google:dist_files", + "//ruby/ext/google/protobuf_c:dist_files", +- "//:well_known_ruby_protos", ++ ":well_known_ruby_protos", + "google-protobuf.gemspec", + ], + outs = ["google-protobuf-" + PROTOBUF_RUBY_VERSION + "-java.gem"], +@@ -119,7 +163,7 @@ genrule( + for utf in $(execpaths @utf8_range//:utf8_range_srcs) $(execpath @utf8_range//:LICENSE); do + mv "tmp/$$utf" "tmp/ruby/ext/google/protobuf_c/third_party/utf8_range" + done +- for wkt in $(execpaths //:well_known_ruby_protos); do ++ for wkt in $(execpaths :well_known_ruby_protos); do + mv "tmp/$$wkt" "tmp/ruby/lib/google/protobuf/" + done + mv "tmp/$(execpath //ruby/lib/google:copy_jar)" "tmp/ruby/lib/google" +@@ -141,7 +185,7 @@ genrule( + srcs = [ + "@utf8_range//:utf8_range_srcs", + "@utf8_range//:LICENSE", +- "//:well_known_ruby_protos", ++ ":well_known_ruby_protos", + "//ruby/ext/google/protobuf_c:dist_files", + "//ruby/lib/google:dist_files", + "google-protobuf.gemspec", +@@ -157,7 +201,7 @@ genrule( + for utf in $(execpaths @utf8_range//:utf8_range_srcs) $(execpath @utf8_range//:LICENSE); do + mv "tmp/$$utf" "tmp/ruby/ext/google/protobuf_c/third_party/utf8_range" + done +- for wkt in $(execpaths //:well_known_ruby_protos); do ++ for wkt in $(execpaths :well_known_ruby_protos); do + mv "tmp/$$wkt" "tmp/ruby/lib/google/protobuf/" + done + cd tmp/ruby +@@ -198,7 +242,7 @@ internal_ruby_proto_library( + visibility = [ + "//ruby:__subpackages__", + ], +- deps = ["//:well_known_ruby_protos"], ++ deps = [":well_known_ruby_protos"], + ) + + conformance_test( +diff --git a/ruby/compatibility_tests/v3.0.0/tests/BUILD.bazel b/ruby/compatibility_tests/v3.0.0/tests/BUILD.bazel +index 34a5391..697f876 100644 +--- a/ruby/compatibility_tests/v3.0.0/tests/BUILD.bazel ++++ b/ruby/compatibility_tests/v3.0.0/tests/BUILD.bazel +@@ -1,6 +1,6 @@ + load("@rules_pkg//:mappings.bzl", "pkg_files", "strip_prefix") + load("@rules_ruby//ruby:defs.bzl", "ruby_test") +-load("//:protobuf.bzl", "internal_ruby_proto_library") ++load("//ruby:defs.bzl", "internal_ruby_proto_library") + + internal_ruby_proto_library( + name = "test_ruby_protos", +diff --git a/ruby/defs.bzl b/ruby/defs.bzl +new file mode 100644 +index 0000000..7f60b47 +--- /dev/null ++++ b/ruby/defs.bzl +@@ -0,0 +1,24 @@ ++"""Wrapper around internal_ruby_proto_library to supply our rules_ruby""" ++ ++load("@rules_ruby//ruby:defs.bzl", "ruby_library") ++load("//:protobuf.bzl", _internal_ruby_proto_library = "internal_ruby_proto_library") ++ ++def internal_ruby_proto_library( ++ name, ++ **kwargs): ++ """Bazel rule to create a Ruby protobuf library from proto source files ++ ++ NOTE: the rule is only an internal workaround to generate protos. The ++ interface may change and the rule may be removed when bazel has introduced ++ the native rule. ++ ++ Args: ++ name: the name of the ruby_proto_library. ++ **kwargs: other keyword arguments that are passed to ruby_library. ++ ++ """ ++ _internal_ruby_proto_library( ++ name, ++ ruby_library, ++ **kwargs ++ ) +diff --git a/ruby/lib/google/BUILD.bazel b/ruby/lib/google/BUILD.bazel +index 18f1c18..8af2fa8 100644 +--- a/ruby/lib/google/BUILD.bazel ++++ b/ruby/lib/google/BUILD.bazel +@@ -76,9 +76,12 @@ ruby_library( + "//ruby:linux_ffi_enabled": ["libprotobuf_c_ffi.so"], + "//conditions:default": [], + }), +- includes = ["ruby/lib"], ++ includes = [ ++ "ruby", ++ "ruby/lib", ++ ], + visibility = ["//ruby:__pkg__"], +- deps = ["//:well_known_ruby_protos"] + select({ ++ deps = ["//ruby:well_known_ruby_protos"] + select({ + "//ruby:ffi_enabled": [ + "@protobuf_bundle//:ffi", + "@protobuf_bundle//:ffi-compiler", +diff --git a/src/google/protobuf/BUILD.bazel b/src/google/protobuf/BUILD.bazel +index 8961ca6..88e545c 100644 +--- a/src/google/protobuf/BUILD.bazel ++++ b/src/google/protobuf/BUILD.bazel +@@ -777,6 +777,7 @@ exports_files( + visibility = [ + "//:__pkg__", + "//python:__pkg__", ++ "//ruby:__pkg__", + ], + ) + +diff --git a/src/google/protobuf/io/coded_stream.cc b/src/google/protobuf/io/coded_stream.cc +index fdfc2d0..665f831 100644 +--- a/src/google/protobuf/io/coded_stream.cc ++++ b/src/google/protobuf/io/coded_stream.cc +@@ -522,7 +522,7 @@ int CodedInputStream::ReadVarintSizeAsIntFallback() { + // Optimization: We're also safe if the buffer is non-empty and it ends + // with a byte that would terminate a varint. + (buffer_end_ > buffer_ && !(buffer_end_[-1] & 0x80))) { +- uint64_t temp; ++ uint64_t temp = 0; + ::std::pair p = ReadVarint64FromArray(buffer_, &temp); + if (!p.first || temp > static_cast(INT_MAX)) return -1; + buffer_ = p.second; +@@ -632,7 +632,7 @@ std::pair CodedInputStream::ReadVarint64Fallback() { + // Optimization: We're also safe if the buffer is non-empty and it ends + // with a byte that would terminate a varint. + (buffer_end_ > buffer_ && !(buffer_end_[-1] & 0x80))) { +- uint64_t temp; ++ uint64_t temp = 0; + ::std::pair p = ReadVarint64FromArray(buffer_, &temp); + if (!p.first) { + return std::make_pair(0, false); diff --git a/shell.nix b/shell.nix index 06958459d..f6ae7b42b 100644 --- a/shell.nix +++ b/shell.nix @@ -12,7 +12,7 @@ verible_used_stdenv.mkDerivation { name = "verible-build-environment"; buildInputs = with pkgs; [ - bazel_5 + bazel_6 jdk11 git