Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support modern x86 build #8

Merged
merged 3 commits into from
Mar 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blurdroid"
version = "0.1.4"
version = "0.1.5"
description = "Bluetooth lib for Rust using Android's bluedroid"
readme = "README.md"
authors = ["Attila Dusnoki <[email protected]>"]
Expand Down
17 changes: 9 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ fn android_main() {
"arm64-v8a"
} else if target.contains("arm") {
"armeabi"
} else if target.contains("x86") {
} else if target.contains("x86") || target.contains("i686") {
"x86"
} else {
panic!("Invalid target architecture {}", target);
};

let src_path = env::var("CARGO_MANIFEST_DIR").unwrap();

if Command::new(ndk_path.join("ndk-build"))
.arg(format!("APP_ABI={}", abi))
.arg("-C")
.arg("src/jni/")
.env("NDK_PROJECT_PATH", format!("{}/src", src_path))
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.status().unwrap().code().unwrap() != 0
Expand All @@ -47,7 +48,7 @@ fn android_main() {
let out_dir = env::var("OUT_DIR").ok().expect("Cargo should have set the OUT_DIR environment variable");

if Command::new("cp")
.arg(format!("src/obj/local/{}/libblurdroid.a", abi))
.arg(format!("{}/src/obj/local/{}/libblurdroid.a", src_path, abi))
.arg(&format!("{}", out_dir))
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
Expand All @@ -59,7 +60,7 @@ fn android_main() {

if Command::new("mkdir")
.arg("-p")
.arg("target/java/classes/")
.arg(&format!("{}/target/java/classes/", out_dir))
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.status().unwrap().code().unwrap() != 0
Expand All @@ -68,12 +69,12 @@ fn android_main() {
process::exit(1)
}

let java_files = fs::read_dir("src/java/hu/uszeged/bluetooth").unwrap().map(|p| p.unwrap().path()).collect::<Vec<_>>();
let java_files = fs::read_dir(format!("{}/src/java/hu/uszeged/bluetooth", src_path)).unwrap().map(|p| p.unwrap().path()).collect::<Vec<_>>();
let java_files = java_files.iter().map(|p| p.as_os_str().to_str().unwrap()).collect::<Vec<_>>();

if Command::new("javac")
.arg("-d")
.arg("target/java/classes/")
.arg(&format!("{}/target/java/classes/", out_dir))
.arg("-cp")
.arg(find_android_platform(sdk_path))
.args(java_files.as_slice())
Expand All @@ -89,7 +90,7 @@ fn android_main() {
.arg("cvf")
.arg(&format!("{}/blurdroid.jar", out_dir))
.arg("-C")
.arg("target/java/classes/")
.arg(&format!("{}/target/java/classes/", out_dir))
.arg("hu")
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
Expand Down