Skip to content

Commit 3d50edb

Browse files
committed
Run cargo fmt
1 parent 8cf9b94 commit 3d50edb

File tree

4 files changed

+80
-54
lines changed

4 files changed

+80
-54
lines changed

build.rs

Lines changed: 70 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ use std::path::PathBuf;
1111
use std::process::Command;
1212
use std::str;
1313

14+
use bindgen::callbacks::{
15+
EnumVariantCustomBehavior, EnumVariantValue, IntKind, MacroParsingBehavior, ParseCallbacks,
16+
};
1417
use regex::Regex;
15-
use bindgen::callbacks::{EnumVariantCustomBehavior, EnumVariantValue, IntKind, ParseCallbacks, MacroParsingBehavior};
1618

1719
#[derive(Debug)]
1820
struct Library {
@@ -31,15 +33,42 @@ impl Library {
3133
}
3234

3335
static LIBRARIES: &[Library] = &[
34-
Library {name: "avcodec", is_feature: true},
35-
Library {name: "avdevice", is_feature: true},
36-
Library {name: "avfilter", is_feature: true},
37-
Library {name: "avformat", is_feature: true},
38-
Library {name: "avresample", is_feature: true},
39-
Library {name: "avutil", is_feature: false},
40-
Library {name: "postproc", is_feature: true},
41-
Library {name: "swresample", is_feature: true},
42-
Library {name: "swscale", is_feature: true},
36+
Library {
37+
name: "avcodec",
38+
is_feature: true,
39+
},
40+
Library {
41+
name: "avdevice",
42+
is_feature: true,
43+
},
44+
Library {
45+
name: "avfilter",
46+
is_feature: true,
47+
},
48+
Library {
49+
name: "avformat",
50+
is_feature: true,
51+
},
52+
Library {
53+
name: "avresample",
54+
is_feature: true,
55+
},
56+
Library {
57+
name: "avutil",
58+
is_feature: false,
59+
},
60+
Library {
61+
name: "postproc",
62+
is_feature: true,
63+
},
64+
Library {
65+
name: "swresample",
66+
is_feature: true,
67+
},
68+
Library {
69+
name: "swscale",
70+
is_feature: true,
71+
},
4372
];
4473

4574
#[derive(Debug)]
@@ -52,11 +81,13 @@ impl ParseCallbacks for Callbacks {
5281
let codec_flag = Regex::new(r"^AV_CODEC_FLAG").unwrap();
5382
let error_max_size = Regex::new(r"^AV_ERROR_MAX_STRING_SIZE").unwrap();
5483

55-
if value >= i64::min_value() as i64 && value <= i64::max_value() as i64
84+
if value >= i64::min_value() as i64
85+
&& value <= i64::max_value() as i64
5686
&& ch_layout.is_match(_name)
5787
{
5888
Some(IntKind::ULongLong)
59-
} else if value >= i32::min_value() as i64 && value <= i32::max_value() as i64
89+
} else if value >= i32::min_value() as i64
90+
&& value <= i32::max_value() as i64
6091
&& (codec_cap.is_match(_name) || codec_flag.is_match(_name))
6192
{
6293
Some(IntKind::UInt)
@@ -132,13 +163,13 @@ fn search() -> PathBuf {
132163

133164
fn fetch() -> io::Result<()> {
134165
let status = Command::new("git")
135-
.current_dir(&output())
136-
.arg("clone")
137-
.arg("-b")
138-
.arg(format!("release/{}", version()))
139-
.arg("https://github.com/FFmpeg/FFmpeg")
140-
.arg(format!("ffmpeg-{}", version()))
141-
.status()?;
166+
.current_dir(&output())
167+
.arg("clone")
168+
.arg("-b")
169+
.arg(format!("release/{}", version()))
170+
.arg("https://github.com/FFmpeg/FFmpeg")
171+
.arg(format!("ffmpeg-{}", version()))
172+
.status()?;
142173

143174
if status.success() {
144175
Ok(())
@@ -150,8 +181,7 @@ fn fetch() -> io::Result<()> {
150181
fn switch(configure: &mut Command, feature: &str, name: &str) {
151182
let arg = if env::var("CARGO_FEATURE_".to_string() + feature).is_ok() {
152183
"--enable-"
153-
}
154-
else {
184+
} else {
155185
"--disable-"
156186
};
157187
configure.arg(arg.to_string() + name);
@@ -185,11 +215,11 @@ fn build() -> io::Result<()> {
185215
configure.arg("--disable-programs");
186216

187217
macro_rules! enable {
188-
($conf:expr, $feat:expr, $name:expr) => (
218+
($conf:expr, $feat:expr, $name:expr) => {
189219
if env::var(concat!("CARGO_FEATURE_", $feat)).is_ok() {
190220
$conf.arg(concat!("--enable-", $name));
191221
}
192-
)
222+
};
193223
}
194224

195225
// macro_rules! disable {
@@ -294,21 +324,21 @@ fn build() -> io::Result<()> {
294324

295325
// run make
296326
if !Command::new("make")
297-
.arg("-j")
298-
.arg(num_cpus::get().to_string())
299-
.current_dir(&source())
300-
.status()?
301-
.success()
327+
.arg("-j")
328+
.arg(num_cpus::get().to_string())
329+
.current_dir(&source())
330+
.status()?
331+
.success()
302332
{
303333
return Err(io::Error::new(io::ErrorKind::Other, "make failed"));
304334
}
305335

306336
// run make install
307337
if !Command::new("make")
308-
.current_dir(&source())
309-
.arg("install")
310-
.status()?
311-
.success()
338+
.current_dir(&source())
339+
.arg("install")
340+
.status()?
341+
.success()
312342
{
313343
return Err(io::Error::new(io::ErrorKind::Other, "make install failed"));
314344
}
@@ -386,7 +416,8 @@ fn check_features(
386416
"#,
387417
includes_code = includes_code,
388418
main_code = main_code
389-
).expect("Write failed");
419+
)
420+
.expect("Write failed");
390421

391422
let executable = out_dir.join(if cfg!(windows) { "check.exe" } else { "check" });
392423
let mut compiler = cc::Build::new().get_compiler().to_command();
@@ -481,8 +512,7 @@ fn search_include(include_paths: &Vec<PathBuf>, header: &str) -> String {
481512
fn link_to_libraries(statik: bool) {
482513
let ffmpeg_ty = if statik { "static" } else { "dylib" };
483514
for lib in LIBRARIES {
484-
let feat_is_enabled =
485-
lib.feature_name().and_then(|f| env::var(&f).ok()).is_some();
515+
let feat_is_enabled = lib.feature_name().and_then(|f| env::var(&f).ok()).is_some();
486516
if !lib.is_feature || feat_is_enabled {
487517
println!("cargo:rustc-link-lib={}={}", ffmpeg_ty, lib.name);
488518
}
@@ -567,7 +597,7 @@ fn main() {
567597
.unwrap()
568598
.include_paths;
569599
}
570-
};
600+
}
571601

572602
pkg_config::Config::new()
573603
.statik(statik)
@@ -1018,9 +1048,10 @@ fn main() {
10181048
}
10191049

10201050
// Finish the builder and generate the bindings.
1021-
let bindings = builder.generate()
1022-
// Unwrap the Result and panic on failure.
1023-
.expect("Unable to generate bindings");
1051+
let bindings = builder
1052+
.generate()
1053+
// Unwrap the Result and panic on failure.
1054+
.expect("Unable to generate bindings");
10241055

10251056
// Write the bindings to the $OUT_DIR/bindings.rs file.
10261057
bindings

src/avutil/error.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ pub fn AVUNERROR(e: c_int) -> c_int {
1111
}
1212

1313
macro_rules! FFERRTAG {
14-
($a:expr, $b:expr, $c:expr, $d:expr) =>
15-
(-MKTAG!($a, $b, $c, $d) as c_int)
14+
($a:expr, $b:expr, $c:expr, $d:expr) => {
15+
-MKTAG!($a, $b, $c, $d) as c_int
16+
};
1617
}
1718

1819
pub const AVERROR_BSF_NOT_FOUND: c_int = FFERRTAG!(0xF8, b'B', b'S', b'F');

src/avutil/macros.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
#[macro_export]
22
macro_rules! MKBETAG {
3-
($a:expr, $b:expr, $c:expr, $d:expr) => (
4-
($d as isize) |
5-
(($c as isize) << 8) |
6-
(($b as isize) << 16) |
7-
(($a as isize) << 24)
8-
)
3+
($a:expr, $b:expr, $c:expr, $d:expr) => {
4+
($d as isize) | (($c as isize) << 8) | (($b as isize) << 16) | (($a as isize) << 24)
5+
};
96
}
107

118
#[macro_export]
129
macro_rules! MKTAG {
13-
($a:expr, $b:expr, $c:expr, $d:expr) => (
14-
($a as isize) |
15-
(($b as isize) << 8) |
16-
(($c as isize) << 16) |
17-
(($d as isize) << 24)
18-
)
10+
($a:expr, $b:expr, $c:expr, $d:expr) => {
11+
($a as isize) | (($b as isize) << 8) | (($c as isize) << 16) | (($d as isize) << 24)
12+
};
1913
}

src/avutil/rational.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use AVRational;
21
use libc::{c_double, c_int};
2+
use AVRational;
33

44
#[inline(always)]
55
pub unsafe fn av_make_q(num: c_int, den: c_int) -> AVRational {

0 commit comments

Comments
 (0)