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};
|
||||
|
||||
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 profile = std::env::var("PROFILE")?;
|
||||
let mut target_dir = None;
|
||||
let mut sub_path = out_dir.as_path();
|
||||
while let Some(parent) = sub_path.parent() {
|
||||
if parent.ends_with(&profile) {
|
||||
target_dir = Some(parent);
|
||||
break;
|
||||
}
|
||||
sub_path = parent;
|
||||
let mut current = out_dir.as_path();
|
||||
for _ in 0..skip_parent_dirs {
|
||||
current = current.parent().ok_or("not found")?;
|
||||
}
|
||||
let target_dir = target_dir.ok_or("not found")?;
|
||||
Ok(target_dir.to_path_buf())
|
||||
|
||||
Ok(std::path::PathBuf::from(current))
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
Loading…
Reference in New Issue