Skip to content

Commit

Permalink
fix: remove protobuf crate
Browse files Browse the repository at this point in the history
  • Loading branch information
XAMPPRocky committed Oct 7, 2024
1 parent e83b7fb commit ef6696a
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 70 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ jobs:
command: clippy
args: --all-targets --features flamegraph,prost-codec -- -D warnings

- name: Run cargo clippy protobuf
uses: actions-rs/cargo@v1.0.3
with:
command: clippy
args: --all-targets --features flamegraph,protobuf-codec -- -D warnings

- name: Check if the prost file committed to git is up-to-date
run: |
git diff --no-ext-diff --exit-code
Expand Down
27 changes: 0 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ frame-pointer = []
# A private feature to indicate either prost-codec or protobuf-codec is enabled.
_protobuf = []
prost-codec = ["prost", "prost-derive", "prost-build", "sha2", "_protobuf"]
protobuf-codec = ["protobuf", "protobuf-codegen-pure", "_protobuf"]

[dependencies]
backtrace = { version = "0.3" }
Expand All @@ -37,7 +36,6 @@ smallvec = "1.13"
inferno = { version = "0.11", default-features = false, features = ["nameattr"], optional = true }
prost = { version = "0.12", optional = true }
prost-derive = { version = "0.12", optional = true }
protobuf = { version = "2.28", optional = true }
criterion = {version = "0.5", optional = true}

[dependencies.symbolic-demangle]
Expand All @@ -52,7 +50,6 @@ rand = "0.8.5"
[build-dependencies]
prost-build = { version = "0.12", optional = true }
sha2 = { version = "0.10", optional = true }
protobuf-codegen-pure = { version = "2.28", optional = true }

[[example]]
name = "flamegraph"
Expand Down
24 changes: 0 additions & 24 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.

#[cfg(feature = "protobuf-codec")]
// Allow deprecated as TiKV pin versions to a outdated one.
#[allow(deprecated)]
fn generate_protobuf() {
use std::io::Write;

let out_dir = std::env::var("OUT_DIR").unwrap();
protobuf_codegen_pure::run(protobuf_codegen_pure::Args {
out_dir: &out_dir,
includes: &["proto"],
input: &["proto/profile.proto"],
customize: protobuf_codegen_pure::Customize {
generate_accessors: Some(false),
lite_runtime: Some(true),
..Default::default()
},
})
.unwrap();
let mut f = std::fs::File::create(format!("{}/mod.rs", out_dir)).unwrap();
write!(f, "pub mod profile;").unwrap();
}

#[cfg(feature = "prost-codec")]
fn generate_prost() {
use sha2::{Digest, Sha256};
Expand Down Expand Up @@ -67,6 +45,4 @@ fn generate_prost() {
fn main() {
#[cfg(feature = "prost-codec")]
generate_prost();
#[cfg(feature = "protobuf-codec")]
generate_protobuf();
}
11 changes: 1 addition & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub use self::report::{Report, ReportBuilder, UnresolvedReport};
pub use inferno::flamegraph;

#[allow(clippy::all)]
#[cfg(all(feature = "prost-codec", not(feature = "protobuf-codec")))]
#[cfg(feature = "prost-codec")]
pub mod protos {
pub use prost::Message;

Expand All @@ -76,14 +76,5 @@ pub mod protos {
));
}

#[cfg(feature = "protobuf-codec")]
pub mod protos {
pub use protobuf::Message;

include!(concat!(env!("OUT_DIR"), "/mod.rs"));

pub use self::profile::*;
}

#[cfg(feature = "criterion")]
pub mod criterion;

0 comments on commit ef6696a

Please sign in to comment.