Skip to content

Commit

Permalink
Merge compile.protocols into compile.elixir (#14109)
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim authored Dec 24, 2024
1 parent 1cd67c9 commit 591e97a
Show file tree
Hide file tree
Showing 14 changed files with 598 additions and 589 deletions.
17 changes: 9 additions & 8 deletions lib/elixir/lib/kernel/parallel_compiler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ defmodule Kernel.ParallelCompiler do
## Options
* `:after_compile` - invoked after all modules are compiled, but before
they are verified. If the files are being written to disk, such as in
`compile_to_path/3`, this will be invoked after the files are written
* `:each_file` - for each file compiled, invokes the callback passing the
file
Expand Down Expand Up @@ -258,13 +262,6 @@ defmodule Kernel.ParallelCompiler do
{status, modules_or_errors, info} =
try do
spawn_workers(schedulers, cache, files, output, options)
else
{:ok, outcome, info} ->
beam_timestamp = Keyword.get(options, :beam_timestamp)
{:ok, write_module_binaries(outcome, output, beam_timestamp), info}

{:error, errors, info} ->
{:error, errors, info}
after
Module.ParallelChecker.stop(cache)
end
Expand All @@ -288,7 +285,9 @@ defmodule Kernel.ParallelCompiler do

{outcome, state} =
spawn_workers(files, %{}, %{}, [], %{}, [], [], %{
beam_timestamp: Keyword.get(options, :beam_timestamp),
dest: Keyword.get(options, :dest),
after_compile: Keyword.get(options, :after_compile, fn -> :ok end),
each_cycle: Keyword.get(options, :each_cycle, fn -> {:runtime, [], []} end),
each_file: Keyword.get(options, :each_file, fn _, _ -> :ok end) |> each_file(),
each_long_compilation: Keyword.get(options, :each_long_compilation, fn _file -> :ok end),
Expand Down Expand Up @@ -345,9 +344,11 @@ defmodule Kernel.ParallelCompiler do
## Verification

defp verify_modules(result, compile_warnings, dependent_modules, state) do
modules = write_module_binaries(result, state.output, state.beam_timestamp)
_ = state.after_compile.()
runtime_warnings = maybe_check_modules(result, dependent_modules, state)
info = %{compile_warnings: Enum.reverse(compile_warnings), runtime_warnings: runtime_warnings}
{{:ok, result, info}, state}
{{:ok, modules, info}, state}
end

defp maybe_check_modules(result, runtime_modules, state) do
Expand Down
1 change: 0 additions & 1 deletion lib/iex/lib/iex/helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ defmodule IEx.Helpers do
defp reenable_tasks(config) do
Mix.Task.reenable("compile")
Mix.Task.reenable("compile.all")
Mix.Task.reenable("compile.protocols")
compilers = config[:compilers] || Mix.compilers()
Enum.each(compilers, &Mix.Task.reenable("compile.#{&1}"))
end
Expand Down
5 changes: 2 additions & 3 deletions lib/mix/lib/mix.ex
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,7 @@ defmodule Mix do
* `:verbose` - if `true`, prints additional debugging information
(Default: `false`)
* `:consolidate_protocols` - if `true`, runs protocol
consolidation via the `mix compile.protocols` task (Default: `true`)
* `:consolidate_protocols` - if `true`, runs protocol consolidation (Default: `true`)
* `:elixir` - if set, ensures the current Elixir version matches the given
version requirement (Default: `nil`)
Expand Down Expand Up @@ -1078,7 +1077,7 @@ defmodule Mix do
app: @mix_install_app,
erlc_paths: [],
elixirc_paths: [],
compilers: [],
compilers: [:elixir],
prune_code_paths: false
] ++ dynamic_config
end
Expand Down
Loading

0 comments on commit 591e97a

Please sign in to comment.