zbq-sys 0.1.1

SPMC zero-copy IPC queue
Documentation
use std::env;
use std::fs;
use std::path::PathBuf;

fn main() {
    let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());

    // Write a small C wrapper that pulls in the implementation.
    let wrapper = out_dir.join("zbq_impl.c");
    fs::write(
        &wrapper,
        concat!(
            "#define _GNU_SOURCE\n",
            "#define ZBQ_IMPLEMENTATION\n",
            "#include <zbq.h>\n",
        ),
    )
    .expect("failed to write zbq_impl.c");

    // zbq.h lives at ../../zbq/zbq.h relative to this crate root.
    let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());

    println!(
        "cargo:rerun-if-changed={}",
        manifest_dir.join("zbq.h").display()
    );

    cc::Build::new()
        .file(&wrapper)
        .include(&manifest_dir)
        .opt_level(3)
        .compile("zbq_impl");
}