mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-06-14 03:32:00 +08:00
ci: 完善构建流程和中国网络环境加速
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
use std::env::{self, VarError};
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
include!("bindgen.rs");
|
||||
|
||||
/// Environment variable that can be set to point to the directory containing the `videodev2.h`
|
||||
/// file to use to generate the bindings.
|
||||
const V4L2R_VIDEODEV_ENV: &str = "V4L2R_VIDEODEV2_H_PATH";
|
||||
|
||||
/// Default header file to parse if the `V4L2R_VIDEODEV2_H_PATH` environment variable is not set.
|
||||
const DEFAULT_VIDEODEV2_H_PATH: &str = "/usr/include/linux";
|
||||
/// Vendored Linux UAPI include root used for non-Android targets.
|
||||
const VENDORED_INCLUDE_DIR: &str = "include";
|
||||
|
||||
/// Wrapper file to use as input of bindgen.
|
||||
const WRAPPER_H: &str = "v4l2r_wrapper.h";
|
||||
@@ -20,29 +16,14 @@ fn main() {
|
||||
let target = env::var("TARGET").unwrap_or_default();
|
||||
let is_android = target.contains("android");
|
||||
|
||||
let default_videodev2_h_path = if is_android {
|
||||
android_sysroot().join("usr/include").display().to_string()
|
||||
let include_root = if is_android {
|
||||
android_sysroot().join("usr/include")
|
||||
} else {
|
||||
DEFAULT_VIDEODEV2_H_PATH.to_string()
|
||||
PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("`CARGO_MANIFEST_DIR` is not set"))
|
||||
.join(VENDORED_INCLUDE_DIR)
|
||||
};
|
||||
let videodev2_h = include_root.join("linux/videodev2.h");
|
||||
|
||||
let videodev2_h_path = env::var(V4L2R_VIDEODEV_ENV)
|
||||
.or_else(|e| {
|
||||
if let VarError::NotPresent = e {
|
||||
Ok(default_videodev2_h_path.clone())
|
||||
} else {
|
||||
Err(e)
|
||||
}
|
||||
})
|
||||
.expect("invalid `V4L2R_VIDEODEV2_H_PATH` environment variable");
|
||||
|
||||
let videodev2_h = PathBuf::from(videodev2_h_path.clone()).join(if is_android {
|
||||
"linux/videodev2.h"
|
||||
} else {
|
||||
"videodev2.h"
|
||||
});
|
||||
|
||||
println!("cargo::rerun-if-env-changed={}", V4L2R_VIDEODEV_ENV);
|
||||
println!("cargo::rerun-if-env-changed=ANDROID_NDK_HOME");
|
||||
println!("cargo::rerun-if-env-changed=ANDROID_NDK_ROOT");
|
||||
println!("cargo::rerun-if-env-changed=NDK_HOME");
|
||||
@@ -54,7 +35,7 @@ fn main() {
|
||||
println!("cargo::rerun-if-changed={}", WRAPPER_H);
|
||||
|
||||
let mut clang_args = vec![
|
||||
format!("-I{videodev2_h_path}"),
|
||||
format!("-I{}", include_root.display()),
|
||||
#[cfg(all(feature = "arch64", not(feature = "arch32")))]
|
||||
"--target=x86_64-linux-gnu".into(),
|
||||
#[cfg(all(feature = "arch32", not(feature = "arch64")))]
|
||||
|
||||
Reference in New Issue
Block a user