-
Notifications
You must be signed in to change notification settings - Fork 70
Description
Currently the import!() macro processes globals, but if the macro is used more than once, things will break because there will be more than 1 globals generated (in >= matter 1.4)
Additionally, if we do a glob import!() (i.e. all clusters), the generated token stream is massive and results in:
macro invocation exceeds token limit: produced 2759294 tokens, limit is 2097152
As such, import!() is unlikely to be a viable long-term approach to generating all clusters, e.g. for an all-clusters-app
Instead, we should use build.rs with cargo:rerun-if-changed=[source.matter], so that we can output globals and clusters to separate files while also caching outputs if input .matter file hasn't changed
This offers the additional benefit of being able to see the actual cluster code, as it will generate an actual rust file in generated/
Additionally, we may want to move this to a separate crate e.g. rs-matter-dm (likely including all its deps in said crate, such as TLV & core types), because compilation of all the clusters adds > 10s, and moving to a separate crate allows caching - we should do this only if there is a regression in build speed vs import!()
See detailed discussion in #338 (comment)_