-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.rs
45 lines (32 loc) · 1.1 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::env;
use std::path::PathBuf;
const CDIO_HEADER: &str = "#include <cdio/cdio.h>
#include <cdio/cd_types.h>
#include <cdio/logging.h>
#include <cdio/mmc_cmds.h>
#include <cdio/utf8.h>\n";
const ISO9660_HEADER: &str = "#include <cdio/iso9660.h>\n";
const UDF_HEADER: &str = "#include <cdio/udf.h>\n";
fn main() {
let mut header = String::new();
#[cfg(feature = "cdio")]
header.push_str(CDIO_HEADER);
#[cfg(feature = "iso9660")]
header.push_str(ISO9660_HEADER);
#[cfg(feature = "udf")]
header.push_str(UDF_HEADER);
#[cfg(feature = "cdio")]
println!("cargo:rustc-link-lib=cdio");
#[cfg(feature = "iso9660")]
println!("cargo:rustc-link-lib=iso9660");
#[cfg(feature = "udf")]
println!("cargo:rustc-link-lib=udf");
let bindings = bindgen::Builder::default()
.header_contents("wrapper.h", header.as_str())
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
}