You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[axconfig-gen](axconfig-gen): A TOML-based configuration generation tool for [ArceOS](https://github.com/arceos-org/arceos). [](https://crates.io/crates/axconfig-gen)[](https://docs.rs/axconfig-gen)
6
+
*[axconfig-gen-macros](axconfig-gen-macros): Procedural macros for converting TOML format configurations to Rust constant definitions. [](https://crates.io/crates/axconfig-gen-macros)[](https://docs.rs/axconfig-gen-macros)
6
7
7
-
```
8
+
### Executable Usage
9
+
10
+
```text
8
11
axconfig-gen [OPTIONS] --spec <SPEC>
9
12
10
13
Options:
@@ -22,4 +25,75 @@ For example, to generate a config file `.axconfig.toml` from the config specific
See [defconfig.toml](example_configs/defconfig.toml) for an example of a config specification file.
28
+
See [defconfig.toml](example-configs/defconfig.toml) for an example of a config specification file.
29
+
30
+
Value types are necessary for generating Rust constant definitions. Types can be specified by the comment following the config item. Currently supported types are `bool`, `int`, `uint`, `str`, `(type1, type2, ...)` for tuples, and `[type]` for arrays. If no type is specified, it will try to infer the type from the value.
Procedural macros for converting TOML format configurations to equivalent Rust constant definitions.
4
+
5
+
## Example
6
+
7
+
```rust
8
+
axconfig_gen_macros::parse_configs!(r#"
9
+
are-you-ok = true
10
+
one-two-three = 123
11
+
12
+
[hello]
13
+
"one-two-three" = "456" # int
14
+
array = [1, 2, 3] # [uint]
15
+
tuple = [1, "abc", 3]
16
+
"#);
17
+
18
+
assert_eq!(ARE_YOU_OK, true);
19
+
assert_eq!(ONE_TWO_THREE, 123usize);
20
+
assert_eq!(hello::ONE_TWO_THREE, 456isize);
21
+
assert_eq!(hello::ARRAY, [1, 2, 3]);
22
+
assert_eq!(hello::TUPLE, (1, "abc", 3));
23
+
```
24
+
25
+
Value types are necessary for generating Rust constant definitions. Types can be specified by the comment following the config item. Currently supported types are `bool`, `int`, `uint`, `str`, `(type1, type2, ...)` for tuples, and `[type]` for arrays. If no type is specified, it will try to infer the type from the value.
26
+
27
+
The above example will generate the following constants:
0 commit comments