Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge compile.protocols into compile.elixir #14109

Merged
merged 14 commits into from
Dec 24, 2024
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
Loading