Skip to content

Commit

Permalink
ok, builds with bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilm committed Sep 22, 2020
1 parent 56c5505 commit 47d2de4
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 23 deletions.
53 changes: 37 additions & 16 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,21 +1,42 @@
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_rust//proto:proto.bzl", "rust_proto_library")
load("@io_bazel_rules_rust//proto:toolchain.bzl", "PROTO_COMPILE_DEPS", "rust_proto_toolchain")
# load("@rules_proto//proto:defs.bzl", "proto_library")
# load("@io_bazel_rules_rust//proto:proto.bzl", "rust_proto_library")
# load("@io_bazel_rules_rust//proto:toolchain.bzl", "PROTO_COMPILE_DEPS", "rust_proto_toolchain")
load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library", "rust_binary")

rust_proto_toolchain(name = "default-proto-toolchain-impl")

toolchain(
name = "default-proto-toolchain",
toolchain = ":default-proto-toolchain-impl",
toolchain_type = "@io_bazel_rules_rust//proto:toolchain",
rust_library(
name = "rustc_worker",
srcs = [
"src/lib.rs",
"src/worker_protocol.rs",
],
deps = [
"@io_bazel_rules_rust//proto/raze:protobuf",
],
)

proto_library(
name = "worker_protocol_proto",
srcs = ["src/worker_protocol.proto"],
rust_binary(
name = "rustc-worker",
srcs = ["src/main.rs"],
deps = [
":rustc_worker",
"@io_bazel_rules_rust//proto/raze:protobuf",
],
)

rust_proto_library(
name = "worker_protocol",
deps = [":worker_protocol_proto"],
)
# rust_proto_toolchain(name = "default-proto-toolchain-impl")
#
# toolchain(
# name = "default-proto-toolchain",
# toolchain = ":default-proto-toolchain-impl",
# toolchain_type = "@io_bazel_rules_rust//proto:toolchain",
# )
#
# proto_library(
# name = "worker_protocol_proto",
# srcs = ["src/worker_protocol.proto"],
# )
#
# rust_proto_library(
# name = "worker_protocol",
# deps = [":worker_protocol_proto"],
# )
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,13 @@ Incrementality is obtained like this:
The Worker protocol is described in a [protocol
buffer](https://github.com/bazelbuild/bazel/blob/07e152e508d9926f1ec87cdf33c9970ee2f18a41/src/main/protobuf/worker_protocol.proto).
This protocol will change very rarely, so to simplify the build process, we
vendor the [`prost-build`](https://docs.rs/prost-build/) generated code in the
tree. This avoids the need for a build.rs and related dependencies. If you need
to update this, use a `build.rs` as described in the `prost-build`
documentation to obtain a new module and replace `src/blaze_worker.rs`.
vendor the generated code in the tree. This avoids the need for worker
consumers (via Bazel) to build `protoc` and `protobuf-codegen`. If you need to
update this:

1. Make sure `protoc` is installed for your operating system and in the path.
2. `cargo install protobuf-codegen --version 2.8.2`.
3. `protoc --rust_out src/ src/worker_protocol.proto`.

## TODO

Expand Down
11 changes: 8 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ load("@io_bazel_rules_rust//:workspace.bzl", "bazel_version")
bazel_version(name = "bazel_version")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# load("@io_bazel_rules_rust//proto:repositories.bzl", "rust_proto_repositories")
# rust_proto_repositories()

http_archive(
name = "rules_proto",
sha256 = "602e7161d9195e50246177e7c55b2f39950a9cf7366f74ed5f22fd45750cd208",
Expand All @@ -39,6 +42,8 @@ load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_
rules_proto_dependencies()
rules_proto_toolchains()

register_toolchains(
":default-proto-toolchain",
)
# register_toolchains(
# ":default-proto-toolchain",
# )
load("@io_bazel_rules_rust//proto/raze:crates.bzl", "raze_fetch_remote_crates")
raze_fetch_remote_crates()

0 comments on commit 47d2de4

Please sign in to comment.