summaryrefslogtreecommitdiff
path: root/src/rebar_erlc_compiler.erl
diff options
context:
space:
mode:
authorKevin Smith <kevin@hypotheticalabs.com>2010-01-05 10:41:15 -0500
committerKevin Smith <kevin@hypotheticalabs.com>2010-01-05 10:41:15 -0500
commitc9d175a30d6e63d7b1c3db4a0ed0b7d3d7b706be (patch)
tree7e9692227f840211dabd7e039f69f1a8ae892e1e /src/rebar_erlc_compiler.erl
parentbfcb54cbc90712091ed886077e52bba2e43f42eb (diff)
parent93111bfcf784bc8b17dd70220a19f95ce51f88f4 (diff)
Merging
Diffstat (limited to 'src/rebar_erlc_compiler.erl')
-rw-r--r--src/rebar_erlc_compiler.erl26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index 575e7dc..933d2df 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -52,16 +52,11 @@ clean(_Config, _AppFile) ->
%% Erlang compilation is recursive, so it's possible that we have a nested
%% directory structure in ebin with .beam files within. As such, we want
%% to scan whatever is left in the ebin/ directory for sub-dirs which
- %% satisfy our criteria. TODO: Is there a better way to do this?
- Dirs = ordsets:from_list([base_dir(F) ||
- F <- rebar_utils:find_files("ebin", "^.*\\.beam\$")]),
- case Dirs of
- [] ->
- ok;
- _ ->
- ok = rebar_file_utils:rm_rf(string:join(Dirs, " "))
- end.
-
+ %% satisfy our criteria.
+ BeamFiles = rebar_utils:find_files("ebin", "^.*\\.beam$"),
+ rebar_file_utils:delete_each(BeamFiles),
+ lists:foreach(fun(Dir) -> delete_dir(Dir, dirs(Dir)) end, dirs("ebin")),
+ ok.
%% ===================================================================
@@ -164,6 +159,11 @@ compile_mib(Source, _Target, Config) ->
?FAIL
end.
-base_dir(Filename) ->
- ["ebin" | Rest] = filename:split(Filename),
- filename:join("ebin", hd(Rest)).
+dirs(Dir) ->
+ [F || F <- filelib:wildcard(filename:join([Dir, "*"])), filelib:is_dir(F)].
+
+delete_dir(Dir, []) ->
+ file:del_dir(Dir);
+delete_dir(Dir, Subdirs) ->
+ lists:foreach(fun(D) -> delete_dir(D, dirs(D)) end, Subdirs),
+ file:del_dir(Dir).