@@ -15,6 +15,12 @@ defmodule Mix.Tasks.Compile do
1515 * `:compilers` - compilers to run, defaults to:
1616 `[:leex, :yeec, :erlang, :elixir, :app]`
1717
18+ * `:consolidate_protocols` - when true, runs protocol
19+ consolidation via the `compile.protocols` task
20+
21+ * `:build_embedded` - when true, activates protocol
22+ consolidation and does not generate symlinks in builds
23+
1824 ## Command line options
1925
2026 * `--list` - list all enabled compilers
@@ -47,21 +53,20 @@ defmodule Mix.Tasks.Compile do
4753 shell . info format ( 'mix ~-#{ max } s # ~ts' , [ task , doc ] )
4854 end
4955
50- shell . info "\n Enabled compilers: #{ Enum . join compilers ( ) , ", " } "
56+ compilers = compilers ( ) ++ if ( consolidate_protocols? ( ) , do: [ :protocols ] , else: [ ] )
57+ shell . info "\n Enabled compilers: #{ Enum . join compilers , ", " } "
5158 end
5259
5360 def run ( args ) do
5461 Mix.Project . get!
55- Mix.Task . run "loadpaths" , [ "--no-readd" | args ]
62+ Mix.Task . run "loadpaths" , args
63+ res = Mix.Task . run "compile.all" , args
5664
57- res =
58- Enum . map ( compilers ( ) , fn ( compiler ) ->
59- List . wrap Mix.Task . run ( "compile.#{ compiler } " , args )
60- end )
65+ if consolidate_protocols? ( ) do
66+ Mix.Task . run "compile.protocols" , args
67+ end
6168
62- true = Code . prepend_path ( Mix.Project . compile_path )
63- unless "--no-readd" in args , do: Code . readd_paths ( )
64- if Enum . any? ( res , & ( :ok in & 1 ) ) , do: :ok , else: :noop
69+ res
6570 end
6671
6772 # Loadpaths without checks because compilers may be defined in deps.
@@ -70,6 +75,11 @@ defmodule Mix.Tasks.Compile do
7075 Mix.Task . reenable "loadpaths"
7176 end
7277
78+ defp consolidate_protocols? do
79+ config = Mix.Project . config
80+ config [ :build_embedded ] || config [ :consolidate_protocols ]
81+ end
82+
7383 @ doc """
7484 Returns all compilers.
7585 """
0 commit comments