From 6629a11f73315c6ca622f7654f3700c1019c75e8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 1 Jun 2024 01:18:15 +0200 Subject: [PATCH] more docs for the build.rs file --- examples/build.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/build.rs b/examples/build.rs index b139e49..f2a7442 100644 --- a/examples/build.rs +++ b/examples/build.rs @@ -8,21 +8,31 @@ fn main() { let manifest_path = PathBuf::from(&manifest_dir); let lib_cfg_dir = "../lib/cfg/csp"; let libcsp_path = "../lib/libcsp"; + + // This helper structure will take care of the majority of work to compile libcsp using the + // cc crate. let mut csp_builder = Builder::new(PathBuf::from(libcsp_path), PathBuf::from(&out_dir)); + // A lot of spam we are not interested in usually. csp_builder.compiler_warnings = false; + // We always re-generate the header file. generate_autoconf_header_file(manifest_path.clone(), &csp_builder.cfg) .expect("generating header file failed"); + // Copy the file to lib/csp/cfg as well for binding generation. std::fs::copy( manifest_path.join("autoconfig.h"), PathBuf::from(&lib_cfg_dir).join("autoconfig.h"), ) .expect("copying autoconfig.h failed"); + + // This file is required for the compile-time configuration of libcsp-rust. csp_builder .generate_autoconf_rust_file(manifest_path) .expect("generating autoconfig.rs failed"); + csp_builder.compile().expect("compiling libcsp failed"); + // If we change the libcsp build configuration, we need to re-run the build. println!("cargo::rerun-if-changed=build.rs"); }