Fix buildscripts

* Fix FDroid build on x86
  * Fix CI build on arm
  * Rename `install_oboe` to `install_android_deps`

... because we add ndk_compat and the function installs
android-specific dependencies.

Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
This commit is contained in:
Vasyl Gello 2023-11-01 11:37:39 +02:00
parent 82b7650458
commit 9f4a844c9b
3 changed files with 11 additions and 12 deletions

View file

@ -180,8 +180,8 @@ def generate_build_script_for_docker():
export VCPKG_ROOT=`pwd`/vcpkg export VCPKG_ROOT=`pwd`/vcpkg
git clone https://github.com/microsoft/vcpkg git clone https://github.com/microsoft/vcpkg
vcpkg/bootstrap-vcpkg.sh vcpkg/bootstrap-vcpkg.sh
vcpkg/vcpkg install libvpx libyuv opus
popd popd
$VCPKG_ROOT/vcpkg install --x-install-root="$VCPKG_ROOT/installed"
# build rustdesk # build rustdesk
./build.py --flutter --hwcodec ./build.py --flutter --hwcodec
''') ''')

View file

@ -41,7 +41,7 @@ fn build_manifest() {
} }
} }
fn install_oboe() { fn install_android_deps() {
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
if target_os != "android" { if target_os != "android" {
return; return;
@ -49,6 +49,8 @@ fn install_oboe() {
let mut target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap(); let mut target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
if target_arch == "x86_64" { if target_arch == "x86_64" {
target_arch = "x64".to_owned(); target_arch = "x64".to_owned();
} else if target_arch == "x86" {
target_arch = "x86".to_owned();
} else if target_arch == "aarch64" { } else if target_arch == "aarch64" {
target_arch = "arm64".to_owned(); target_arch = "arm64".to_owned();
} else { } else {
@ -66,22 +68,15 @@ fn install_oboe() {
path.join("lib").to_str().unwrap() path.join("lib").to_str().unwrap()
) )
); );
println!("cargo:rustc-link-lib=ndk_compat");
println!("cargo:rustc-link-lib=oboe"); println!("cargo:rustc-link-lib=oboe");
println!("cargo:rustc-link-lib=c++"); println!("cargo:rustc-link-lib=c++");
println!("cargo:rustc-link-lib=OpenSLES"); println!("cargo:rustc-link-lib=OpenSLES");
// I always got some strange link error with oboe, so as workaround, put oboe.cc into oboe src: src/common/AudioStreamBuilder.cpp
// also to avoid libc++_shared not found issue, cp ndk's libc++_shared.so to jniLibs, e.g.
// ./flutter_hbb/android/app/src/main/jniLibs/arm64-v8a/libc++_shared.so
// let include = path.join("include");
//cc::Build::new().file("oboe.cc").include(include).compile("oboe_wrapper");
} }
fn main() { fn main() {
hbb_common::gen_version(); hbb_common::gen_version();
install_oboe(); install_android_deps();
// 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 == "android" || target_os == "ios" {
#[cfg(all(windows, feature = "inline"))] #[cfg(all(windows, feature = "inline"))]
build_manifest(); build_manifest();
#[cfg(windows)] #[cfg(windows)]

View file

@ -23,14 +23,18 @@ fn link_pkg_config(_name: &str) -> Vec<PathBuf> {
unimplemented!() unimplemented!()
} }
/// Link vcppkg package. /// Link vcpkg package.
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();
if target_arch == "x86_64" { if target_arch == "x86_64" {
target_arch = "x64".to_owned(); target_arch = "x64".to_owned();
} else if target_arch == "x86" {
target_arch = "x86".to_owned();
} else if target_arch == "aarch64" { } else if target_arch == "aarch64" {
target_arch = "arm64".to_owned(); target_arch = "arm64".to_owned();
} else {
target_arch = "arm".to_owned();
} }
let mut target = if target_os == "macos" { let mut target = if target_os == "macos" {
if target_arch == "x64" { if target_arch == "x64" {