automerge/automerge-c/build.rs
Jason Kankiewicz 3ddde2fff2 Normalize the header include statement for all C
source files.
Normalize the header include statement within the documentation.
Limit `AMpush()` usage within the quickstart example to variable
assignment.
2022-08-22 22:28:23 -07:00

21 lines
794 B
Rust

extern crate cbindgen;
use std::{env, path::PathBuf};
fn main() {
let crate_dir = PathBuf::from(
env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR env var is not defined"),
);
let config = cbindgen::Config::from_file("cbindgen.toml")
.expect("Unable to find cbindgen.toml configuration file");
if let Ok(writer) = cbindgen::generate_with_config(&crate_dir, config) {
// \note CMake sets this environment variable before invoking Cargo so
// that it can direct the generated header file into its
// out-of-source build directory for post-processing.
if let Ok(target_dir) = env::var("CBINDGEN_TARGET_DIR") {
writer.write_to_file(PathBuf::from(target_dir).join("automerge.h"));
}
}
}