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
{{ message }}
This repository was archived by the owner on Aug 1, 2023. It is now read-only.
This patch adds a set of macros to derive types.json automatically. This is, all in all, a little complicated because the best way to analyze the code is through macros (since we can easily mark types that need to be exported) but macros, for obvious reasons, are run at compile-time and are not _meant_ to be side-effecty. That is, you can't easily just store a bunch of global data and when you're finished just emit it. Instead, we truncate and re-write a file-system temp file each time we encounter a new type and eventually we stop encountering new ones and we're good. We do this separately for each project in `scripts/build_types.json` since partial compilation and project-by-project compilation makes this even harder to do. We also need to clean and rebuild each time to ensure every macro is run. _Also_ there is some compile time slowness added here since I can't seem to remove the macros via features or other settings since this runs in the same layer as those types of tools. All-in-all, it's significantly fast enough and hopefully will make the process of updating our types.json trivial going forward.
Note: some of the code is pretty spaghetti in the derive code itself and can be upgraded over time. The issue is that there is a ton of possibilities that could occur in the syntax and we probably don't want to handle all of them.
The most complex one that we need to consider is `WIDTH` which, as a const, is not very easy to determine its value, so for now, we just use its value directly, since literals are fairly easy.
Note: the goal of `types-derive` is that it is generic and can be added to substrate's core, so we try to avoid "Gateway-specific" features in the code.
0 commit comments