mirror of
https://github.com/rustdesk/magnum-opus.git
synced 2025-07-01 15:25:27 +00:00
Merge pull request #1 from selfisekai/pkg-config
add linux-pkg-config feature
This commit is contained in:
commit
5cd2bf989c
@ -13,6 +13,10 @@ categories = ["api-bindings", "encoding", "compression",
|
|||||||
repository = "https://github.com/DuckerMan/magnum-opus"
|
repository = "https://github.com/DuckerMan/magnum-opus"
|
||||||
documentation = "https://docs.rs/magnum-opus"
|
documentation = "https://docs.rs/magnum-opus"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
linux-pkg-config = ["dep:pkg-config"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
target_build_utils = "0.3"
|
target_build_utils = "0.3"
|
||||||
bindgen = "0.59"
|
bindgen = "0.59"
|
||||||
|
pkg-config = { version = "0.3.27", optional = true }
|
||||||
|
18
build.rs
18
build.rs
@ -3,6 +3,17 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(all(target_os = "linux", feature = "linux-pkg-config"))]
|
||||||
|
fn link_pkg_config(name: &str) -> Vec<PathBuf> {
|
||||||
|
let lib = pkg_config::probe_library(name)
|
||||||
|
.expect(format!(
|
||||||
|
"unable to find '{name}' development headers with pkg-config (feature linux-pkg-config is enabled).
|
||||||
|
try installing '{name}-dev' from your system package manager.").as_str());
|
||||||
|
|
||||||
|
lib.include_paths
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(all(target_os = "linux", feature = "linux-pkg-config")))]
|
||||||
fn link_vcpkg(mut path: PathBuf, name: &str) -> PathBuf {
|
fn link_vcpkg(mut path: PathBuf, name: &str) -> PathBuf {
|
||||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||||
let mut target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
let mut target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||||
@ -45,6 +56,7 @@ fn link_vcpkg(mut path: PathBuf, name: &str) -> PathBuf {
|
|||||||
include
|
include
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(not(all(target_os = "linux", feature = "linux-pkg-config")))]
|
||||||
fn link_homebrew_m1(name: &str) -> PathBuf {
|
fn link_homebrew_m1(name: &str) -> PathBuf {
|
||||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||||
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||||
@ -95,6 +107,12 @@ fn link_homebrew_m1(name: &str) -> PathBuf {
|
|||||||
include
|
include
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(all(target_os = "linux", feature = "linux-pkg-config"))]
|
||||||
|
fn find_package(name: &str) -> Vec<PathBuf> {
|
||||||
|
return link_pkg_config(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(all(target_os = "linux", feature = "linux-pkg-config")))]
|
||||||
fn find_package(name: &str) -> Vec<PathBuf> {
|
fn find_package(name: &str) -> Vec<PathBuf> {
|
||||||
if let Ok(vcpkg_root) = std::env::var("VCPKG_ROOT") {
|
if let Ok(vcpkg_root) = std::env::var("VCPKG_ROOT") {
|
||||||
vec![link_vcpkg(vcpkg_root.into(), name)]
|
vec![link_vcpkg(vcpkg_root.into(), name)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user