From df8be364fb51d1f4cd7499d7655e395ae3727e32 Mon Sep 17 00:00:00 2001 From: matejcik Date: Wed, 25 Sep 2024 11:53:27 +0200 Subject: [PATCH] build(core/rust): provide a default value for BUILD_DIR to make it easier to run cargo separately, and support rust-analyzer without tweaking its config --- core/embed/rust/build.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/embed/rust/build.rs b/core/embed/rust/build.rs index 4f438d77f..47f4724eb 100644 --- a/core/embed/rust/build.rs +++ b/core/embed/rust/build.rs @@ -3,6 +3,7 @@ use std::ffi::OsStr; use std::{env, path::PathBuf, process::Command}; fn main() { + println!("cargo:rustc-env=BUILD_DIR={}", build_dir()); #[cfg(feature = "micropython")] generate_qstr_bindings(); #[cfg(feature = "micropython")] @@ -15,7 +16,13 @@ fn main() { } fn build_dir() -> String { - env::var("BUILD_DIR").expect("BUILD_DIR not defined") + let build_dir_str = env::var("BUILD_DIR").unwrap_or(String::from("../../build/unix")); + PathBuf::from(build_dir_str) + .canonicalize() + .unwrap() + .to_str() + .unwrap() + .to_string() } const DEFAULT_BINDGEN_MACROS_COMMON: &[&str] = &[