Ralith / hecs

A handy ECS
Apache License 2.0
921 stars 79 forks source link

no-std support for macros #339

Closed wenyuzhao closed 9 months ago

wenyuzhao commented 9 months ago

This PR fixes #106 and supports no_std builds to use macros.

Changes involved:

~There is probably no need to deal with lazy_static as it already has the spin_no_std feature enabled. It should already support no_std builds.~

~After merging the commit to use OnceLock instead of lazy_static, I had to use spin::Once for no-std builds. OnceLock is only in std, not in core.~

wenyuzhao commented 9 months ago

The changes look good to me. I wonder about the testing story though. Can we add a no_std build to the CI so that this does not regress so easily?

@adamreichold I added a no_std build test in CI. The CI job will check no_std macro builds on both x86_64-unknown-none and x86_64-unknown-linux-gnu targets. However, I added the source code for the build test as a cargo example under the examples/ dir. Not sure if there is any better way to do this...