From 7fcb20a823cfd98fe2383cabb557c8c3fe7c76f8 Mon Sep 17 00:00:00 2001 From: core Date: Fri, 15 Dec 2023 22:59:20 -0500 Subject: [PATCH] fix nebula-ffi buildscript --- nebula-ffi/build.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/nebula-ffi/build.rs b/nebula-ffi/build.rs index 59fe846..4923ce3 100644 --- a/nebula-ffi/build.rs +++ b/nebula-ffi/build.rs @@ -4,19 +4,16 @@ use std::path::PathBuf; use std::{env, process}; fn get_cargo_target_dir() -> Result> { + 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() {