Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: protoc should not be required #194

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ jobs:
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable

- name: Install protoc
uses: arduino/setup-protoc@v3

- name: Set up Rust cache
uses: Swatinem/rust-cache@v2
with:
Expand Down
66 changes: 2 additions & 64 deletions clients/cli/Cargo.lock

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

5 changes: 1 addition & 4 deletions clients/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
[package]
name = "nexus-network"
version = "0.4.0"
version = "0.4.3"
edition = "2021"

[[bin]]
name = "prover"
path = "src/prover.rs"

[build-dependencies]
prost-build = "0.13"

[profile.dev]
opt-level = 1

Expand Down
31 changes: 9 additions & 22 deletions clients/cli/build.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
use std::{error::Error, path::PathBuf, process::Command};
use std::{error::Error, path::PathBuf};

fn main() -> Result<(), Box<dyn Error>> {
let out_dir: PathBuf = "./src/generated/".into();
let proto_file: PathBuf = "../../proto/orchestrator.proto".into();
let proto_dir = match proto_file.parent().ok_or("Failed to get parent directory of proto file") {
Ok(dir) => dir,
Err(e) => return Err(e.into()),
};
let generated_file: PathBuf = "./src/generated/nexus.orchestrator.rs".into();

match Command::new("protoc")
.arg("--version")
.output() {
Ok(_) => prost_build::Config::new()
.out_dir(out_dir)
.protoc_arg("--experimental_allow_proto3_optional")
.compile_protos(&[&proto_file], &[proto_dir])?,
Err(e) => {
// Skipping protobuf compilation.
println!("cargo:warning=Failed to run protoc: {}", e);
return Err(e.into());
}
// Verify the generated file exists
if !generated_file.exists() {
println!(
"cargo:warning=Generated protobuf file not found at {}",
generated_file.display()
);
return Err("Missing required generated protobuf file".into());
}

// Tell Cargo to rerun this script if the proto file changes
println!("cargo:rerun-if-changed={}", proto_file.display());

Ok(())
}
Loading