Skip to content

Commit

Permalink
Migrate from cargo_raze to crate_universe
Browse files Browse the repository at this point in the history
The cargo_raze buildfile generator is no longer actively maintained.
It's superceded by crate_universe which doesn't require manual
installation of external tools or custom Cargo.toml configuration.

As a nice side effect, updating dependencies now only changes the
Cargo.lock and Cargo.bazel.lock files instead of a gazillion individual
buildfiles files in some subdirectory.

To rebuild the lockfiles:

```
CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index
```
  • Loading branch information
aaronmondal authored and allada committed Jun 29, 2023
1 parent fa97b28 commit 61309c1
Show file tree
Hide file tree
Showing 270 changed files with 14,086 additions and 21,873 deletions.
13,619 changes: 13,619 additions & 0 deletions Cargo.Bazel.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -50,11 +50,11 @@ Configuration is done via a JSON file that is passed in as the first parameter t

## How to update external rust deps

Install `cargo` and then run: `cargo install cargo-raze`.
From now on you can use:
```
$ cargo generate-lockfile # This will generate a new Cargo.lock file.
$ cargo raze # This will code-gen the bazel rules.
All dependencies are tracked in a generated `@crate_index` workspace and locked
in `Cargo.Bazel.lock`. To regenerate the `@crate_index`:

```bash
CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index
```

# License
Expand Down
45 changes: 40 additions & 5 deletions WORKSPACE
Expand Up @@ -12,20 +12,55 @@ http_archive(

http_archive(
name = "rules_python",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.5.0/rules_python-0.5.0.tar.gz",
sha256 = "cd6730ed53a002c56ce4e2f396ba3b3be262fd7cb68339f0377a45e8227fe332",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.5.0/rules_python-0.5.0.tar.gz",
)

load(
"@rules_rust//rust:repositories.bzl",
"rules_rust_dependencies",
"rust_register_toolchains",
)

load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
rules_rust_dependencies()
rust_register_toolchains(edition="2021", versions = ["1.62.1"])

load("//third_party:crates.bzl", "raze_fetch_remote_crates")
raze_fetch_remote_crates()
rust_register_toolchains(
edition = "2021",
versions = ["1.62.1"],
)

load(
"@rules_rust//crate_universe:defs.bzl",
"crate",
"crates_repository",
"render_config",
)

crates_repository(
name = "crate_index",
cargo_lockfile = "//:Cargo.lock",
lockfile = "//:Cargo.Bazel.lock",
manifests = ["//:Cargo.toml"],
render_config = render_config(
default_package_name = "",
),
supported_platform_triples = [
"aarch64-unknown-linux-gnu",
"arm-unknown-linux-gnueabi",
"armv7-unknown-linux-gnueabi",
"x86_64-unknown-linux-gnu",
],
)

load("@crate_index//:defs.bzl", "crate_repositories")

crate_repositories()

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

rust_proto_repositories()

# @com_google_protobuf is loaded from `rust_proto_repositories`.
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()
12 changes: 6 additions & 6 deletions cas/BUILD
Expand Up @@ -16,14 +16,14 @@ rust_binary(
"//cas/store:default_store_factory",
"//cas/worker:local_worker",
"//config",
"//third_party:clap",
"//third_party:env_logger",
"//third_party:futures",
"//third_party:json5",
"//third_party:tokio",
"//third_party:tonic",
"//util:common",
"//util:error",
"@crate_index//:clap",
"@crate_index//:env_logger",
"@crate_index//:futures",
"@crate_index//:json5",
"@crate_index//:tokio",
"@crate_index//:tonic",
"@rules_rust//tools/runfiles",
],
)
108 changes: 54 additions & 54 deletions cas/grpc_service/BUILD
Expand Up @@ -3,192 +3,192 @@ load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
rust_library(
name = "cas_server",
srcs = ["cas_server.rs"],
visibility = ["//cas:__pkg__"],
deps = [
"//cas/store",
"//cas/store:grpc_store",
"//config",
"//proto",
"//third_party:bytes",
"//third_party:futures",
"//third_party:stdext",
"//third_party:tokio",
"//third_party:tonic",
"//util:common",
"//util:error",
"@crate_index//:bytes",
"@crate_index//:futures",
"@crate_index//:stdext",
"@crate_index//:tokio",
"@crate_index//:tonic",
],
visibility = ["//cas:__pkg__"]
)

rust_library(
name = "ac_server",
srcs = ["ac_server.rs"],
visibility = ["//cas:__pkg__"],
deps = [
"//cas/store",
"//cas/store:ac_utils",
"//cas/store:grpc_store",
"//config",
"//proto",
"//third_party:bytes",
"//third_party:prost",
"//third_party:tonic",
"//util:common",
"//util:error",
"@crate_index//:bytes",
"@crate_index//:prost",
"@crate_index//:tonic",
],
visibility = ["//cas:__pkg__"]
)

rust_library(
name = "capabilities_server",
srcs = ["capabilities_server.rs"],
visibility = ["//cas:__pkg__"],
deps = [
"//cas/scheduler",
"//cas/store",
"//config",
"//proto",
"//third_party:tonic",
"//util:error",
"@crate_index//:tonic",
],
visibility = ["//cas:__pkg__"]
)

rust_library(
name = "bytestream_server",
srcs = ["bytestream_server.rs"],
visibility = ["//cas:__pkg__"],
deps = [
"//cas/store",
"//cas/store:grpc_store",
"//config",
"//proto",
"//third_party:async_lock",
"//third_party:futures",
"//third_party:tokio",
"//third_party:tonic",
"//util:buf_channel",
"//util:common",
"//util:error",
"//util:resource_info",
"//util:write_request_stream_wrapper",
"@crate_index//:async-lock",
"@crate_index//:futures",
"@crate_index//:tokio",
"@crate_index//:tonic",
],
visibility = ["//cas:__pkg__"]
)

rust_library(
name = "execution_server",
srcs = ["execution_server.rs"],
visibility = ["//cas:__pkg__"],
deps = [
"//cas/scheduler",
"//cas/scheduler:action_messages",
"//cas/scheduler:platform_property_manager",
"//cas/scheduler:scheduler",
"//cas/store",
"//cas/store:ac_utils",
"//config",
"//proto",
"//third_party:futures",
"//third_party:rand",
"//third_party:stdext",
"//third_party:tokio",
"//third_party:tokio_stream",
"//third_party:tonic",
"//util:common",
"//util:error",
"@crate_index//:futures",
"@crate_index//:rand",
"@crate_index//:stdext",
"@crate_index//:tokio",
"@crate_index//:tokio-stream",
"@crate_index//:tonic",
],
visibility = ["//cas:__pkg__"]
)

rust_library(
name = "worker_api_server",
srcs = ["worker_api_server.rs"],
visibility = ["//cas:__pkg__"],
deps = [
"//cas/scheduler",
"//cas/scheduler:action_messages",
"//cas/scheduler:platform_property_manager",
"//cas/scheduler:worker",
"//config",
"//proto",
"//third_party:futures",
"//third_party:tokio",
"//third_party:tonic",
"//third_party:uuid",
"//util:common",
"//util:error",
"@crate_index//:futures",
"@crate_index//:tokio",
"@crate_index//:tonic",
"@crate_index//:uuid",
],
visibility = ["//cas:__pkg__"]
)

rust_test(
name = "worker_api_server_test",
srcs = ["tests/worker_api_server_test.rs"],
deps = [
":worker_api_server",
"//cas/scheduler",
"//cas/scheduler:action_messages",
"//cas/scheduler:platform_property_manager",
"//cas/scheduler:worker",
"//config",
"//proto",
"//third_party:pretty_assertions",
"//third_party:tokio",
"//third_party:tokio_stream",
"//third_party:tonic",
"//util:common",
"//util:error",
":worker_api_server",
"@crate_index//:pretty_assertions",
"@crate_index//:tokio",
"@crate_index//:tokio-stream",
"@crate_index//:tonic",
],
)

rust_test(
name = "cas_server_test",
srcs = ["tests/cas_server_test.rs"],
deps = [
":cas_server",
"//cas/store",
"//cas/store:default_store_factory",
"//config",
"//proto",
"//third_party:maplit",
"//third_party:pretty_assertions",
"//third_party:tokio",
"//third_party:tonic",
"//util:common",
"//util:error",
":cas_server",
"@crate_index//:maplit",
"@crate_index//:pretty_assertions",
"@crate_index//:tokio",
"@crate_index//:tonic",
],
)

rust_test(
name = "ac_server_test",
srcs = ["tests/ac_server_test.rs"],
deps = [
":ac_server",
"//cas/store",
"//cas/store:default_store_factory",
"//config",
"//proto",
"//third_party:bytes",
"//third_party:maplit",
"//third_party:pretty_assertions",
"//third_party:prost",
"//third_party:tokio",
"//third_party:tonic",
"//util:common",
"//util:error",
":ac_server",
"@crate_index//:bytes",
"@crate_index//:maplit",
"@crate_index//:pretty_assertions",
"@crate_index//:prost",
"@crate_index//:tokio",
"@crate_index//:tonic",
],
)

rust_test(
name = "bytestream_server_test",
srcs = ["tests/bytestream_server_test.rs"],
deps = [
":bytestream_server",
"//cas/store",
"//cas/store:default_store_factory",
"//config",
"//proto",
"//third_party:futures",
"//third_party:maplit",
"//third_party:pretty_assertions",
"//third_party:tokio",
"//third_party:tokio_stream",
"//third_party:tonic",
"//util:common",
"//util:error",
":bytestream_server",
"@crate_index//:futures",
"@crate_index//:maplit",
"@crate_index//:pretty_assertions",
"@crate_index//:tokio",
"@crate_index//:tokio-stream",
"@crate_index//:tonic",
],
)

0 comments on commit 61309c1

Please sign in to comment.