Skip to content

Commit

Permalink
Merge pull request #16 from adrianreber/2023-01-17-crates.io
Browse files Browse the repository at this point in the history
Another try to make rust-criu work with crates.io
  • Loading branch information
adrianreber authored Jan 19, 2023
2 parents 4b1b5da + 9ef9c5a commit c10a2a3
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ jobs:
- name: Run fmt
run: cargo fmt --all -- --check

- name: Build with generate enabled
run: GENERATE_PROTOBUF=1 GENERATE_TEST_PROCESS=1 cargo build --verbose

- name: Run tests
run: sudo target/debug/rust-criu-test criu/criu/criu
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ license-file = "LICENSE"
libc = "0.2"
anyhow = "1.0.56"
protobuf = "3.2.0"
rust-criu-protobuf = { path = "rust-criu-protobuf" }

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

[lib]
name = "rust_criu"
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,19 @@

`rust-criu` provides an interface to use [CRIU](https://criu.org/) in the
same way as [go-criu](https://github.com/checkpoint-restore/go-criu) does.

## Generate protobuf bindings

The CRIU RPC protobuf bindings are pre-generated and part of the rust-criu
repository. The bindings can be re-generated with
```shell
$ GENERATE_PROTOBUF=1 cargo build
```

## Run tests

To run the included tests please use the following command to build `rust-criu`:
```
$ GENERATE_TEST_PROCESS=1 cargo build
$ sudo target/debug/rust-criu-test /path/to/criu/binary
```
23 changes: 19 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
extern crate protobuf_codegen;

fn main() {
std::process::Command::new("gcc")
.args(["test/piggie.c", "-o", "test/piggie"])
.status()
.unwrap();
if std::env::var_os("GENERATE_PROTOBUF").is_some() {
protobuf_codegen::Codegen::new()
.includes(["proto"])
.input("proto/rpc.proto")
.out_dir("src/rust_criu_protobuf")
.run_from_script();
}

if std::env::var_os("GENERATE_TEST_PROCESS").is_some() {
std::process::Command::new("gcc")
.args(["test/piggie.c", "-o", "test/piggie"])
.status()
.unwrap();
}
println!("cargo:rerun-if-changed=test/piggie.c");
println!("cargo:rerun-if-changed=proto/rpc.proto");
println!("cargo:rerun-if-env-changed=GENERATE_PROTOBUF");
println!("cargo:rerun-if-env-changed=GENERATE_TEST_PROCESS");
}
File renamed without changes.
14 changes: 0 additions & 14 deletions rust-criu-protobuf/Cargo.toml

This file was deleted.

11 changes: 0 additions & 11 deletions rust-criu-protobuf/build.rs

This file was deleted.

2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
mod rust_criu_protobuf;

use anyhow::{Context, Result};
use protobuf::Message;
use rust_criu_protobuf::rpc;
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit c10a2a3

Please sign in to comment.