Skip to content

Commit

Permalink
Fix buildscripts
Browse files Browse the repository at this point in the history
  * 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 <[email protected]>
  • Loading branch information
basilgello committed Nov 7, 2023
1 parent 82b7650 commit 9f4a844
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
''')
Expand Down
15 changes: 5 additions & 10 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,16 @@ 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;
}
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 {
Expand All @@ -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)]
Expand Down
6 changes: 5 additions & 1 deletion libs/scrap/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ fn link_pkg_config(_name: &str) -> Vec<PathBuf> {
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" {
Expand Down

0 comments on commit 9f4a844

Please sign in to comment.