I know about macros,
__before_compile__ and other attributes, compiler tracers and such stuff. The question is exactly about implementing wrapper for Elixir compiler which be compatible with
Mix.Task.Compiler, nothing else.
How do I write the
Mix.Task.Compiler which will do some global changes to the AST before calling Elixir’s compiler to generate
Right now my compiler
- Searches for
.exfiles in the path specified by
Code.string_to_quoted()on each file
- Changes the AST
File.write!()to the build_path of the binaries returned by
Current solution drawbacks
- I think it is possible to compile straight to file (without
- I think this kind of compilation does not call compiler tracers
- I think it can have some problems with protocol consolidation
- It needs to read/write elixir’s compiler manifest, which is some kind of a private structure.
- It is difficult to change the AST because modules can have compile-time code in their bodies, which I need to preevaluate, to change the code inside functions.