Skip to content

Commit 67aabe0

Browse files
author
José Valim
committed
Calculate beam files only when writing manifest data
Signed-off-by: José Valim <[email protected]>
1 parent 8506cc6 commit 67aabe0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/mix/lib/mix/compilers/elixir.ex

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ defmodule Mix.Compilers.Elixir do
177177
end
178178

179179
defp each_module(pid, cwd, source, module, binary) do
180-
beam = Atom.to_string(module) <> ".beam"
181-
182180
{compile_references, runtime_references} = Kernel.LexicalTracker.remote_references(module)
183181

184182
compile_references =
@@ -214,7 +212,7 @@ defmodule Mix.Compilers.Elixir do
214212
module: module,
215213
kind: kind,
216214
source: source,
217-
beam: beam,
215+
beam: nil, # They are calculated when writing the manifest
218216
binary: binary
219217
)
220218

@@ -265,8 +263,10 @@ defmodule Mix.Compilers.Elixir do
265263
## Resolution
266264

267265
defp update_stale_sources(sources, removed, changed) do
266+
# Remove delete sources
268267
sources =
269-
Enum.reject(sources, fn source(source: source) -> source in removed end)
268+
Enum.reduce(removed, sources, &List.keydelete(&2, &1, source(:source)))
269+
# Store empty sources for the changed ones as the compiler appends data
270270
sources =
271271
Enum.reduce(changed, sources, &List.keystore(&2, &1, source(:source), source(source: &1)))
272272
sources
@@ -394,13 +394,14 @@ defmodule Mix.Compilers.Elixir do
394394
File.mkdir_p!(Path.dirname(manifest))
395395

396396
modules =
397-
for module(beam: beam, binary: binary) = module <- modules do
397+
for module(binary: binary, module: module) = entry <- modules do
398+
beam = Atom.to_string(module) <> ".beam"
398399
if binary do
399400
beam_path = Path.join(compile_path, beam)
400401
File.write!(beam_path, binary)
401402
File.touch!(beam_path, timestamp)
402403
end
403-
module(module, binary: nil)
404+
module(entry, binary: nil, beam: beam)
404405
end
405406

406407
manifest_data =

0 commit comments

Comments
 (0)