diff options
author | Wyatt Calandro <64923869+wcalandro@users.noreply.github.com> | 2022-07-28 15:20:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-28 15:20:15 -0700 |
commit | 48a119cdc2e1decc390c0af98617c10e6f90de36 (patch) | |
tree | 97634b351f0749c28ff40aaecb0c5804e00de0b0 | |
parent | d282719f5fe1d97ff260964335f59145ed927a3e (diff) | |
download | kythe-48a119cdc2e1decc390c0af98617c10e6f90de36.tar.gz |
chore(rust_common): manually configure the Rust protobuf toolchain (#5330)
* chore(rust_common): manually configure the Rust protobuf toolchain
* fix: linting issues
-rw-r--r-- | BUILD | 15 | ||||
-rw-r--r-- | Cargo.Bazel.lock | 39 | ||||
-rw-r--r-- | WORKSPACE | 13 | ||||
-rw-r--r-- | cargo-bazel-lock.json | 236 | ||||
-rw-r--r-- | external.bzl | 2 | ||||
-rw-r--r-- | kythe/rust/extractor/BUILD | 4 | ||||
-rw-r--r-- | kythe/rust/fuchsia_extractor/BUILD | 4 | ||||
-rw-r--r-- | kythe/rust/indexer/BUILD | 8 | ||||
-rw-r--r-- | tools/rust/extra_action/BUILD | 2 |
9 files changed, 311 insertions, 12 deletions
@@ -1,6 +1,7 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("//:version.bzl", "MAX_VERSION", "MIN_VERSION") load("@bazel_gazelle//:def.bzl", "gazelle") +load("@rules_rust//proto:toolchain.bzl", "rust_proto_toolchain") package(default_visibility = ["//visibility:private"]) @@ -49,3 +50,17 @@ bzl_library( name = "setup_bzl", srcs = ["setup.bzl"], ) + +# Create a Rust protobuf toolchain with protobuf version 2.8.2 +rust_proto_toolchain( + name = "rust_proto_toolchain_impl", + edition = "2021", + proto_compile_deps = ["@crate_index//:protobuf"], + proto_plugin = "@crate_index//:protobuf-codegen__protoc-gen-rust", +) + +toolchain( + name = "rust_proto_toolchain", + toolchain = ":rust_proto_toolchain_impl", + toolchain_type = "@rules_rust//proto:toolchain", +) diff --git a/Cargo.Bazel.lock b/Cargo.Bazel.lock index 58b6c366a..c324dca8d 100644 --- a/Cargo.Bazel.lock +++ b/Cargo.Bazel.lock @@ -77,6 +77,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] +name = "bytes" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +dependencies = [ + "byteorder", + "iovec", +] + +[[package]] name = "bzip2" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -241,6 +251,8 @@ dependencies = [ "hex", "lazy_static", "path-clean", + "protobuf", + "protobuf-codegen", "quick-error", "rayon", "regex", @@ -323,6 +335,15 @@ dependencies = [ ] [[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + +[[package]] name = "itertools" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -485,6 +506,24 @@ dependencies = [ ] [[package]] +name = "protobuf" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70731852eec72c56d11226c8a5f96ad5058a3dab73647ca5f7ee351e464f2571" +dependencies = [ + "bytes", +] + +[[package]] +name = "protobuf-codegen" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d74b9cbbf2ac9a7169c85a3714ec16c51ee9ec7cfd511549527e9a7df720795" +dependencies = [ + "protobuf", +] + +[[package]] name = "quick-error" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -111,6 +111,14 @@ crates_repository( "serial_test": crate.spec( version = "0.6.0", ), + # Dependencies for our Rust protobuf toolchain + "protobuf": crate.spec( + features = ["with-bytes"], + version = "=2.8.2", + ), + "protobuf-codegen": crate.spec( + version = "=2.8.2", + ), }, render_config = render_config( default_package_name = "", @@ -120,3 +128,8 @@ crates_repository( load("@crate_index//:defs.bzl", "crate_repositories") crate_repositories() + +# Register our Rust protobuf toolchain from the BUILD file +register_toolchains( + ":rust_proto_toolchain", +) diff --git a/cargo-bazel-lock.json b/cargo-bazel-lock.json index eaa4b02d0..a9ee829e6 100644 --- a/cargo-bazel-lock.json +++ b/cargo-bazel-lock.json @@ -1,5 +1,5 @@ { - "checksum": "e648ab4a6092efa4423a7d5bbbadfd78b7f87914a8f97508f3ebcc990a7f20d8", + "checksum": "6a69c3f063bb45f7b5b1837f5c023c5ed381780c57ba38e3e28325afa96f3832", "crates": { "adler 1.0.2": { "name": "adler", @@ -428,6 +428,52 @@ }, "license": "Unlicense OR MIT" }, + "bytes 0.4.12": { + "name": "bytes", + "version": "0.4.12", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/bytes/0.4.12/download", + "sha256": "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" + } + }, + "targets": [ + { + "Library": { + "crate_name": "bytes", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "bytes", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "byteorder 1.4.3", + "target": "byteorder" + }, + { + "id": "iovec 0.1.4", + "target": "iovec" + } + ], + "selects": {} + }, + "edition": "2015", + "version": "0.4.12" + }, + "license": "MIT" + }, "bzip2 0.4.3": { "name": "bzip2", "version": "0.4.3", @@ -1369,6 +1415,14 @@ "target": "path_clean" }, { + "id": "protobuf 2.8.2", + "target": "protobuf" + }, + { + "id": "protobuf-codegen 2.8.2", + "target": "protobuf_codegen" + }, + { "id": "quick-error 2.0.1", "target": "quick_error" }, @@ -1835,6 +1889,50 @@ }, "license": "BSD-3-Clause" }, + "iovec 0.1.4": { + "name": "iovec", + "version": "0.1.4", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/iovec/0.1.4/download", + "sha256": "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" + } + }, + "targets": [ + { + "Library": { + "crate_name": "iovec", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "iovec", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [], + "selects": { + "cfg(unix)": [ + { + "id": "libc 0.2.126", + "target": "libc" + } + ] + } + }, + "edition": "2015", + "version": "0.1.4" + }, + "license": "MIT/Apache-2.0" + }, "itertools 0.10.3": { "name": "itertools", "version": "0.10.3", @@ -2890,6 +2988,139 @@ }, "license": "MIT OR Apache-2.0" }, + "protobuf 2.8.2": { + "name": "protobuf", + "version": "2.8.2", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/protobuf/2.8.2/download", + "sha256": "70731852eec72c56d11226c8a5f96ad5058a3dab73647ca5f7ee351e464f2571" + } + }, + "targets": [ + { + "Library": { + "crate_name": "protobuf", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "BuildScript": { + "crate_name": "build_script_build", + "crate_root": "build.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "protobuf", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "crate_features": [ + "bytes", + "with-bytes" + ], + "deps": { + "common": [ + { + "id": "bytes 0.4.12", + "target": "bytes" + }, + { + "id": "protobuf 2.8.2", + "target": "build_script_build" + } + ], + "selects": {} + }, + "edition": "2015", + "version": "2.8.2" + }, + "build_script_attrs": { + "data_glob": [ + "**" + ] + }, + "license": "MIT" + }, + "protobuf-codegen 2.8.2": { + "name": "protobuf-codegen", + "version": "2.8.2", + "repository": { + "Http": { + "url": "https://crates.io/api/v1/crates/protobuf-codegen/2.8.2/download", + "sha256": "3d74b9cbbf2ac9a7169c85a3714ec16c51ee9ec7cfd511549527e9a7df720795" + } + }, + "targets": [ + { + "Library": { + "crate_name": "protobuf_codegen", + "crate_root": "src/lib.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "Binary": { + "crate_name": "protoc-gen-rust", + "crate_root": "src/bin/protoc-gen-rust.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + }, + { + "Binary": { + "crate_name": "protobuf-bin-gen-rust-do-not-use", + "crate_root": "src/bin/protobuf-bin-gen-rust-do-not-use.rs", + "srcs": { + "include": [ + "**/*.rs" + ], + "exclude": [] + } + } + } + ], + "library_target_name": "protobuf_codegen", + "common_attrs": { + "compile_data_glob": [ + "**" + ], + "deps": { + "common": [ + { + "id": "protobuf 2.8.2", + "target": "protobuf" + } + ], + "selects": {} + }, + "edition": "2015", + "version": "2.8.2" + }, + "license": "MIT" + }, "quick-error 2.0.1": { "name": "quick-error", "version": "2.0.1", @@ -5134,7 +5365,8 @@ } }, "binary_crates": [ - "cc 1.0.73" + "cc 1.0.73", + "protobuf-codegen 2.8.2" ], "workspace_members": { "direct-cargo-bazel-deps 0.0.1": "" diff --git a/external.bzl b/external.bzl index 171bfb94e..a6dc24678 100644 --- a/external.bzl +++ b/external.bzl @@ -38,7 +38,7 @@ def _rule_dependencies(): py_repositories() rules_rust_dependencies() rust_register_toolchains(version = "nightly", iso_date = "2022-01-09", dev_components = True, include_rustc_srcs = True) - rust_proto_repositories() + rust_proto_repositories(register_default_toolchain = False) rust_analyzer_deps() crate_universe_dependencies() rules_ruby_dependencies() diff --git a/kythe/rust/extractor/BUILD b/kythe/rust/extractor/BUILD index 0488a1047..d94fecb59 100644 --- a/kythe/rust/extractor/BUILD +++ b/kythe/rust/extractor/BUILD @@ -32,11 +32,11 @@ rust_binary( "@crate_index//:clap", "@crate_index//:glob", "@crate_index//:hex", + "@crate_index//:protobuf", "@crate_index//:rls-data", "@crate_index//:sha2", "@crate_index//:tempdir", "@crate_index//:zip", - "@rules_rust//proto/raze:protobuf", ], ) @@ -90,9 +90,9 @@ rust_binary( "//third_party/bazel:extra_actions_base_rust_proto", "//tools/rust/runfiles", "@crate_index//:anyhow", + "@crate_index//:protobuf", "@crate_index//:tempdir", "@crate_index//:zip", - "@rules_rust//proto/raze:protobuf", ], ) diff --git a/kythe/rust/fuchsia_extractor/BUILD b/kythe/rust/fuchsia_extractor/BUILD index 2e03ea166..11c99ad53 100644 --- a/kythe/rust/fuchsia_extractor/BUILD +++ b/kythe/rust/fuchsia_extractor/BUILD @@ -14,7 +14,7 @@ rust_library( "//kythe/proto:analysis_rust_proto", "@com_google_absl//absl/status", "@crate_index//:anyhow", - "@rules_rust//proto/raze:protobuf", + "@crate_index//:protobuf", ], ) @@ -53,13 +53,13 @@ rust_binary( "@crate_index//:clap", "@crate_index//:hex", "@crate_index//:lazy_static", + "@crate_index//:protobuf", "@crate_index//:rayon", "@crate_index//:regex", "@crate_index//:rls-data", "@crate_index//:serde_json", "@crate_index//:sha2", "@crate_index//:tempdir", - "@rules_rust//proto/raze:protobuf", ], ) diff --git a/kythe/rust/indexer/BUILD b/kythe/rust/indexer/BUILD index 1dd1ae87c..d67f7e462 100644 --- a/kythe/rust/indexer/BUILD +++ b/kythe/rust/indexer/BUILD @@ -16,6 +16,7 @@ rust_library( "@crate_index//:base64", "@crate_index//:hex", "@crate_index//:path-clean", + "@crate_index//:protobuf", "@crate_index//:quick-error", "@crate_index//:rls-analysis", "@crate_index//:rls-data", @@ -23,7 +24,6 @@ rust_library( "@crate_index//:serde_json", "@crate_index//:sha2", "@crate_index//:zip", - "@rules_rust//proto/raze:protobuf", ], ) @@ -38,7 +38,7 @@ rust_binary( ":kythe_rust_indexer", "@crate_index//:anyhow", "@crate_index//:clap", - "@rules_rust//proto/raze:protobuf", + "@crate_index//:protobuf", ], ) @@ -55,8 +55,8 @@ rust_binary( "@crate_index//:anyhow", "@crate_index//:base64", "@crate_index//:clap", + "@crate_index//:protobuf", "@crate_index//:serde_json", - "@rules_rust//proto/raze:protobuf", ], ) @@ -78,8 +78,8 @@ rust_test( "//kythe/proto:analysis_rust_proto", "//kythe/proto:storage_rust_proto", "@crate_index//:hex", + "@crate_index//:protobuf", "@crate_index//:sha2", - "@rules_rust//proto/raze:protobuf", "@rules_rust//tools/runfiles", ], ) diff --git a/tools/rust/extra_action/BUILD b/tools/rust/extra_action/BUILD index b8f4d7dfc..7f4407584 100644 --- a/tools/rust/extra_action/BUILD +++ b/tools/rust/extra_action/BUILD @@ -10,7 +10,7 @@ rust_binary( "//third_party/bazel:extra_actions_base_rust_proto", "@crate_index//:anyhow", "@crate_index//:clap", - "@rules_rust//proto/raze:protobuf", + "@crate_index//:protobuf", ], ) |