Skip to content

Commit c1764c6

Browse files
committed
after_compile
1 parent b03922e commit c1764c6

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

lib/elixir/lib/kernel/parallel_compiler.ex

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ defmodule Kernel.ParallelCompiler do
122122
123123
## Options
124124
125+
* `:after_compile` - invoked after all modules are compiled, but before
126+
they are verified. If the files are being written to disk, such as in
127+
`compile_to_path/3`, this will be invoked after the files are written
128+
125129
* `:each_file` - for each file compiled, invokes the callback passing the
126130
file
127131
@@ -139,8 +143,6 @@ defmodule Kernel.ParallelCompiler do
139143
* `{:runtime, modules, warnings}` - to stop compilation and verify the list
140144
of modules because dependent modules have changed
141145
142-
* `:after_persistence` - ...
143-
144146
* `:long_compilation_threshold` - the timeout (in seconds) to check for modules
145147
taking too long to compile. For each file that exceeds the threshold, the
146148
`:each_long_compilation` callback is invoked. From Elixir v1.11, only the time
@@ -285,7 +287,7 @@ defmodule Kernel.ParallelCompiler do
285287
spawn_workers(files, %{}, %{}, [], %{}, [], [], %{
286288
beam_timestamp: Keyword.get(options, :beam_timestamp),
287289
dest: Keyword.get(options, :dest),
288-
after_persistence: Keyword.get(options, :after_persistence, fn -> :ok end),
290+
after_compile: Keyword.get(options, :after_compile, fn -> :ok end),
289291
each_cycle: Keyword.get(options, :each_cycle, fn -> {:runtime, [], []} end),
290292
each_file: Keyword.get(options, :each_file, fn _, _ -> :ok end) |> each_file(),
291293
each_long_compilation: Keyword.get(options, :each_long_compilation, fn _file -> :ok end),
@@ -343,7 +345,7 @@ defmodule Kernel.ParallelCompiler do
343345

344346
defp verify_modules(result, compile_warnings, dependent_modules, state) do
345347
modules = write_module_binaries(result, state.output, state.beam_timestamp)
346-
_ = state.after_persistence.()
348+
_ = state.after_compile.()
347349
runtime_warnings = maybe_check_modules(result, dependent_modules, state)
348350
info = %{compile_warnings: Enum.reverse(compile_warnings), runtime_warnings: runtime_warnings}
349351
{{:ok, modules, info}, state}

lib/mix/lib/mix/compilers/elixir.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,8 @@ defmodule Mix.Compilers.Elixir do
10211021
pid =
10221022
spawn_link(fn ->
10231023
compile_opts = [
1024-
after_persistence: fn ->
1025-
compiler_call(parent, ref, {:after_persistence, opts})
1024+
after_compile: fn ->
1025+
compiler_call(parent, ref, {:after_compile, opts})
10261026
end,
10271027
each_cycle: fn ->
10281028
compiler_call(parent, ref, {:each_cycle, stale_modules, dest, timestamp})
@@ -1061,8 +1061,8 @@ defmodule Mix.Compilers.Elixir do
10611061

10621062
defp compiler_loop(ref, pid, state, cwd) do
10631063
receive do
1064-
{^ref, {:after_persistence, opts}} ->
1065-
{response, state} = after_persistence(state, opts)
1064+
{^ref, {:after_compile, opts}} ->
1065+
{response, state} = after_compile(state, opts)
10661066
send(pid, {ref, response})
10671067
compiler_loop(ref, pid, state, cwd)
10681068

@@ -1095,7 +1095,7 @@ defmodule Mix.Compilers.Elixir do
10951095
end
10961096
end
10971097

1098-
defp after_persistence(state, opts) do
1098+
defp after_compile(state, opts) do
10991099
{modules, exports, sources, changed, pending_modules, stale_exports, consolidation} = state
11001100

11011101
state =

0 commit comments

Comments
 (0)