Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
google
GitHub Repository: google/crosvm
Path: blob/main/media/ffmpeg/build.rs
5394 views
1
// Copyright 2022 The ChromiumOS Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
use std::path::PathBuf;
6
7
use pkg_config::Config;
8
9
fn main() {
10
// Skip building dependencies when generating documents.
11
if std::env::var("CARGO_DOC").is_ok() {
12
return;
13
}
14
15
// ffmpeg is currently only supported on unix
16
if std::env::var("CARGO_CFG_UNIX").is_err() {
17
return;
18
}
19
20
// ffmgeg is not supported by CI on 32-bit arm
21
if std::env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "arm" {
22
return;
23
}
24
25
// Match all ffmpeg 6.0+ versions.
26
Config::new()
27
.atleast_version("60")
28
.probe("libavcodec")
29
.unwrap();
30
Config::new()
31
.atleast_version("58")
32
.probe("libavutil")
33
.unwrap();
34
Config::new()
35
.atleast_version("7")
36
.probe("libswscale")
37
.unwrap();
38
39
let bindings = bindgen::Builder::default()
40
.header("src/bindings.h")
41
.allowlist_function("av_.*")
42
.allowlist_function("avcodec_.*")
43
.allowlist_function("sws_.*")
44
.allowlist_function("av_image_.*")
45
.allowlist_var("AV_PROFILE.*")
46
.allowlist_var("AV_.*")
47
.allowlist_var("AVERROR_.*")
48
// Skip va_list and functions that use it to avoid ABI problems on aarch64.
49
.blocklist_type(".*va_list.*")
50
.blocklist_function("av_log_.*")
51
.blocklist_function("av_vlog")
52
.generate()
53
.expect("failed to generate bindings");
54
let out_path = PathBuf::from(std::env::var("OUT_DIR").unwrap());
55
bindings
56
.write_to_file(out_path.join("bindings.rs"))
57
.expect("writing bindings to file failed");
58
}
59
60