From 0316264f1c313641641747eb50f429dfc7ec10b6 Mon Sep 17 00:00:00 2001 From: Michael Krasnitski Date: Tue, 9 Apr 2024 18:11:29 -0400 Subject: [PATCH] Gate `AbstractType` derive macro behind a `derive` feature-flag --- rust/Cargo.toml | 6 ++++-- rust/src/lib.rs | 1 + rust/src/types.rs | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rust/Cargo.toml b/rust/Cargo.toml index b10134df8..681c85a94 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" [features] noexports = [] +derive = ["binaryninja-derive", "elain"] [dependencies] lazy_static = "1.4.0" @@ -13,8 +14,9 @@ log = "0.4" libc = "0.2" rayon = { version = "1.8", optional = true } binaryninjacore-sys = { path = "binaryninjacore-sys" } -binaryninja-derive = { path = "binaryninja-derive" } -elain = "0.3.0" +binaryninja-derive = { path = "binaryninja-derive", optional = true } +# Const-generic alignment gadgetry used by the `AbstractType` derive macro +elain = { version = "0.3.0", optional = true } [patch.crates-io] # Patched pdb crate to implement some extra structures diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 8ba41fa7f..ebec48a5f 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -169,6 +169,7 @@ use std::path::PathBuf; pub use binaryninjacore_sys::BNBranchType as BranchType; pub use binaryninjacore_sys::BNEndianness as Endianness; use binaryview::BinaryView; +#[cfg(feature = "derive")] pub use elain; use metadata::Metadata; use metadata::MetadataType; diff --git a/rust/src/types.rs b/rust/src/types.rs index 12d617b93..755d857ec 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -691,6 +691,7 @@ impl Drop for TypeBuilder { ////////// // Type +#[cfg(feature = "derive")] pub use binaryninja_derive::*; pub trait AbstractType: Sized { const SIZE: usize = std::mem::size_of::();