sashaafm

sashaafm

End of compilation hook

Hello, I was wondering if there’s a way to do something at the end of application’s compilation? For example, there are the @before_compile and @after_compile hooks, which are scoped to the calling module. However, since Elixir’s compiler is concurrent, there doesn’t seem to be a deterministic way to know what will be the last compiled module in case you want to do something at the end of all compilations.

I reckon there must be some way to know the compilation has finished (e.g., Elixir emits a Generated <app_name> app at the end of each app’s compilation process which by looking at the source code seems to be emitted once the target app file is written)? Probably the API for this won’t be public for the general user.

Marked As Solved

michalmuskala

michalmuskala

Elixir has the concept of multiple compilers. Currently the built-in ones are:

  • yecc - responsible for generating yecc parser files
  • leex - responsible for generating leex lexer files
  • erlang - responsible for compiling erlang files
  • elixir - responsible for compiling elixir files
  • xref - responsible for collecting compilation information so that missing module information can be displayed
  • app - responsible for generating the .app file.

You can define your own compiles and include them at a particular point. For example: phoenix includes the phoenix compiler to support code reloading.

Maybe that could solve your issue?

Also Liked

hazardfn

hazardfn

Not sure if this is entirely what you meant but I think you can extend the compile mix task by adding your own “compiler” to the project and (to run it after everything else is compiled) just set it to last in the :compilers list. The docs has some info on this:

http://elixir-lang.org/docs/stable/mix/Mix.Tasks.Compile.html#content

I have never tried it but adding a module in the same namespace (Mix.Tasks.Compile.x) should work if I understand correctly…

Where Next?

Popular in Questions Top

JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

Other popular topics Top

William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement