This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
57 lines (57 loc) · 1.95 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
46
47
48
49
50
51
52
53
54
55
56
57
fn main() -> std::io::Result<()> {
{
let cargo_manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
println!("cargo:rerun-if-changed={cargo_manifest_dir}/src/x264.h",);
println!("cargo:rustc-link-search=native={cargo_manifest_dir}/x264/");
println!("cargo:rustc-link-lib=static=x264");
if !std::process::Command::new("/bin/bash")
.args([
"configure",
"--disable-cli",
"--enable-static",
"--disable-interlaced",
"--bit-depth=8",
"--enable-lto",
"--enable-strip",
"--disable-avs",
"--disable-swscale",
"--disable-lavf",
"--disable-ffms",
"--disable-gpac",
"--disable-lsmash",
])
.current_dir("x264")
.status()
.expect("Failed to spawn '/bin/bash configure' for x264")
.success()
{
panic!("Failed to configure x264");
}
if !std::process::Command::new("make")
.args(["clean"])
.current_dir("x264")
.status()
.expect("Failed to spawn 'make clean' for x264")
.success()
{
panic!("Failed to make clean x264");
}
if !std::process::Command::new("make")
.current_dir("x264")
.status()
.expect("Failed to spawn 'make' for x264")
.success()
{
panic!("Failed to make x264");
}
let bindings = bindgen::Builder::default()
.header("src/x264.h")
.generate()
.expect("Unable to generate bindings");
let out_path = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("x264_bindings.rs"))
.expect("Couldn't write bindings");
}
Ok(())
}