Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bazeliskrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
USE_BAZEL_VERSION=5.4.1
USE_BAZEL_VERSION=8.0.0
8 changes: 6 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ First you need to set up your project to depend on this repository. We suggest t

### Registering a plugin

Assuming that we'd like to use the plugin `protoc-gen-jonathan.py` as a `protoc` plugin in `bazel`, the first thing to do is registering it as a `py_binary` with `bazel`, giving the target a name compliant with what `protoc` will accept as a name (i.e. like `/protoc-gen-[^_\.-]*/`).
Assuming that we would like to use the plugin `protoc-gen-jonathan.py` as a `protoc` plugin in `bazel`, the first thing to do is register it as a `py_binary` with `bazel`, giving the target a name compliant with what `protoc` will accept as a name (i.e., like `/protoc-gen-[^_\.-]*/`).

If the plugin uses templates, these must be registered as data dependencies.

Expand Down
4 changes: 2 additions & 2 deletions bazel/deps.bzl
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 4 additions & 0 deletions bazel/py_toolchains.bzl
Original file line number Diff line number Diff line change
@@ -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 = {}):
Expand All @@ -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()
3 changes: 1 addition & 2 deletions bazel/pypi_repos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
28 changes: 12 additions & 16 deletions bazel/repos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
3 changes: 2 additions & 1 deletion tests/cpp/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_proto_library")
load("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library")
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_python//python:defs.bzl", "py_binary")
load(":cpp_rule.bzl", "cc_generate_library")
Expand Down