Skip to content

Commit 33629c1

Browse files
committed
Preserve compatibility
1 parent 6e455ea commit 33629c1

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

lib/mix/lib/mix/compilers/protocol.ex

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@ defmodule Mix.Compilers.Protocol do
66
## Umbrella handling
77

88
def umbrella(args, res) do
9+
config = Mix.Project.config()
10+
config_mtime = Mix.Project.config_mtime(config)
911
{opts, _, _} = OptionParser.parse(args, switches: [force: :boolean, verbose: :boolean])
12+
13+
opts =
14+
if "--no-protocol-consolidation" in args do
15+
Keyword.put(opts, :consolidate_protocols, false)
16+
else
17+
Keyword.take(config, [:consolidate_protocols]) ++ opts
18+
end
19+
1020
manifest = manifest()
11-
config_mtime = Mix.Project.config_mtime()
1221
{old_config_mtime, old_protocols_and_impls} = read_manifest(manifest)
1322

1423
case status(config_mtime > old_config_mtime, opts) do

lib/mix/lib/mix/tasks/archive.build.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ defmodule Mix.Tasks.Archive.Build do
6363
if project && Keyword.get(opts, :compile, true) do
6464
# We only care about the archive ebin, so we disable protocol
6565
# consolidation to avoid further changes to the environment.
66-
Mix.Task.run(:compile, ["--no-consolidate-protocols" | args])
66+
Mix.Task.run(:compile, ["--no-protocol-consolidation" | args])
6767
end
6868

6969
source =

lib/mix/lib/mix/tasks/compile.elixir.ex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ defmodule Mix.Tasks.Compile.Elixir do
9090
@switches [
9191
force: :boolean,
9292
docs: :boolean,
93-
consolidate_protocols: :boolean,
9493
warnings_as_errors: :boolean,
9594
ignore_module_conflict: :boolean,
9695
debug_info: :boolean,
@@ -125,6 +124,13 @@ defmodule Mix.Tasks.Compile.Elixir do
125124
|> tracers_opts(tracers)
126125
|> profile_opts()
127126

127+
opts =
128+
if "--no-protocol-consolidation" in args do
129+
Keyword.put(opts, :consolidate_protocols, false)
130+
else
131+
opts
132+
end
133+
128134
# Having compilations racing with other is most undesired,
129135
# so we wrap the compiler in a lock.
130136

lib/mix/lib/mix/tasks/compile.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ defmodule Mix.Tasks.Compile do
7171
default case with dependencies)
7272
* `--no-prune-code-paths` - do not prune code paths before compilation, this keeps
7373
the entirety of Erlang/OTP available when the project starts
74-
* `--no-consolidate-protocols` - skips protocol consolidation
74+
* `--no-protocol-consolidation` - skips protocol consolidation
7575
* `--no-validate-compile-env` - does not validate the application compile environment
7676
* `--return-errors` - returns error status and diagnostics instead of exiting on error
7777
* `--warnings-as-errors` - exit with non-zero status if compilation has one or more

lib/mix/test/mix/tasks/compile_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ defmodule Mix.Tasks.CompileTest do
224224
end)
225225
end
226226

227-
test "skip protocol consolidation when --no-consolidate-protocols" do
227+
test "skip protocol consolidation when --no-protocol-consolidation" do
228228
in_fixture("no_mixfile", fn ->
229229
File.rm("_build/dev/lib/sample/.mix/compile.protocols")
230-
assert Mix.Task.run("compile", ["--no-consolidate-protocols"]) == {:ok, []}
230+
assert Mix.Task.run("compile", ["--no-protocol-consolidation"]) == {:ok, []}
231231
assert File.regular?("_build/dev/lib/sample/ebin/Elixir.A.beam")
232232
refute File.regular?("_build/dev/lib/sample/consolidated/Elixir.Enumerable.beam")
233233
end)
@@ -283,7 +283,7 @@ defmodule Mix.Tasks.CompileTest do
283283
Mix.Project.push(WrongPath)
284284

285285
ExUnit.CaptureIO.capture_io(fn ->
286-
assert Mix.Task.run("compile", ["--no-consolidate-protocols"]) == {:noop, []}
286+
assert Mix.Task.run("compile", ["--no-protocol-consolidation"]) == {:noop, []}
287287
end)
288288
end
289289

0 commit comments

Comments
 (0)