mirror of
https://github.com/correl/rebar.git
synced 2024-11-14 11:09:35 +00:00
Delete existing out-edges before adding new ones in modify_erlcinfo
When the source file changes it could happen that some of its dependecies get removed. In that case we should remove these former dependencies from the graph, so that they don't influence recompilation of the source file anymore.
This commit is contained in:
parent
13fe77d3f5
commit
462962ebab
3 changed files with 27 additions and 3 deletions
|
@ -40,7 +40,7 @@ files() ->
|
|||
run(_Dir) ->
|
||||
compile_all(ok, ""),
|
||||
check_beams_ok(),
|
||||
check_beams_untouched(),
|
||||
check_beams_untouched(filelib:wildcard("ebin/*.beam")),
|
||||
modify_and_recompile_ok("src/lisp.erl", "ebin/lisp.beam"),
|
||||
|
||||
clean_all_ok(),
|
||||
|
@ -48,14 +48,27 @@ run(_Dir) ->
|
|||
compile_all(ok, ""),
|
||||
modify_and_recompile_ok("extra_include/extra.hrl", "ebin/java.beam"),
|
||||
|
||||
Java = "src/java.erl",
|
||||
{ok, OrigContent} = file:read_file(Java),
|
||||
%% Remove header file inclusion
|
||||
{ok, _} = file:copy("src/java.erl.no_extra", Java),
|
||||
%% Ensure recompilation
|
||||
touch([Java]),
|
||||
compile_all(ok, ""),
|
||||
%% Modify that header file
|
||||
touch(["extra_include/extra.hrl"]),
|
||||
%% Ensure we don't have to recompile anything
|
||||
check_beams_untouched(["ebin/java.beam"]),
|
||||
%% Clean up
|
||||
ok = file:write_file(Java, OrigContent),
|
||||
|
||||
ok.
|
||||
|
||||
check_beams_ok() ->
|
||||
F = fun(BeamFile) -> ?assert(filelib:is_regular(BeamFile)) end,
|
||||
with_erl_beams(F).
|
||||
|
||||
check_beams_untouched() ->
|
||||
Beams = filelib:wildcard("ebin/*.beam"),
|
||||
check_beams_untouched(Beams) ->
|
||||
compile_all_and_assert_mtimes(Beams, fun erlang:'=:='/2).
|
||||
|
||||
modify_and_recompile_ok(TouchFile, CheckFile) ->
|
||||
|
|
10
inttest/erlc_dep_graph/src/java.erl.no_extra
Normal file
10
inttest/erlc_dep_graph/src/java.erl.no_extra
Normal file
|
@ -0,0 +1,10 @@
|
|||
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
|
||||
%% ex: ts=4 sw=4 ft=erlang et
|
||||
-module(java).
|
||||
|
||||
-export([factory/0]).
|
||||
|
||||
-include("lambda.hrl").
|
||||
|
||||
factory() ->
|
||||
?FUN.
|
|
@ -448,6 +448,7 @@ modify_erlcinfo(G, Source, Dirs) ->
|
|||
ok = file:close(Fd),
|
||||
LastUpdated = {date(), time()},
|
||||
digraph:add_vertex(G, Source, LastUpdated),
|
||||
digraph:del_edges(G, digraph:out_edges(G, Source)),
|
||||
lists:foreach(
|
||||
fun(Incl) ->
|
||||
update_erlcinfo(G, Dirs, Incl),
|
||||
|
|
Loading…
Reference in a new issue