@@ -122,6 +122,10 @@ defmodule Kernel.ParallelCompiler do
122122
123123 ## Options
124124
125+ * `:after_compile` - invoked after all modules are compiled, but before
126+ they are verified. If the files are being written to disk, such as in
127+ `compile_to_path/3`, this will be invoked after the files are written
128+
125129 * `:each_file` - for each file compiled, invokes the callback passing the
126130 file
127131
@@ -258,13 +262,6 @@ defmodule Kernel.ParallelCompiler do
258262 { status , modules_or_errors , info } =
259263 try do
260264 spawn_workers ( schedulers , cache , files , output , options )
261- else
262- { :ok , outcome , info } ->
263- beam_timestamp = Keyword . get ( options , :beam_timestamp )
264- { :ok , write_module_binaries ( outcome , output , beam_timestamp ) , info }
265-
266- { :error , errors , info } ->
267- { :error , errors , info }
268265 after
269266 Module.ParallelChecker . stop ( cache )
270267 end
@@ -288,7 +285,9 @@ defmodule Kernel.ParallelCompiler do
288285
289286 { outcome , state } =
290287 spawn_workers ( files , % { } , % { } , [ ] , % { } , [ ] , [ ] , % {
288+ beam_timestamp: Keyword . get ( options , :beam_timestamp ) ,
291289 dest: Keyword . get ( options , :dest ) ,
290+ after_compile: Keyword . get ( options , :after_compile , fn -> :ok end ) ,
292291 each_cycle: Keyword . get ( options , :each_cycle , fn -> { :runtime , [ ] , [ ] } end ) ,
293292 each_file: Keyword . get ( options , :each_file , fn _ , _ -> :ok end ) |> each_file ( ) ,
294293 each_long_compilation: Keyword . get ( options , :each_long_compilation , fn _file -> :ok end ) ,
@@ -345,9 +344,11 @@ defmodule Kernel.ParallelCompiler do
345344 ## Verification
346345
347346 defp verify_modules ( result , compile_warnings , dependent_modules , state ) do
347+ modules = write_module_binaries ( result , state . output , state . beam_timestamp )
348+ _ = state . after_compile . ( )
348349 runtime_warnings = maybe_check_modules ( result , dependent_modules , state )
349350 info = % { compile_warnings: Enum . reverse ( compile_warnings ) , runtime_warnings: runtime_warnings }
350- { { :ok , result , info } , state }
351+ { { :ok , modules , info } , state }
351352 end
352353
353354 defp maybe_check_modules ( result , runtime_modules , state ) do
0 commit comments