Skip to content

Commit 47d2de4

Browse files
committed
ok, builds with bazel
1 parent 56c5505 commit 47d2de4

File tree

3 files changed

+52
-23
lines changed

3 files changed

+52
-23
lines changed

BUILD

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,42 @@
1-
load("@rules_proto//proto:defs.bzl", "proto_library")
2-
load("@io_bazel_rules_rust//proto:proto.bzl", "rust_proto_library")
3-
load("@io_bazel_rules_rust//proto:toolchain.bzl", "PROTO_COMPILE_DEPS", "rust_proto_toolchain")
1+
# load("@rules_proto//proto:defs.bzl", "proto_library")
2+
# load("@io_bazel_rules_rust//proto:proto.bzl", "rust_proto_library")
3+
# load("@io_bazel_rules_rust//proto:toolchain.bzl", "PROTO_COMPILE_DEPS", "rust_proto_toolchain")
4+
load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library", "rust_binary")
45

5-
rust_proto_toolchain(name = "default-proto-toolchain-impl")
6-
7-
toolchain(
8-
name = "default-proto-toolchain",
9-
toolchain = ":default-proto-toolchain-impl",
10-
toolchain_type = "@io_bazel_rules_rust//proto:toolchain",
6+
rust_library(
7+
name = "rustc_worker",
8+
srcs = [
9+
"src/lib.rs",
10+
"src/worker_protocol.rs",
11+
],
12+
deps = [
13+
"@io_bazel_rules_rust//proto/raze:protobuf",
14+
],
1115
)
1216

13-
proto_library(
14-
name = "worker_protocol_proto",
15-
srcs = ["src/worker_protocol.proto"],
17+
rust_binary(
18+
name = "rustc-worker",
19+
srcs = ["src/main.rs"],
20+
deps = [
21+
":rustc_worker",
22+
"@io_bazel_rules_rust//proto/raze:protobuf",
23+
],
1624
)
1725

18-
rust_proto_library(
19-
name = "worker_protocol",
20-
deps = [":worker_protocol_proto"],
21-
)
26+
# rust_proto_toolchain(name = "default-proto-toolchain-impl")
27+
#
28+
# toolchain(
29+
# name = "default-proto-toolchain",
30+
# toolchain = ":default-proto-toolchain-impl",
31+
# toolchain_type = "@io_bazel_rules_rust//proto:toolchain",
32+
# )
33+
#
34+
# proto_library(
35+
# name = "worker_protocol_proto",
36+
# srcs = ["src/worker_protocol.proto"],
37+
# )
38+
#
39+
# rust_proto_library(
40+
# name = "worker_protocol",
41+
# deps = [":worker_protocol_proto"],
42+
# )

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,13 @@ Incrementality is obtained like this:
9696
The Worker protocol is described in a [protocol
9797
buffer](https://github.com/bazelbuild/bazel/blob/07e152e508d9926f1ec87cdf33c9970ee2f18a41/src/main/protobuf/worker_protocol.proto).
9898
This protocol will change very rarely, so to simplify the build process, we
99-
vendor the [`prost-build`](https://docs.rs/prost-build/) generated code in the
100-
tree. This avoids the need for a build.rs and related dependencies. If you need
101-
to update this, use a `build.rs` as described in the `prost-build`
102-
documentation to obtain a new module and replace `src/blaze_worker.rs`.
99+
vendor the generated code in the tree. This avoids the need for worker
100+
consumers (via Bazel) to build `protoc` and `protobuf-codegen`. If you need to
101+
update this:
102+
103+
1. Make sure `protoc` is installed for your operating system and in the path.
104+
2. `cargo install protobuf-codegen --version 2.8.2`.
105+
3. `protoc --rust_out src/ src/worker_protocol.proto`.
103106

104107
## TODO
105108

WORKSPACE

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ load("@io_bazel_rules_rust//:workspace.bzl", "bazel_version")
2626
bazel_version(name = "bazel_version")
2727
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2828

29+
# load("@io_bazel_rules_rust//proto:repositories.bzl", "rust_proto_repositories")
30+
# rust_proto_repositories()
31+
2932
http_archive(
3033
name = "rules_proto",
3134
sha256 = "602e7161d9195e50246177e7c55b2f39950a9cf7366f74ed5f22fd45750cd208",
@@ -39,6 +42,8 @@ load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_
3942
rules_proto_dependencies()
4043
rules_proto_toolchains()
4144

42-
register_toolchains(
43-
":default-proto-toolchain",
44-
)
45+
# register_toolchains(
46+
# ":default-proto-toolchain",
47+
# )
48+
load("@io_bazel_rules_rust//proto/raze:crates.bzl", "raze_fetch_remote_crates")
49+
raze_fetch_remote_crates()

0 commit comments

Comments
 (0)