fix nebula-ffi buildscript
This commit is contained in:
parent
1a2ad44d58
commit
7fcb20a823
|
@ -4,19 +4,16 @@ use std::path::PathBuf;
|
||||||
use std::{env, process};
|
use std::{env, process};
|
||||||
|
|
||||||
fn get_cargo_target_dir() -> Result<std::path::PathBuf, Box<dyn std::error::Error>> {
|
fn get_cargo_target_dir() -> Result<std::path::PathBuf, Box<dyn std::error::Error>> {
|
||||||
|
let skip_triple = std::env::var("TARGET")? == std::env::var("HOST")?;
|
||||||
|
let skip_parent_dirs = if skip_triple { 4 } else { 5 };
|
||||||
|
|
||||||
let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR")?);
|
let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR")?);
|
||||||
let profile = std::env::var("PROFILE")?;
|
let mut current = out_dir.as_path();
|
||||||
let mut target_dir = None;
|
for _ in 0..skip_parent_dirs {
|
||||||
let mut sub_path = out_dir.as_path();
|
current = current.parent().ok_or("not found")?;
|
||||||
while let Some(parent) = sub_path.parent() {
|
|
||||||
if parent.ends_with(&profile) {
|
|
||||||
target_dir = Some(parent);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
sub_path = parent;
|
|
||||||
}
|
Ok(std::path::PathBuf::from(current))
|
||||||
let target_dir = target_dir.ok_or("not found")?;
|
|
||||||
Ok(target_dir.to_path_buf())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
Loading…
Reference in New Issue