From b2239fd880fa40fa98d206d8f31aec1bb8a0ce12 Mon Sep 17 00:00:00 2001 From: Ranger <32590310+southorange0929@users.noreply.github.com> Date: Fri, 10 May 2024 14:32:48 +0800 Subject: [PATCH] fix(napi-macro): gengerate type file should align with type-def featrue (#2100) * fix: make sure env without exception pending before throw error * fix(napi-macro): gengerate type file should align with type-def featrue * fix(napi-macro): gengerate type file should align with type-def featrue --- crates/macro/src/expand/napi.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/macro/src/expand/napi.rs b/crates/macro/src/expand/napi.rs index 79657d84..e56c3046 100644 --- a/crates/macro/src/expand/napi.rs +++ b/crates/macro/src/expand/napi.rs @@ -21,15 +21,16 @@ use syn::{Attribute, Item}; /// } /// /// ``` +#[cfg(feature = "type-def")] static BUILT_FLAG: AtomicBool = AtomicBool::new(false); pub fn expand(attr: TokenStream, input: TokenStream) -> BindgenResult { + #[cfg(feature = "type-def")] if BUILT_FLAG .compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed) .is_ok() { // logic on first macro expansion - #[cfg(feature = "type-def")] prepare_type_def_file(); if let Ok(wasi_register_file) = env::var("WASI_REGISTER_TMP_PATH") { @@ -84,8 +85,10 @@ pub fn expand(attr: TokenStream, input: TokenStream) -> BindgenResult BindgenResult std::io::Result<()> { use std::io::{BufRead, BufReader};