Skip to content

Commit

Permalink
build: Use make in build.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundmiller committed Jan 9, 2024
1 parent a32d6ee commit 7bf2eb9
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
use std::path::Path;
use std::process::Command;

fn main() -> miette::Result<()> {
let include_dir = Path::new("src/include/");
println!("cargo:rerun-if-changed=Makefile");
let status = Command::new("make")
.args(&["clean"])
.status()
.expect("failed to run \"make clean\"");
assert!(status.success());

let path = std::path::PathBuf::from("src"); // include path
let mut b = autocxx_build::Builder::new("src/main.rs", &[&path]).build()?;
b.std("c++17")
.cpp_set_stdlib("stdc++")
.include(include_dir)
.file("src/dragen-os.cpp")
.compile("dragen-os"); // arbitrary library name, pick anything
println!("cargo:rerun-if-changed=src/main.rs");
println!("cargo:rerun-if-changed=src/dragen-os.cpp");
// build dragen-os command and dragen static library
let status = Command::new("make")
.status()
.expect("failed to run \"make\"");
assert!(status.success());
// Add instructions to link to any C++ libraries you need.
Ok(())
}

0 comments on commit 7bf2eb9

Please sign in to comment.