forked from containers/containrs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
29 lines (25 loc) · 793 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use anyhow::{Context, Result};
use cbindgen::{Builder, Language};
use std::{env, path::PathBuf};
const PROTO_FILE: &str = "src/kubernetes/cri/proto/criapi.proto";
fn main() -> Result<()> {
tonic_build::configure()
.out_dir("src/kubernetes/cri/api")
.compile(
&[PROTO_FILE],
&[&PathBuf::from(PROTO_FILE)
.parent()
.context("no path parent")?
.display()
.to_string()],
)
.context("compile CRI protocol buffers")?;
Builder::new()
.with_crate(env::var("CARGO_MANIFEST_DIR")?)
.with_language(Language::C)
.with_pragma_once(true)
.generate()
.context("generate bindings")?
.write_to_file("src/ffi/ffi.h");
Ok(())
}