From 90298ad35da9593242c59a5766369911bbefcf96 Mon Sep 17 00:00:00 2001 From: franchioping Date: Thu, 2 Apr 2026 16:53:22 +0100 Subject: [PATCH] fix building with cargo (dont build the bindings file unless ESP32 env variables are present). ready to merge --- build.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index 66e16ac..b89a83c 100644 --- a/build.rs +++ b/build.rs @@ -2,10 +2,12 @@ use std::path::{Path, PathBuf}; use std::{env, time}; fn main() { - let cargo_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); - let target_dir = PathBuf::from(env::var("CARGO_BUILD_TARGET_DIR").unwrap()); + if env::var("CARGO_BUILD_TARGET_DIR").is_ok() { + let cargo_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); + let target_dir = PathBuf::from(env::var("CARGO_BUILD_TARGET_DIR").unwrap()); - run_cbindgen(&cargo_dir, &target_dir); + run_cbindgen(&cargo_dir, &target_dir); + } } fn run_cbindgen(cargo_dir: &Path, target_dir: &Path) {