mirror of
https://github.com/rustdesk/magnum-opus.git
synced 2026-02-16 02:20:47 +00:00
android support
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "magnum-opus"
|
||||
version = "0.3.3"
|
||||
version = "0.3.4"
|
||||
authors = ["Tad Hardesty <tad@platymuus.com>", "Sergey Duck <sergeypechnikov326@gmail.com>"]
|
||||
edition = "2018"
|
||||
description = "Safe Rust bindings for libopus"
|
||||
@@ -14,6 +14,5 @@ repository = "https://github.com/DuckerMan/magnum-opus"
|
||||
documentation = "https://docs.rs/magnum-opus"
|
||||
|
||||
[build-dependencies]
|
||||
vcpkg = "0.2"
|
||||
target_build_utils = "0.3"
|
||||
bindgen = "0.53"
|
||||
|
||||
58
build.rs
58
build.rs
@@ -3,26 +3,44 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
fn find_package(name: &str) -> vcpkg::Library {
|
||||
let mut cfg = vcpkg::Config::new();
|
||||
cfg.emit_includes(true);
|
||||
let mut res = cfg.find_package(name);
|
||||
if res.is_err() {
|
||||
let target = {
|
||||
if cfg!(windows) {
|
||||
":x64-windows-static"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
};
|
||||
std::process::Command::new("vcpkg")
|
||||
.arg("install")
|
||||
.arg(format!("{}{}", name, target))
|
||||
.status()
|
||||
.unwrap();
|
||||
res = cfg.find_package(name);
|
||||
fn find_package(name: &str) -> Vec<PathBuf> {
|
||||
let vcpkg_root = std::env::var("VCPKG_ROOT").unwrap();
|
||||
let mut path: PathBuf = vcpkg_root.into();
|
||||
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
|
||||
let mut target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||
if target_arch == "x86_64" {
|
||||
target_arch = "x64".to_owned();
|
||||
} else if target_arch == "aarch64" {
|
||||
target_arch = "arm64".to_owned();
|
||||
} else {
|
||||
target_arch = "arm".to_owned();
|
||||
}
|
||||
res.unwrap()
|
||||
let target = if target_os == "macos" {
|
||||
"x64-osx".to_owned()
|
||||
} else if target_os == "windows" {
|
||||
"x64-windows-static".to_owned()
|
||||
} else if target_os == "android" {
|
||||
format!("{}-android-static", target_arch)
|
||||
} else {
|
||||
"x64-linux".to_owned()
|
||||
};
|
||||
println!("cargo:info={}", target);
|
||||
path.push("installed");
|
||||
path.push(target);
|
||||
println!(
|
||||
"{}",
|
||||
format!("cargo:rustc-link-lib={}", name.trim_start_matches("lib"))
|
||||
);
|
||||
println!(
|
||||
"{}",
|
||||
format!(
|
||||
"cargo:rustc-link-search={}",
|
||||
path.join("lib").to_str().unwrap()
|
||||
)
|
||||
);
|
||||
let include = path.join("include");
|
||||
println!("{}", format!("cargo:include={}", include.to_str().unwrap()));
|
||||
vec![include]
|
||||
}
|
||||
|
||||
fn generate_bindings(ffi_header: &Path, include_paths: &[PathBuf], ffi_rs: &Path) {
|
||||
@@ -50,7 +68,7 @@ fn generate_bindings(ffi_header: &Path, include_paths: &[PathBuf], ffi_rs: &Path
|
||||
}
|
||||
|
||||
fn gen_opus() {
|
||||
let includes = find_package("opus").include_paths;
|
||||
let includes = find_package("opus");
|
||||
let src_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap();
|
||||
let src_dir = Path::new(&src_dir);
|
||||
let out_dir = env::var_os("OUT_DIR").unwrap();
|
||||
|
||||
Reference in New Issue
Block a user