aboutsummaryrefslogtreecommitdiffhomepage
path: root/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/build.rs b/build.rs
new file mode 100644
index 0000000..98d7c88
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,25 @@
+use std::env;
+use std::path::Path;
+use std::io::Write;
+
+fn main() {
+ // Generate KVM constants from the system header <linux/kvm.h>.
+
+ // Only re-run if the generation source file changed.
+ println!("cargo:rerun-if-changed=sysdeps/kvm.c");
+
+ // Input directory.
+ let sysdeps = Path::new(&env::var("CARGO_MANIFEST_DIR").unwrap()).join("sysdeps");
+
+ // Output file.
+ let kvm_constants = Path::new(&env::var("OUT_DIR").unwrap()).join("kvm_constants.rs");
+
+ // Run make to generate the output file.
+ let o = std::process::Command::new("make")
+ .arg("-C")
+ .arg(sysdeps.to_str().unwrap())
+ .arg(format!("OUT={}", kvm_constants.display()))
+ .output()
+ .unwrap();
+ std::io::stdout().write_all(&o.stdout).unwrap();
+}