1use std::{
2 env,
3 path::{Path, PathBuf},
4};
5
6mod c_files;
7
8pub const LIBXML2: &str = "libxml2-2.10.3";
9
10pub struct Source {
11 pub root: PathBuf,
12 pub include: PathBuf,
13}
14
15pub fn build_lib() -> Source {
16 let vendor = source_dir();
17 let libxml2 = vendor.join(LIBXML2);
18 let include = libxml2.join("include");
19
20 println!("cargo:include={}", include.to_str().unwrap());
21
22 cc::Build::new()
23 .define("HAVE_CONFIG_H", None)
24 .define("_REENTRANT", None)
25 .flag_if_supported("-pedantic")
26 .flag_if_supported("-Wno-unused-but-set-variable")
27 .include(&include)
28 .files(c_files::C_FILES)
29 .compile("xml2");
30
31 Source {
32 root: libxml2,
33 include,
34 }
35}
36
37fn source_dir() -> PathBuf {
38 dunce::canonicalize(Path::new(env!("CARGO_MANIFEST_DIR")).join("vendor")).unwrap()
39}