Skip to content

Commit

Permalink
Move to protobuf 3.x
Browse files Browse the repository at this point in the history
This also adds rules to not unnecessarily run the build script
(build.rs) if the input has not changed. This also moves the protobuf
generation in its own library/subdirectory to avoid errors on docs.rs
which mounts the src/ directory as read-only.

Signed-off-by: Adrian Reber <areber@redhat.com>
  • Loading branch information
adrianreber committed Jan 17, 2023
1 parent 87a5e0b commit 243d352
Show file tree
Hide file tree
Showing 10 changed files with 6,266 additions and 7,004 deletions.
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ license-file = "LICENSE"

[dependencies]
libc = "0.2"
protobuf = "2.27.1"
anyhow = "1.0.56"

[build-dependencies]
protobuf-codegen-pure = "2.25.2"
protobuf = "3.2.0"
rust-criu-protobuf = { path = "rust-criu-protobuf" }

[lib]
name = "rust_criu"
Expand Down
10 changes: 1 addition & 9 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
extern crate protobuf_codegen_pure;

fn main() {
protobuf_codegen_pure::Codegen::new()
.out_dir("src/proto")
.inputs(["proto/rpc.proto"])
.include("proto")
.run()
.expect("Codegen failed.");

std::process::Command::new("gcc")
.args(["test/piggie.c", "-o", "test/piggie"])
.status()
.unwrap();
println!("cargo:rerun-if-changed=test/piggie.c");
}
14 changes: 14 additions & 0 deletions rust-criu-protobuf/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "rust-criu-protobuf"
version = "0.1.0"
edition = "2021"

[dependencies]
protobuf = "3.2.0"

[build-dependencies]
protobuf-codegen = "3.2.0"

[lib]
name = "rust_criu_protobuf"
path = "src/mod.rs"
11 changes: 11 additions & 0 deletions rust-criu-protobuf/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extern crate protobuf_codegen;

fn main() {
protobuf_codegen::Codegen::new()
.includes(["proto"])
.input("proto/rpc.proto")
.out_dir("src")
.run_from_script();

println!("cargo:rerun-if-changed=proto/rpc.proto");
}
File renamed without changes.
3 changes: 3 additions & 0 deletions rust-criu-protobuf/src/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @generated

pub mod rpc;
Loading

0 comments on commit 243d352

Please sign in to comment.