-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.rs
More file actions
84 lines (71 loc) · 2.82 KB
/
Copy pathbuild.rs
File metadata and controls
84 lines (71 loc) · 2.82 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
fn main() {
build::main();
}
#[cfg(not(feature = "bundled"))]
mod build {
use std::env;
pub fn main() {
if let Ok(dir) = env::var("LAME_LIB_DIR") {
println!("cargo:rustc-link-search=native={}", dir);
}
if env::var("LAME_STATIC").is_ok() {
println!("cargo:rustc-link-lib=static=mp3lame");
} else {
println!("cargo:rustc-link-lib=dylib=mp3lame");
}
}
}
#[cfg(feature = "bundled")]
mod build {
extern crate gcc;
use std::env;
pub fn main() {
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS not set");
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH not set");
let mut config = gcc::Config::new();
config.file("lame-3.99.5/libmp3lame/bitstream.c")
.file("lame-3.99.5/libmp3lame/encoder.c")
.file("lame-3.99.5/libmp3lame/fft.c")
.file("lame-3.99.5/libmp3lame/gain_analysis.c")
.file("lame-3.99.5/libmp3lame/id3tag.c")
.file("lame-3.99.5/libmp3lame/lame.c")
.file("lame-3.99.5/libmp3lame/mpglib_interface.c") //Perhaps remove
.file("lame-3.99.5/libmp3lame/newmdct.c")
.file("lame-3.99.5/libmp3lame/presets.c")
.file("lame-3.99.5/libmp3lame/psymodel.c")
.file("lame-3.99.5/libmp3lame/quantize_pvt.c")
.file("lame-3.99.5/libmp3lame/quantize.c")
.file("lame-3.99.5/libmp3lame/reservoir.c")
.file("lame-3.99.5/libmp3lame/set_get.c")
.file("lame-3.99.5/libmp3lame/tables.c")
.file("lame-3.99.5/libmp3lame/takehiro.c")
.file("lame-3.99.5/libmp3lame/util.c")
.file("lame-3.99.5/libmp3lame/vbrquantize.c")
.file("lame-3.99.5/libmp3lame/VbrTag.c")
.file("lame-3.99.5/libmp3lame/version.c")
.include("lame-3.99.5/include")
.include("lame-3.99.5/libmp3lame")
.define("HAVE_CONFIG_H", None)
.define("PIC", None);
if target_os == "windows" {
config.define("TAKEHIRO_IEEE754_HACK", None)
.define("FLOAT8", Some("float"))
.define("REAL_IS_FLOAT", Some("1"))
.define("BS_FORMAT", Some("BINARY"));
}
let os_config_dir = match &*target_os {
"linux" => "linux",
"macos" => "mac",
"windows" => "win",
os => panic!("unsupported os {}", os),
};
let arch_config_dir = match &*target_arch {
"x86" => "ia32",
"x86_64" => "x64",
"arm" => "arm",
arch => panic!("unsupported arch {}", arch),
};
config.include(format!("lame-config/{}/{}", os_config_dir, arch_config_dir));
config.compile("libmp3lame.a");
}
}