Skip to content

Commit 041fd5f

Browse files
feat(dfir_lang): support graph_ids #[no_std] via std, alloc, serde features (#2923)
Add `std`/`alloc`/`serde` feature flags. The only non-codegen module (`graph_ids`) now compiles on bare-metal targets with zero std dependencies. - Add `#![cfg_attr(not(feature = "std"), no_std)]` to `lib.rs` - Make `serde` optional (only needed for `slotmap` key serialization, pulled in by `codegen` feature) - Set `slotmap` to `default-features = false` - `codegen` feature implies `std` + `serde` Co-authored-by: Infinity 🤖 <infinity@hydro.run> Co-authored-by: Infinity 🤖 <infinity@hydro.run>
1 parent 341fb14 commit 041fd5f

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

dfir_lang/Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ license = { workspace = true }
1212
workspace = true
1313

1414
[features]
15-
default = ["codegen"]
15+
default = ["std", "codegen"]
16+
std = ["alloc", "serde?/std", "slotmap/std"]
17+
alloc = ["serde?/alloc"]
18+
serde = ["dep:serde", "slotmap/serde"]
1619
codegen = [
20+
"std",
21+
"serde",
1722
"dep:auto_impl",
1823
"dep:documented",
1924
"dep:itertools",
@@ -38,9 +43,9 @@ itertools = { version = "0.14.0", optional = true }
3843
prettyplease = { version = "0.2.0", features = [ "verbatim" ], optional = true }
3944
proc-macro2 = { version = "1.0.95", features = [ "span-locations" ], optional = true }
4045
quote = { version = "1.0.35", optional = true }
41-
serde = "1.0.197"
46+
serde = { version = "1.0.197", default-features = false, optional = true }
4247
serde_json = { version = "1.0.115", optional = true }
43-
slotmap = { version = "1.1.0", features = ["serde"] }
48+
slotmap = { version = "1.1.0", default-features = false }
4449
syn = { version = "2.0.46", features = [ "extra-traits", "full", "parsing", "visit-mut" ], optional = true }
4550
webbrowser = { version = "1.0.3", optional = true }
4651

dfir_lang/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
//! DFIR syntax
2-
2+
#![cfg_attr(not(feature = "std"), no_std)]
33
#![warn(missing_docs)]
44
#![cfg_attr(all(nightly, feature = "codegen"), feature(proc_macro_diagnostic))]
55

6+
#[cfg(any(test, feature = "alloc"))]
7+
extern crate alloc;
8+
#[cfg(any(test, feature = "std"))]
9+
extern crate std;
10+
611
pub mod graph_ids;
712

813
#[cfg(feature = "codegen")]

0 commit comments

Comments
 (0)