calyxir/calyx

[fud2] Reduce Redundancy in Emitted Ninja Files from High Level Rhai

Opened this issue · 0 comments

Issue

Currently generated Ninja can be redundant. The two most egregious examples

  • Duplicate rules with different names are not collected into a single rule and reused. This comes up when Rhai functions wrap around shell or shell_deps and are used in more than one op.
  • Duplicate variable definitions are not collected into a single variable which is reused. This comes up when a value from the config files is used in more than one op.

Ideas for Implementation

One method for reducing this redundancy is for the Emitter to only emit the Ninja file after receiving being manipulated by all EmitBuilds first. It can then recognize repeated variables and rules to optimize the final Ninja.

An upside of this method is it is pretty self contained. A downside is it doesn't provide much path to allow the user to name common rules which occur in the final Ninja. If this feature is even wanted though is unclear (it might just be fine to understand the names of rules in the final Ninja will be a bit opaque).