use std::{
env, fs,
io::Write as _,
path::{Path, PathBuf},
};
struct Build {
cfg: cc::Build,
is_msvc: bool,
}
impl Build {
fn new(cfg: cc::Build) -> Self {
let is_msvc = cfg.try_get_compiler().unwrap().is_like_msvc();
Self { cfg, is_msvc }
}
fn append(&mut self, root: Option<&str>, files: &[&str]) {
let root = root.map_or(String::new(), |s| {
assert!(!s.ends_with('/'), "remove trailing slash");
format!("{s}/")
});
self.cfg.files(
files
.into_iter()
.map(|fname| format!("src/zlib-ng/{root}{fname}.c")),
);
}
fn mflag(
&mut self,
non_msvc: impl Into