canonicalzie ndk path and revert patch changes after build
-use std::{
- env,
- path::PathBuf,
- process::Command,
-};
+use std::{env, fs, path::PathBuf, process::Command};
fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
@@ -27,8 +23,7 @@ fn main() {
if cfg!(feature = "fltk-bundled") {
let url = PathBuf::from(format!(
"https://github.com/MoAlyousef/fltk-rs/releases/download/{}/lib_x64-{}.tar.gz",
- pkg_version,
- platform
+ pkg_version, platform
));
Command::new("curl")
@@ -42,7 +37,6 @@ fn main() {
.current_dir(out_dir.clone())
.status()
.expect("Curl and Tar are needed to download and upack the bundled libraries!");
-
} else {
println!("cargo:rerun-if-changed=cfltk/include/cfl_new.hpp");
println!("cargo:rerun-if-changed=cfltk/include/cfl.h");
@@ -157,7 +151,10 @@ fn main() {
}
if let Ok(toolchain) = env::var("CFLTK_TOOLCHAIN_FILE") {
- dst.define("CMAKE_TOOLCHAIN_FILE", toolchain);
+ dst.define(
+ "CMAKE_TOOLCHAIN_FILE",
+ fs::canonicalize(toolchain).expect("Failed to canonicalize toolchain path!"),
+ );
}
if target_triple.contains("android") {
@@ -178,6 +175,12 @@ fn main() {
.build();
}
+ Command::new("git")
+ .args(&["reset", "--hard", "origin/master"])
+ .current_dir(manifest_dir.join("cfltk").join("fltk"))
+ .status()
+ .expect("Git is needed to retrieve the fltk source files!");
+
println!(
"cargo:rustc-link-search=native={}",
out_dir.join("build").display()
@@ -272,7 +275,8 @@ fn main() {
}
fn handle_android(triple: &str, dst: &mut cmake::Config) {
- let ndk = PathBuf::from(env::var("NDK_HOME").expect("NDK_HOME should be set!"));
+ let ndk = env::var("NDK_HOME").expect("NDK_HOME should be set!");
+ let ndk = fs::canonicalize(ndk).expect("Failed to canonicalize ndk path");
dst.define("CMAKE_SYSTEM_NAME", "Android");
dst.define("CMAKE_SYSTEM_VERSION", "16");
@@ -284,19 +288,19 @@ fn handle_android(triple: &str, dst: &mut cmake::Config) {
"i686-linux-android" => {
dst.define("ANDROID_ABI", "x86");
dst.define("CMAKE_ANDROID_ARCH_ABI", "x86");
- },
+ }
"aarch64-linux-android" => {
dst.define("ANDROID_ABI", "arm64-v8a");
dst.define("CMAKE_ANDROID_ARCH_ABI", "arm64-v8a");
- },
+ }
"armv7-linux-androideabi" => {
dst.define("ANDROID_ABI", "armeabi-v7a");
dst.define("CMAKE_ANDROID_ARCH_ABI", "armeabi-v7a");
- },
+ }
"x86_64-linux-android" => {
dst.define("ANDROID_ABI", "x86_64");
dst.define("CMAKE_ANDROID_ARCH_ABI", "x86_64");
- },
+ }
_ => panic!("Unknown android triple"),
}
}
