diff --git a/.bazeliskrc b/.bazeliskrc index bd4a535..e0d5ba7 100644 --- a/.bazeliskrc +++ b/.bazeliskrc @@ -1 +1 @@ -USE_BAZEL_VERSION=5.4.1 +USE_BAZEL_VERSION=8.0.0 diff --git a/.bazelrc b/.bazelrc index 7a9655a..db01cf8 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,8 +1,12 @@ -# Use a remote build cache that's world-readable. Don't write unless told otherwise. +# TODO: migrate to Bazel modules +common --enable_workspace +common --enable_bzlmod=false + +build --verbose_failures +# Use a remote build cache that's world-readable. Don't write unless told otherwise. build --remote_cache=https://storage.googleapis.com/reboot-dev-bazel-remote-cache-reboot-us build --remote_upload_local_results=false # Print full test logs for failed tests. - test --test_output=errors diff --git a/bazel/deps.bzl b/bazel/deps.bzl index 510ca54..87e5248 100644 --- a/bazel/deps.bzl +++ b/bazel/deps.bzl @@ -1,9 +1,9 @@ """Dependency specific initialization.""" -load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") load("@pyprotoc_plugin_pypi//:requirements.bzl", pypi_deps = "install_deps") +load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") def deps(repo_mapping = {}): - protobuf_deps() + rules_proto_dependencies() pypi_deps(repo_mapping = repo_mapping) diff --git a/bazel/py_toolchains.bzl b/bazel/py_toolchains.bzl index e300d5f..708f16f 100644 --- a/bazel/py_toolchains.bzl +++ b/bazel/py_toolchains.bzl @@ -1,5 +1,6 @@ """Defines a local python toolchain for use in rules_python.""" +load("@rules_proto//proto:toolchains.bzl", "rules_proto_toolchains") load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains") def py_toolchains(repo_mapping = {}): @@ -10,3 +11,6 @@ def py_toolchains(repo_mapping = {}): python_version = "3.10.12", repo_mapping = repo_mapping, ) + + # TODO: not really a Python toolchain? + rules_proto_toolchains() diff --git a/bazel/pypi_repos.bzl b/bazel/pypi_repos.bzl index 0647888..ebf8407 100644 --- a/bazel/pypi_repos.bzl +++ b/bazel/pypi_repos.bzl @@ -3,12 +3,11 @@ should be installed later in WORKSPACE file to be accessible. `pip_parse` takes a `requirements_lock` file as input, which is generated by the `bazel run :requirements.update` command.""" -load("@python3_10_12//:defs.bzl", "interpreter") load("@rules_python//python:pip.bzl", "pip_parse") def pypi_repos(): pip_parse( name = "pyprotoc_plugin_pypi", - python_interpreter_target = interpreter, + python_interpreter_target = "@python3_10_12_host//:python", requirements_lock = "@com_github_reboot_dev_pyprotoc_plugin//:requirements_lock.txt", ) diff --git a/bazel/repos.bzl b/bazel/repos.bzl index a5cf218..135f07f 100644 --- a/bazel/repos.bzl +++ b/bazel/repos.bzl @@ -16,30 +16,26 @@ def repos(external = True, repo_mapping = {}): """Adds repositories/archives needed by pyprotoc-plugin Args: - external: whether or not we're invoking this function as though - though we're an external dependency + external: whether we are invoking this function as though we are + an external dependency repo_mapping: passed through to all other functions that expect/use repo_mapping, e.g., 'git_repository' """ http_archive( name = "rules_python", - sha256 = "9acc0944c94adb23fba1c9988b48768b1bacc6583b52a2586895c5b7491e2e31", - strip_prefix = "rules_python-0.27.0", - url = "https://github.com/bazelbuild/rules_python/releases/download/0.27.0/rules_python-0.27.0.tar.gz", + sha256 = "4f7e2aa1eb9aa722d96498f5ef514f426c1f55161c3c9ae628c857a7128ceb07", + strip_prefix = "rules_python-1.0.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/1.0.0/rules_python-1.0.0.tar.gz", repo_mapping = repo_mapping, ) - if "com_google_protobuf" not in native.existing_rules(): - git_repository( - name = "com_google_protobuf", - remote = "https://github.com/protocolbuffers/protobuf", - # Release v3.19.4. - # TODO(codingcanuck): Update to a newer release after - # https://github.com/protocolbuffers/protobuf/issues/9688 is fixed. - commit = "22d0e265de7d2b3d2e9a00d071313502e7d4cccf", - shallow_since = "1643340956 -0800", - repo_mapping = repo_mapping, - ) + http_archive( + name = "rules_proto", + sha256 = "14a225870ab4e91869652cfd69ef2028277fc1dc4910d65d353b62d6e0ae21f4", + strip_prefix = "rules_proto-7.1.0", + url = "https://github.com/bazelbuild/rules_proto/releases/download/7.1.0/rules_proto-7.1.0.tar.gz", + repo_mapping = repo_mapping, + ) if external and "com_github_reboot_dev_pyprotoc_plugin" not in native.existing_rules(): git_repository( diff --git a/rules.bzl b/rules.bzl index b8be2b9..8104d2a 100644 --- a/rules.bzl +++ b/rules.bzl @@ -107,7 +107,7 @@ def _protoc_plugin_rule_implementation(context): else: fail( "Handling this type of (generated?) .proto file " + - "was not forseen and is not implemented. " + + "was not foreseen and is not implemented. " + "Please create an issue at " + "https://github.com/reboot-dev/pyprotoc-plugin/issues " + "with your proto file and we will have a look!", diff --git a/tests/cpp/BUILD.bazel b/tests/cpp/BUILD.bazel index 8a20e3f..d6ff6ea 100644 --- a/tests/cpp/BUILD.bazel +++ b/tests/cpp/BUILD.bazel @@ -1,5 +1,6 @@ -load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library") load("@rules_proto//proto:defs.bzl", "proto_library") +load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library") +load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library") load("@rules_python//python:defs.bzl", "py_binary") load(":cpp_rule.bzl", "cc_generate_library")