@@ -2,6 +2,7 @@ defmodule Mix.Compilers.Elixir do
2
2
@ moduledoc false
3
3
4
4
@ manifest_vsn 13
5
+ @ checkpoint_vsn 2
5
6
6
7
import Record
7
8
@@ -102,7 +103,7 @@ defmodule Mix.Compilers.Elixir do
102
103
{ false , stale , old_lock , old_config }
103
104
end
104
105
105
- { stale_local_mods , stale_local_exports , all_local_exports } =
106
+ { stale_modules , stale_exports , all_local_exports } =
106
107
stale_local_deps ( manifest , stale , modified , all_local_exports )
107
108
108
109
prev_paths = for source ( source: source ) <- all_sources , do: source
@@ -120,8 +121,8 @@ defmodule Mix.Compilers.Elixir do
120
121
all_modules ,
121
122
all_sources ,
122
123
removed ,
123
- stale_local_mods ,
124
- Map . merge ( stale_local_exports , removed_modules ) ,
124
+ Map . merge ( stale_modules , removed_modules ) ,
125
+ Map . merge ( stale_exports , removed_modules ) ,
125
126
dest
126
127
)
127
128
end
@@ -180,7 +181,7 @@ defmodule Mix.Compilers.Elixir do
180
181
delete_compiler_info ( )
181
182
end
182
183
else
183
- # We need to return ok if deps_changed? or stale_local_mods changed,
184
+ # We need to return ok if deps_changed? or stale_modules changed,
184
185
# even if no code was compiled, because we need to propagate the changed
185
186
# status to compile.protocols. This will be the case whenever:
186
187
#
@@ -193,7 +194,7 @@ defmodule Mix.Compilers.Elixir do
193
194
# will only compute the diff with current protocols. In fact, there is no
194
195
# need to reconsolidate if an Erlang file changes and it doesn't trigger
195
196
# any other change, but the diff check should be reasonably fast anyway.
196
- status = if removed != [ ] or deps_changed? or stale_local_mods != % { } , do: :ok , else: :noop
197
+ status = if removed != [ ] or deps_changed? or stale_modules != % { } , do: :ok , else: :noop
197
198
198
199
# If nothing changed but there is one more recent mtime, bump the manifest
199
200
if status != :noop or Enum . any? ( Map . values ( sources_stats ) , & ( elem ( & 1 , 0 ) > modified ) ) do
@@ -283,8 +284,8 @@ defmodule Mix.Compilers.Elixir do
283
284
all_modules ,
284
285
all_sources ,
285
286
removed ,
286
- stale_local_mods ,
287
- stale_local_exports ,
287
+ stale_modules ,
288
+ stale_exports ,
288
289
dest
289
290
) do
290
291
# TODO: Use :maps.from_keys/2 on Erlang/OTP 24+
@@ -294,13 +295,17 @@ defmodule Mix.Compilers.Elixir do
294
295
into: % { } ,
295
296
do: { module , [ ] }
296
297
297
- { checkpoint_stale , checkpoint_modules } = parse_checkpoint ( manifest )
298
+ { checkpoint_stale_modules , checkpoint_stale_exports , checkpoint_modules } =
299
+ parse_checkpoint ( manifest )
300
+
298
301
modules_to_recompile = Map . merge ( checkpoint_modules , modules_to_recompile )
299
- stale_local_mods = Map . merge ( checkpoint_stale , stale_local_mods )
302
+ stale_modules = Map . merge ( checkpoint_stale_modules , stale_modules )
303
+ stale_exports = Map . merge ( checkpoint_stale_exports , stale_exports )
300
304
301
- if map_size ( stale_local_mods ) != map_size ( checkpoint_stale ) or
305
+ if map_size ( stale_modules ) != map_size ( checkpoint_stale_modules ) or
306
+ map_size ( stale_exports ) != map_size ( checkpoint_stale_exports ) or
302
307
map_size ( modules_to_recompile ) != map_size ( checkpoint_modules ) do
303
- write_checkpoint ( manifest , stale_local_mods , modules_to_recompile )
308
+ write_checkpoint ( manifest , stale_modules , stale_exports , modules_to_recompile )
304
309
end
305
310
306
311
sources_stats =
@@ -332,8 +337,8 @@ defmodule Mix.Compilers.Elixir do
332
337
all_modules ,
333
338
all_sources ,
334
339
removed ++ changed ,
335
- stale_local_mods ,
336
- stale_local_exports ,
340
+ stale_modules ,
341
+ stale_exports ,
337
342
dest
338
343
)
339
344
@@ -654,16 +659,16 @@ defmodule Mix.Compilers.Elixir do
654
659
# files that have changed. Then it recursively figures out
655
660
# all the files that changed (via the module dependencies) and
656
661
# return the non-changed entries and the removed sources.
657
- defp update_stale_entries ( modules , _sources , [ ] , stale_mods , stale_exports , _compile_path )
658
- when stale_mods == % { } and stale_exports == % { } do
662
+ defp update_stale_entries ( modules , _sources , [ ] , stale_modules , stale_exports , _compile_path )
663
+ when stale_modules == % { } and stale_exports == % { } do
659
664
{ modules , % { } , [ ] }
660
665
end
661
666
662
- defp update_stale_entries ( modules , sources , changed , stale_mods , stale_exports , compile_path ) do
667
+ defp update_stale_entries ( modules , sources , changed , stale_modules , stale_exports , compile_path ) do
663
668
# TODO: Use :maps.from_keys/2 on Erlang/OTP 24+
664
669
changed = Enum . into ( changed , % { } , & { & 1 , [ ] } )
665
670
reducer = & remove_stale_entry ( & 1 , & 2 , sources , stale_exports , compile_path )
666
- remove_stale_entries ( modules , % { } , changed , stale_mods , reducer )
671
+ remove_stale_entries ( modules , % { } , changed , stale_modules , reducer )
667
672
end
668
673
669
674
defp remove_stale_entries ( modules , exports , old_changed , old_stale , reducer ) do
@@ -720,14 +725,16 @@ defmodule Mix.Compilers.Elixir do
720
725
defp stale_local_deps ( manifest , stale_modules , modified , old_exports ) do
721
726
base = Path . basename ( manifest )
722
727
728
+ # The stale modules so far will become both stale_modules and stale_exports,
729
+ # as any export from a dependency needs to be recompiled.
723
730
# TODO: Use :maps.from_keys/2 on Erlang/OTP 24+
724
731
stale_modules = for module <- stale_modules , do: { module , [ ] } , into: % { }
725
732
726
733
for % { scm: scm , opts: opts } = dep <- Mix.Dep . cached ( ) ,
727
734
not scm . fetchable? ,
728
735
manifest = Path . join ( [ opts [ :build ] , ".mix" , base ] ) ,
729
736
Mix.Utils . last_modified ( manifest ) > modified ,
730
- reduce: { stale_modules , % { } , old_exports } do
737
+ reduce: { stale_modules , stale_modules , old_exports } do
731
738
{ modules , exports , new_exports } ->
732
739
{ _manifest_modules , dep_sources } = read_manifest ( manifest )
733
740
@@ -1017,19 +1024,19 @@ defmodule Mix.Compilers.Elixir do
1017
1024
( manifest <> ".checkpoint" ) |> File . read! ( ) |> :erlang . binary_to_term ( )
1018
1025
rescue
1019
1026
_ ->
1020
- { % { } , % { } }
1027
+ { % { } , % { } , % { } }
1021
1028
else
1022
- { @ manifest_vsn , stale , recompile_modules } ->
1023
- { stale , recompile_modules }
1029
+ { @ checkpoint_vsn , stale_modules , stale_exports , recompile_modules } ->
1030
+ { stale_modules , stale_exports , recompile_modules }
1024
1031
1025
1032
_ ->
1026
- { % { } , % { } }
1033
+ { % { } , % { } , % { } }
1027
1034
end
1028
1035
end
1029
1036
1030
- defp write_checkpoint ( manifest , stale , recompile_modules ) do
1037
+ defp write_checkpoint ( manifest , stale_modules , stale_exports , recompile_modules ) do
1031
1038
File . mkdir_p! ( Path . dirname ( manifest ) )
1032
- term = { @ manifest_vsn , stale , recompile_modules }
1039
+ term = { @ checkpoint_vsn , stale_modules , stale_exports , recompile_modules }
1033
1040
checkpoint_data = :erlang . term_to_binary ( term , [ :compressed ] )
1034
1041
File . write! ( manifest <> ".checkpoint" , checkpoint_data )
1035
1042
end
0 commit comments