Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
MixusMinimax authored Mar 15, 2024
2 parents 8e77510 + 2a4aeaf commit 9a5edea
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 23 deletions.
16 changes: 16 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Rust",
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye",
"features": {
"ghcr.io/devcontainers-contrib/features/apt-packages:1": {
"packages": "cmake,ninja-build,protobuf-compiler,libprotoc-dev"
}
},
"customizations": {
"vscode": {
"extensions": [
"zxh404.vscode-proto3"
]
}
}
}
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: install cargo-machete
uses: baptiste0928/cargo-install@v2
with:
crate: cargo-machete
- uses: taiki-e/install-action@cargo-machete
- name: Check unused dependencies
run: cargo machete

Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ exclude = [
bench = false

[features]
default = ["prost-derive", "std"]
prost-derive = ["dep:prost-derive"]
default = ["derive", "std"]
derive = ["dep:prost-derive"]
prost-derive = ["derive"] # deprecated, please use derive feature instead
no-recursion-limit = []
std = []

Expand Down
23 changes: 10 additions & 13 deletions prost-build/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1516,24 +1516,21 @@ pub fn protoc_from_env() -> PathBuf {
}

pub fn error_message_protoc_not_found() -> String {
let error_msg = "Could not find `protoc`. If `protoc` is installed, try setting the `PROTOC` environment variable to the path of the `protoc` binary.";

let os_specific_hint = if cfg!(target_os = "macos") {
"You could try running `brew install protobuf` or downloading it from https://github.com/protocolbuffers/protobuf/releases"
"To install it on macOS, run `brew install protobuf`."
} else if cfg!(target_os = "linux") {
"If you're on debian, try `apt-get install protobuf-compiler` or download it from https://github.com/protocolbuffers/protobuf/releases"
"To install it on Debian, run `apt-get install protobuf-compiler`."
} else {
"You can download it from https://github.com/protocolbuffers/protobuf/releases or from your package manager."
"Try installing `protobuf-compiler` or `protobuf` using your package manager."
};
let error_msg =
"Could not find `protoc` installation and this build crate cannot proceed without
this knowledge. If `protoc` is installed and this crate had trouble finding
it, you can set the `PROTOC` environment variable with the specific path to your
installed `protoc` binary.";
format!(
"{}{}
let download_msg =
"It is also available at https://github.com/protocolbuffers/protobuf/releases";

For more information: https://docs.rs/prost-build/#sourcing-protoc
",
error_msg, os_specific_hint
format!(
"{} {} {} For more information: https://docs.rs/prost-build/#sourcing-protoc",
error_msg, os_specific_hint, download_msg
)
}

Expand Down
3 changes: 2 additions & 1 deletion src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ pub fn encode_varint<B>(mut value: u64, buf: &mut B)
where
B: BufMut,
{
loop {
// Varints are never more than 10 bytes
for _ in 0..10 {
if value < 0x80 {
buf.put_u8(value as u8);
break;
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ where
// Based on serde's equivalent re-export [1], but enabled by default.
//
// [1]: https://github.com/serde-rs/serde/blob/v1.0.89/serde/src/lib.rs#L245-L256
#[cfg(feature = "prost-derive")]
#[cfg(feature = "derive")]
#[allow(unused_imports)]
#[macro_use]
extern crate prost_derive;
#[cfg(feature = "prost-derive")]
#[cfg(feature = "derive")]
#[doc(hidden)]
pub use prost_derive::*;
2 changes: 1 addition & 1 deletion tests-no-std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ path = "../tests/src/lib.rs"
anyhow = { version = "1.0.45", default-features = false }
bytes = { version = "1", default-features = false }
cfg-if = "1"
prost = { path = "..", default-features = false, features = ["prost-derive"] }
prost = { path = "..", default-features = false, features = ["derive"] }
prost-types = { path = "../prost-types", default-features = false }
protobuf = { path = "../protobuf" }

Expand Down

0 comments on commit 9a5edea

Please sign in to comment.