refact: suppress warns on macos (#12449)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2025-08-18 15:09:11 +08:00
committed by GitHub
parent bf24869c6a
commit a22f2108c6
20 changed files with 150 additions and 82 deletions

View File

@@ -239,6 +239,24 @@ fn ffmpeg() {
*/
fn main() {
// there is problem with cfg(target_os) in build.rs, so use our workaround
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
// We check if is macos, because macos uses rust 1.8.1.
// `cargo::rustc-check-cfg` is new with Cargo 1.80.
// No need to run `cargo version` to get the version here, because:
// The following lines are used to suppress the lint warnings.
// warning: unexpected `cfg` condition name: `quartz`
if cfg!(target_os = "macos") {
if target_os != "ios" {
println!("cargo::rustc-check-cfg=cfg(android)");
println!("cargo::rustc-check-cfg=cfg(dxgi)");
println!("cargo::rustc-check-cfg=cfg(quartz)");
println!("cargo::rustc-check-cfg=cfg(x11)");
// ^^^^^^^^^^^^^^^^^^^^^^ new with Cargo 1.80
}
}
// note: all link symbol names in x86 (32-bit) are prefixed wth "_".
// run "rustup show" to show current default toolchain, if it is stable-x86-pc-windows-msvc,
// please install x64 toolchain by "rustup toolchain install stable-x86_64-pc-windows-msvc",
@@ -256,8 +274,6 @@ fn main() {
gen_vcpkg_package("libyuv", "yuv_ffi.h", "yuv_ffi.rs", ".*");
// ffmpeg();
// there is problem with cfg(target_os) in build.rs, so use our workaround
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
if target_os == "ios" {
// nothing
} else if target_os == "android" {

View File

@@ -17,7 +17,9 @@ use hbb_common::message_proto::{DisplayInfo, Resolution};
use crate::AdapterDevice;
use crate::common::{bail, ResultType};
use crate::{Frame, PixelBuffer, Pixfmt, TraitCapturer};
use crate::{Frame, TraitCapturer};
#[cfg(any(target_os = "windows", target_os = "linux"))]
use crate::{PixelBuffer, Pixfmt};
pub const PRIMARY_CAMERA_IDX: usize = 0;
lazy_static::lazy_static! {
@@ -162,11 +164,11 @@ impl Cameras {
return Ok(Vec::new());
}
pub fn exists(index: usize) -> bool {
pub fn exists(_index: usize) -> bool {
false
}
pub fn get_camera_resolution(index: usize) -> ResultType<Resolution> {
pub fn get_camera_resolution(_index: usize) -> ResultType<Resolution> {
bail!(CAMERA_NOT_SUPPORTED);
}
@@ -174,7 +176,7 @@ impl Cameras {
vec![]
}
pub fn get_capturer(current: usize) -> ResultType<Box<dyn TraitCapturer>> {
pub fn get_capturer(_current: usize) -> ResultType<Box<dyn TraitCapturer>> {
bail!(CAMERA_NOT_SUPPORTED);
}
}
@@ -201,6 +203,7 @@ impl CameraCapturer {
})
}
#[allow(dead_code)]
#[cfg(not(any(target_os = "windows", target_os = "linux")))]
fn new(_current: usize) -> ResultType<Self> {
bail!(CAMERA_NOT_SUPPORTED);

View File

@@ -18,10 +18,17 @@ use crate::{
CodecFormat, EncodeInput, EncodeYuvFormat, ImageRgb, ImageTexture,
};
#[cfg(any(
feature = "hwcodec",
feature = "mediacodec",
feature = "vram",
target_os = "windows"
))]
use hbb_common::config::option2bool;
use hbb_common::{
anyhow::anyhow,
bail,
config::{option2bool, Config, PeerConfig},
config::{Config, PeerConfig},
lazy_static, log,
message_proto::{
supported_decoding::PreferCodec, video_frame, Chroma, CodecAbility, EncodedVideoFrames,