Cache templates compiled by proc-macro#125
Conversation
Instead of recompiling sailfish templates on every proc-macro invocation, see if an output file for the same input file content + compiler config combination already exists. This also fixes rust-sailfish#58 because it avoids multiple proc-macro invocations writing to the same output file at roughly the same time from different processes, for example in clippy checks that execute in parallel. In addition to the compiled output, now the list of dependencies (file names), which was previously generated by the compiler for each template on every proc-macro invocation, needs to be stored to disk for re-use.
|
Also, I don't handle the case when the |
|
@w-flo @djarb @imbolc @botika @Kogia-sima I will be merging this pull request, and then working on trying to get the rm_whitespace test working correctly. |
|
Thanks @vthg2themax! Feel free to ping me if you find / suspect there are new issues caused by the PR later on. I suspect upgrading to proc_macro2 1.0.66 could fix the rm_whitespace test. It includes this PR which looks related. Currently sailfish uses 1.0.56. |
|
After running the tests again, the issue has disappeared. Bonus! |
Use fix from rust-sailfish/sailfish#125 Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Use fix from rust-sailfish/sailfish#125 Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
I'm putting this up as a draft because I'm not convinced I can test it sufficiently. I have tested it a bit and it seems to work for my use case and fixes #58.
Possible disadvantages / risks:
cargo cleanshould drop all of them, right?)Instead of recompiling sailfish templates on every proc-macro invocation, see if an output file for the same input file content + compiler config combination already exists.
This also fixes #58 because it avoids multiple proc-macro invocations writing to the same output file at roughly the same time from different processes, for example in clippy checks that execute in parallel.
In addition to the compiled output, now the list of dependencies (file names), which was previously generated by the compiler for each template on every proc-macro invocation, needs to be stored to disk for re-use.