Skip to content

Commit

Permalink
feat: make protoc requirement optional (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
infiniteregrets authored Dec 11, 2024
1 parent c57b098 commit cb62572
Show file tree
Hide file tree
Showing 5 changed files with 2,367 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: install rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
toolchain: stable nightly
components: rustfmt, clippy
- name: install protoc
uses: arduino/setup-protoc@v3
Expand All @@ -71,7 +71,7 @@ jobs:
RUSTDOCFLAGS: -D warnings
run: cargo doc --workspace --all-features --no-deps --document-private-items
- name: check formatting
run: cargo fmt --all -- --check
run: cargo +nightly fmt --all -- --check
- name: check clippy
run: cargo clippy --workspace --all-features --all-targets -- -D warnings --allow deprecated
- name: check Cargo.toml sorting
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ prost = "0.13.3"
prost-types = "0.13.3"
regex = "1.11.1"
secrecy = "0.8.0"
sync_docs = "0.1.0"
sync_docs = { git = "https://github.com/s2-streamstore/sync_docs" }
thiserror = "1.0.67"
tokio = { version = "1.41.1", features = ["time"] }
tokio-muxt = "0.5.0"
Expand All @@ -32,7 +32,7 @@ tracing = "0.1.40"
uuid = { version = "1.11.0", features = ["v4", "fast-rng"] }

[build-dependencies]
tonic-build = { version = "0.12.3", features = ["prost"] }
tonic-build = { version = "0.12.3", features = ["prost"], optional = true }

[dev-dependencies]
rstest = "0.23.0"
Expand All @@ -41,6 +41,7 @@ tokio-stream = "0.1.16"

[features]
connector = []
prost-build = ["dep:tonic-build"]

[lints.clippy]
unused_async = "deny"
14 changes: 9 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure()
.bytes(["."])
.compile_protos(&["proto/s2/v1alpha/s2.proto"], &["proto"])?;

println!("cargo:rustc-env=COMPILED_PROST_FILE=s2.v1alpha.rs");
#[cfg(feature = "prost-build")]
{
tonic_build::configure()
.out_dir("src")
.bytes(["."])
.compile_protos(&["proto/s2/v1alpha/s2.proto"], &["proto"])?;
std::fs::rename("src/s2.v1alpha.rs", "src/api.rs")?;
}
println!("cargo:rustc-env=COMPILED_PROST_FILE=src/api.rs");
Ok(())
}
Loading

0 comments on commit cb62572

Please sign in to comment.