Skip to content

Commit 591e97a

Browse files
authored
Merge compile.protocols into compile.elixir (#14109)
1 parent 1cd67c9 commit 591e97a

File tree

14 files changed

+598
-589
lines changed

14 files changed

+598
-589
lines changed

lib/elixir/lib/kernel/parallel_compiler.ex

Lines changed: 9 additions & 8 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
@@ -258,13 +262,6 @@ defmodule Kernel.ParallelCompiler do
258262
{status, modules_or_errors, info} =
259263
try do
260264
spawn_workers(schedulers, cache, files, output, options)
261-
else
262-
{:ok, outcome, info} ->
263-
beam_timestamp = Keyword.get(options, :beam_timestamp)
264-
{:ok, write_module_binaries(outcome, output, beam_timestamp), info}
265-
266-
{:error, errors, info} ->
267-
{:error, errors, info}
268265
after
269266
Module.ParallelChecker.stop(cache)
270267
end
@@ -288,7 +285,9 @@ defmodule Kernel.ParallelCompiler do
288285

289286
{outcome, state} =
290287
spawn_workers(files, %{}, %{}, [], %{}, [], [], %{
288+
beam_timestamp: Keyword.get(options, :beam_timestamp),
291289
dest: Keyword.get(options, :dest),
290+
after_compile: Keyword.get(options, :after_compile, fn -> :ok end),
292291
each_cycle: Keyword.get(options, :each_cycle, fn -> {:runtime, [], []} end),
293292
each_file: Keyword.get(options, :each_file, fn _, _ -> :ok end) |> each_file(),
294293
each_long_compilation: Keyword.get(options, :each_long_compilation, fn _file -> :ok end),
@@ -345,9 +344,11 @@ defmodule Kernel.ParallelCompiler do
345344
## Verification
346345

347346
defp verify_modules(result, compile_warnings, dependent_modules, state) do
347+
modules = write_module_binaries(result, state.output, state.beam_timestamp)
348+
_ = state.after_compile.()
348349
runtime_warnings = maybe_check_modules(result, dependent_modules, state)
349350
info = %{compile_warnings: Enum.reverse(compile_warnings), runtime_warnings: runtime_warnings}
350-
{{:ok, result, info}, state}
351+
{{:ok, modules, info}, state}
351352
end
352353

353354
defp maybe_check_modules(result, runtime_modules, state) do

lib/iex/lib/iex/helpers.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ defmodule IEx.Helpers do
171171
defp reenable_tasks(config) do
172172
Mix.Task.reenable("compile")
173173
Mix.Task.reenable("compile.all")
174-
Mix.Task.reenable("compile.protocols")
175174
compilers = config[:compilers] || Mix.compilers()
176175
Enum.each(compilers, &Mix.Task.reenable("compile.#{&1}"))
177176
end

lib/mix/lib/mix.ex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,7 @@ defmodule Mix do
704704
* `:verbose` - if `true`, prints additional debugging information
705705
(Default: `false`)
706706
707-
* `:consolidate_protocols` - if `true`, runs protocol
708-
consolidation via the `mix compile.protocols` task (Default: `true`)
707+
* `:consolidate_protocols` - if `true`, runs protocol consolidation (Default: `true`)
709708
710709
* `:elixir` - if set, ensures the current Elixir version matches the given
711710
version requirement (Default: `nil`)
@@ -1078,7 +1077,7 @@ defmodule Mix do
10781077
app: @mix_install_app,
10791078
erlc_paths: [],
10801079
elixirc_paths: [],
1081-
compilers: [],
1080+
compilers: [:elixir],
10821081
prune_code_paths: false
10831082
] ++ dynamic_config
10841083
end

0 commit comments

Comments
 (0)