From 7bf2eb9fcd345dae1634ad323c74b32fcc175838 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Tue, 9 Jan 2024 12:39:32 -0600 Subject: [PATCH] build: Use make in build.rs Duh Examples: https://github.com/rust-fuzz/honggfuzz-rs/blob/912092c1f14a505d180d888894e895a5baed4839/build.rs#L9 https://github.com/avr-rust/libc/blob/1e3ce441d1a1839ac20213d8af42ae4ac4bdf528/build.rs#L57 https://github.com/glandium/git-cinnabar/blob/4c91b281ba237cab75484dcc1bf6c20ce6123e3e/build.rs Thinking this could be a build step in nix or something too --- build.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/build.rs b/build.rs index 9183ed9..426bd69 100644 --- a/build.rs +++ b/build.rs @@ -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(()) }