Skip to content

Commit

Permalink
Regenerate documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
freeformstu committed Jun 25, 2023
1 parent 6cb92b2 commit 2c6d472
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion docs/crate_universe.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ bazel run //3rdparty:crates_vendor -- --repin
```

Under the hood, `--repin` will trigger a [cargo update](https://doc.rust-lang.org/cargo/commands/cargo-update.html)
call against the generated workspace. The following table describes how to controll particular values passed to the
call against the generated workspace. The following table describes how to control particular values passed to the
`cargo update` command.

| Value | Cargo command |
Expand Down
6 changes: 5 additions & 1 deletion docs/symbols.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ load(
_crates_vendor = "crates_vendor",
)
load(
"@rules_rust//proto:proto.bzl",
"@rules_rust//proto:defs.bzl",
_rust_grpc_library = "rust_grpc_library",
_rust_prost_library = "rust_prost_library",
_rust_proto_library = "rust_proto_library",
_rust_tonic_library = "rust_tonic_library",
)
load(
"@rules_rust//proto:repositories.bzl",
Expand Down Expand Up @@ -124,6 +126,8 @@ rust_doc_test = _rust_doc_test

rust_proto_library = _rust_proto_library
rust_grpc_library = _rust_grpc_library
rust_prost_library = _rust_prost_library
rust_tonic_library = _rust_tonic_library

rust_bindgen = _rust_bindgen
rust_bindgen_dependencies = _rust_bindgen_dependencies
Expand Down
1 change: 1 addition & 0 deletions proto/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ bzl_library(
srcs = glob(["**/*.bzl"]),
deps = [
"//proto/3rdparty:bzl_lib",
"//proto/prost:bzl_lib",
],
)
9 changes: 1 addition & 8 deletions proto/prost/private/prost.bzl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Rules for building protos in Rust with Prost and Tonic."""

load("@rules_proto//proto:defs.bzl", "ProtoInfo")
load("@rules_proto//proto:defs.bzl", "ProtoInfo", "proto_common")
load("//rust:defs.bzl", "rust_common")

# buildifier: disable=bzl-visibility
Expand All @@ -10,13 +10,6 @@ load("//rust/private:providers.bzl", "DepVariantInfo")
load("//rust/private:rustc.bzl", "rustc_compile_action")
load(":providers.bzl", "ProstProtoInfo", "TonicProtoInfo")

# This follows the exact same convention as the new upstream protobuf rules.
# https://github.com/protocolbuffers/protobuf/blob/v23.3/rust/aspects.bzl#L15
# The interface here hasn't changed in quite a while and since there's now
# additional reliance on it there it seems unlikely that it will break and if
# it does there should be a clear migration example for Starlark code there.
proto_common = proto_common_do_not_use

PROST_EXTENSION = ".rs"
TONIC_EXTENSION = ".tonic.rs"

Expand Down
46 changes: 24 additions & 22 deletions proto/prost/private/protoc_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,15 @@ fn find_generated_rust_files(out_dir: &Path) -> ProtocResult<BTreeSet<PathBuf>>
for f in find_generated_rust_files(&path)? {
all_rs_files.insert(f);
}
} else {
if let Some(ext) = path.extension() {
if ext == "rs" {
all_rs_files.insert(path);
}
} else if let Some(name) = path.file_name() {
if name == "_" {
let rs_name = path.parent().expect("Failed to get parent").join("_.rs");
fs::rename(&path, &rs_name).map_err(from_error)?;
all_rs_files.insert(rs_name);
}
} else if let Some(ext) = path.extension() {
if ext == "rs" {
all_rs_files.insert(path);
}
} else if let Some(name) = path.file_name() {
if name == "_" {
let rs_name = path.parent().expect("Failed to get parent").join("_.rs");
fs::rename(&path, &rs_name).map_err(from_error)?;
all_rs_files.insert(rs_name);
}
}
}
Expand Down Expand Up @@ -224,11 +222,11 @@ fn compute_proto_package_info(
crate_name: &str,
protoc: &Path,
includes: &BTreeSet<String>,
proto_paths: &Vec<String>,
proto_paths: &[String],
) -> ProtocResult<BTreeSet<String>> {
let mut extern_paths = BTreeSet::new();
for proto_file in proto_files.iter() {
let output = process::Command::new(&protoc)
let output = process::Command::new(protoc)
.args(includes.iter().map(|include| format!("-I{}", include)))
.arg("--print_free_field_numbers")
.args(
Expand Down Expand Up @@ -259,16 +257,16 @@ fn compute_proto_package_info(
}

let (absolute, _) = text
.split_once(" ")
.split_once(' ')
.ok_or_else(|| format!("Failed to split line: {}", text))?;

let mut package = "";
let mut symbol_name = absolute;
if let Some((package_, symbol_name_)) = absolute.rsplit_once(".") {
if let Some((package_, symbol_name_)) = absolute.rsplit_once('.') {
package = package_;
symbol_name = symbol_name_;
}
let symbol = format!("{}::{}", package.replace(".", "::"), symbol_name);
let symbol = format!("{}::{}", package.replace('.', "::"), symbol_name);
let extern_path = format!(".{}={}::{}", absolute, crate_name, symbol.trim_matches(':'));
if !extern_paths.insert(extern_path.clone()) {
panic!("Duplicate extern: {}", extern_path);
Expand Down Expand Up @@ -335,23 +333,27 @@ impl Args {
// for the process runner and arguments for protoc and potentially spawn
// additional arguments needed by prost.
for arg in env::args().skip(1) {
if !arg.starts_with("-") {
if !arg.starts_with('-') {
proto_files.insert(PathBuf::from(arg));
continue;
}

if arg.starts_with("-I") {
includes.insert(arg[2..].to_string());
includes.insert(
arg.strip_prefix("-I")
.expect("Failed to strip -I")
.to_string(),
);
continue;
}

if !arg.contains("=") {
if !arg.contains('=') {
extra_args.push(arg);
continue;
}

let part = arg
.split_once("=")
.split_once('=')
.ok_or_else(|| format!("Failed to parse argument `{arg}`",))?;
match part {
("--protoc", value) => {
Expand All @@ -369,7 +371,7 @@ impl Args {
}
("--package_info_output", value) => {
let (key, value) = value
.split_once("=")
.split_once('=')
.map(|(a, b)| (a.to_string(), PathBuf::from(b)))
.expect("Failed to parse package info output");
crate_name = Some(key);
Expand Down Expand Up @@ -539,7 +541,7 @@ fn main() -> ProtocResult<()> {
// Write outputs
fs::write(&out_librs, generate_lib_rs(&rust_files, is_tonic)?).map_err(from_error)?;
fs::write(
&package_info_file,
package_info_file,
package_info.into_iter().collect::<Vec<_>>().join("\n"),
)
.map_err(from_error)?;
Expand Down
8 changes: 4 additions & 4 deletions proto/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ def rust_proto_dependencies():
maybe(
http_archive,
name = "rules_proto",
sha256 = "66bfdf8782796239d3875d37e7de19b1d94301e8972b3cbd2446b332429b4df1",
strip_prefix = "rules_proto-4.0.0",
sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
strip_prefix = "rules_proto-5.3.0-21.7",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
],
)

Expand Down

0 comments on commit 2c6d472

Please sign in to comment.