Skip to content

Commit 8fab410

Browse files
committed
Add no_std support
1 parent bb54959 commit 8fab410

30 files changed

+728
-398
lines changed

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
"files.associations": {
33
"**/mimex-*.txt": "csv"
44
},
5+
// "rust-analyzer.cargo.noDefaultFeatures": true,
6+
// "rust-analyzer.cargo.features": ["no_std"]
57
"rust-analyzer.cargo.features": "all"
68
}

Cargo.lock

Lines changed: 81 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,37 @@ harness = false
1717
required-features = ["mlogv32"]
1818

1919
[dependencies]
20-
base64 = "0.22.1"
21-
binrw = "0.15.0"
22-
cesu8 = "1.1.0"
23-
csv = "1.3.1"
20+
binrw = { version = "0.15.0", default-features = false, features = ["verbose-backtrace"] }
2421
enum_dispatch = "0.3.13"
25-
flate2 = { version = "1.1.2", features = ["zlib-rs"], default-features = false }
26-
indexmap = "2.10.0"
27-
itertools = "0.14.0"
28-
lalrpop-util = { version = "0.22.2", features = ["lexer"] }
22+
hashbrown = "0.15.5"
23+
indexmap = { version = "2.10.0", default-features = false }
24+
itertools = { version = "0.14.0", default-features = false, features = ["use_alloc"] }
2925
lazy_static = "1.5.0"
30-
noise = "0.9.0"
31-
num-traits = "0.2.19"
32-
rand = "0.9.2"
33-
rapidhash = { version = "3.0.0", features = ["unsafe"] }
34-
regex = "1.11.1"
35-
replace_with = "0.1.8"
36-
serde = { version = "1.0.219", features = ["derive"] }
37-
serde_json = "1.0.141"
38-
strum = "0.27.2"
26+
num-traits = { version = "0.2.19", default-features = false }
27+
# https://github.com/hoxxep/rapidhash/issues/38
28+
rapidhash = { git = "https://github.com/hoxxep/rapidhash", rev = "582477028c", default-features = false }
29+
replace_with = { version = "0.1.8", default-features = false }
30+
serde = { version = "1.0.219", default-features = false, features = ["derive"] }
31+
strum = { version = "0.27.2", default-features = false }
3932
strum_macros = "0.27.2"
40-
thiserror = "2.0.12"
41-
velcro = "0.5.4"
42-
widestring = "1.2.0"
33+
thiserror = { version = "2.0.12", default-features = false }
34+
widestring = { version = "1.2.0", default-features = false, features = ["alloc"] }
35+
36+
# no_std
37+
libm = { version = "0.2.11", optional = true }
38+
serde-json-core = { version = "0.6.0", optional = true }
39+
40+
# std
41+
base64 = { version = "0.22.1", optional = true }
42+
cesu8 = { version = "1.1.0", optional = true }
43+
csv = { version = "1.3.1", optional = true }
44+
flate2 = { version = "1.1.2", default-features = false, features = ["zlib-rs"], optional = true }
45+
lalrpop-util = { version = "0.22.2", features = ["lexer"], optional = true }
46+
# https://github.com/Razaekel/noise-rs/issues/251
47+
noise = { version = "0.9.0", optional = true }
48+
rand = { version = "0.9.2", optional = true }
49+
regex = { version = "1.11.1", optional = true }
50+
serde_json = { version = "1.0.141", optional = true }
4351

4452
# mlog
4553
clap = { version = "4.5.42", features = ["derive"], optional = true }
@@ -51,14 +59,44 @@ cursive = { version = "0.21.1", optional = true }
5159
indicatif = { version = "0.18.0", optional = true }
5260

5361
[build-dependencies]
54-
lalrpop = "0.22.2"
62+
lalrpop = { version = "0.22.2", optional = true }
5563

5664
[dev-dependencies]
5765
iai-callgrind = "0.16.1"
5866
pretty_assertions = "1.4.1"
67+
velcro = "0.5.4"
5968

6069
[features]
70+
default = ["std"]
71+
no_std = [
72+
"dep:libm",
73+
"dep:serde-json-core",
74+
"lazy_static/spin_no_std",
75+
]
76+
std = [
77+
"dep:base64",
78+
"dep:cesu8",
79+
"dep:csv",
80+
"dep:flate2",
81+
"dep:lalrpop",
82+
"dep:lalrpop-util",
83+
"dep:noise",
84+
"dep:rand",
85+
"dep:regex",
86+
"dep:serde_json",
87+
"binrw/std",
88+
"indexmap/std",
89+
"itertools/use_std",
90+
"num-traits/std",
91+
"rapidhash/std",
92+
"regex/std",
93+
"replace_with/std",
94+
"serde/std",
95+
"strum/std",
96+
"thiserror/std",
97+
]
6198
mlog = [
99+
"std",
62100
"dep:clap",
63101
"dep:clap-stdin",
64102
]

build.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
fn main() {
2-
println!("cargo:rerun-if-changed=src/logic/grammar.lalrpop");
3-
lalrpop::process_root().unwrap();
2+
#[cfg(feature = "std")]
3+
{
4+
println!("cargo:rerun-if-changed=src/logic/grammar.lalrpop");
5+
lalrpop::process_root().unwrap();
6+
}
47
}

src/bin/mlogv32.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use mindustry_rs::{
2424
Building, BuildingData, LValue, LogicVM, LogicVMBuilder, MEMORY_BANK, MESSAGE,
2525
MICRO_PROCESSOR, SWITCH, WORLD_PROCESSOR,
2626
},
27-
types::{Object, PackedPoint2, ProcessorConfig, Schematic},
27+
types::{Object, PackedPoint2, ProcessorConfig, schematics::Schematic},
2828
};
2929
use serde::Deserialize;
3030
use widestring::{U16String, u16str};

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
#![no_std]
2+
3+
extern crate alloc;
4+
5+
#[cfg(feature = "std")]
6+
extern crate std;
7+
18
pub mod logic;
29
pub mod types;
310
mod utils;

0 commit comments

Comments
 (0)