From 9f4a844c9b95d609a1ca502a591ac36e9db2748d Mon Sep 17 00:00:00 2001 From: Vasyl Gello Date: Wed, 1 Nov 2023 11:37:39 +0200 Subject: [PATCH] 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 --- build.py | 2 +- build.rs | 15 +++++---------- libs/scrap/build.rs | 6 +++++- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/build.py b/build.py index 8cff351e2..786ef199b 100755 --- a/build.py +++ b/build.py @@ -180,8 +180,8 @@ def generate_build_script_for_docker(): export VCPKG_ROOT=`pwd`/vcpkg git clone https://github.com/microsoft/vcpkg vcpkg/bootstrap-vcpkg.sh - vcpkg/vcpkg install libvpx libyuv opus popd + $VCPKG_ROOT/vcpkg install --x-install-root="$VCPKG_ROOT/installed" # build rustdesk ./build.py --flutter --hwcodec ''') diff --git a/build.rs b/build.rs index ad745667d..bb115e66d 100644 --- a/build.rs +++ b/build.rs @@ -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(); if target_os != "android" { return; @@ -49,6 +49,8 @@ fn install_oboe() { 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 == "x86" { + target_arch = "x86".to_owned(); } else if target_arch == "aarch64" { target_arch = "arm64".to_owned(); } else { @@ -66,22 +68,15 @@ fn install_oboe() { path.join("lib").to_str().unwrap() ) ); + println!("cargo:rustc-link-lib=ndk_compat"); println!("cargo:rustc-link-lib=oboe"); println!("cargo:rustc-link-lib=c++"); 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() { hbb_common::gen_version(); - install_oboe(); - // 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" { + install_android_deps(); #[cfg(all(windows, feature = "inline"))] build_manifest(); #[cfg(windows)] diff --git a/libs/scrap/build.rs b/libs/scrap/build.rs index 7d162adfa..90518eb9b 100644 --- a/libs/scrap/build.rs +++ b/libs/scrap/build.rs @@ -23,14 +23,18 @@ fn link_pkg_config(_name: &str) -> Vec { unimplemented!() } -/// Link vcppkg package. +/// Link vcpkg package. fn link_vcpkg(mut path: PathBuf, name: &str) -> PathBuf { 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 == "x86" { + target_arch = "x86".to_owned(); } else if target_arch == "aarch64" { target_arch = "arm64".to_owned(); + } else { + target_arch = "arm".to_owned(); } let mut target = if target_os == "macos" { if target_arch == "x64" {