Skip to content

Commit 51d99f3

Browse files
committed
zephyr: main.c: Only add logging support when needed
Match the conditionals of the Rust code needing the log wrappers in C code, so that this is not brought in if there is no logging support enabled in Zephyr. Signed-off-by: David Brown <[email protected]>
1 parent acaba09 commit 51d99f3

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

main.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,11 @@
1010

1111
extern void rust_main(void);
1212

13+
#if defined(CONFIG_LOG) && !defined(CONFIG_LOG_MINIMAL)
1314
// Logging, to see how things things are expanded.
1415
#include <zephyr/logging/log.h>
1516
LOG_MODULE_REGISTER(rust, 3);
1617

17-
int main(void)
18-
{
19-
rust_main();
20-
return 0;
21-
}
22-
2318
void rust_log_message(uint32_t level, char *msg) {
2419
// Ok. The log macros in Zephyr perform all kinds of macro stitching, etc, on the
2520
// arguments. As such, we can't just pass the level to something, but actually need to
@@ -41,6 +36,13 @@ void rust_log_message(uint32_t level, char *msg) {
4136
break;
4237
}
4338
}
39+
#endif /* defined(CONFIG_LOG) && !defined(CONFIG_LOG_MINIMAL) */
40+
41+
int main(void)
42+
{
43+
rust_main();
44+
return 0;
45+
}
4446

4547
/* On most arches, panic is entirely macros resulting in some kind of inline assembly. Create this
4648
* wrapper so the Rust panic handler can call the same kind of panic.

0 commit comments

Comments
 (0)