Skip to main content

cargo_php_sys_build/
build_files.rs

1use std::{env, fs::File, io::Write, path::PathBuf};
2
3pub static CHECK_C: &[u8] = include_bytes!("check.c");
4pub static WRAPPER_H: &[u8] = include_bytes!("wrapper.h");
5
6fn output_file(filename: &str, contents: &[u8]) -> anyhow::Result<PathBuf> {
7    let out_path = PathBuf::from(env::var("OUT_DIR")?).join(filename);
8    File::create(&out_path)?.write_all(contents)?;
9    Ok(out_path)
10}
11
12pub fn render_check_c() -> anyhow::Result<PathBuf> {
13    output_file("check.c", CHECK_C)
14}
15
16pub fn render_wrapper_h() -> anyhow::Result<PathBuf> {
17    output_file("wrapper.h", WRAPPER_H)
18}