Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3fc13166 authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi Committed by Abhishek Pandit-Subedi
Browse files

floss: Fix build for arm cross-compiling

ARM builds complain about incorrect size for c_char (u8 vs i8) so use
the actual raw character type instead.

Also add build scripts for all binaries so that pkg-config correctly
adds the correct libdir to the search paths.

Bug: 201687614
Tag: #floss
Test: ./build.py; emerge-zork-floss floss; emerge-trogdor floss;
Change-Id: I32e6975e4def090da4ce2e9661b4d623615615d2
parent 6193b979
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -27,3 +27,4 @@ pkg-config = "0.3.19"
[[bin]]
name = "btclient"
path = "src/main.rs"
build = "build.rs"
+12 −0
Original line number Diff line number Diff line
use pkg_config::Config;

fn main() {
    let target_dir = std::env::var_os("CARGO_TARGET_DIR").unwrap();
    println!("cargo:rustc-link-search=native={}", target_dir.into_string().unwrap());

    // When cross-compiling, pkg-config is looking for dbus at the host libdir instead of the
    // sysroot. Adding this dependency here forces the linker to include the current sysroot's
    // libdir and fixes the build issues.
    Config::new().probe("dbus-1").unwrap();
    println!("cargo:rerun-if-changed=build.rs");
}
+4 −0
Original line number Diff line number Diff line
@@ -25,5 +25,9 @@ serde_json = "1.0"
syslog = "4.0"
tokio = { version = "1.0", features = ["fs", "macros", "rt-multi-thread", "sync"] }

[build-dependencies]
pkg-config = "0.3.19"

[[bin]]
name = "btmanagerd"
build = "build.rs"
+12 −0
Original line number Diff line number Diff line
use pkg_config::Config;

fn main() {
    let target_dir = std::env::var_os("CARGO_TARGET_DIR").unwrap();
    println!("cargo:rustc-link-search=native={}", target_dir.into_string().unwrap());

    // When cross-compiling, pkg-config is looking for dbus at the host libdir instead of the
    // sysroot. Adding this dependency here forces the linker to include the current sysroot's
    // libdir and fixes the build issues.
    Config::new().probe("dbus-1").unwrap();
    println!("cargo:rerun-if-changed=build.rs");
}
+2 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ use num_traits::cast::{FromPrimitive, ToPrimitive};
use std::cmp;
use std::fmt::{Debug, Formatter, Result};
use std::mem;
use std::os::raw::c_char;
use std::sync::{Arc, Mutex};
use std::vec::Vec;
use topshim_macros::cb_variant;
@@ -408,7 +409,7 @@ impl BluetoothProperty {
                record.channel = sr.channel;
                let name_len = len - mem::size_of::<BtServiceRecord>();
                record.name.copy_from_slice(
                    &(sr.name.as_bytes().iter().map(|x| *x as i8).collect::<Vec<i8>>())
                    &(sr.name.as_bytes().iter().map(|x| *x as c_char).collect::<Vec<c_char>>())
                        [0..name_len],
                );
            }
Loading