diff options
author | Jerry Kuch <jerryk@vmware.com> | 2010-11-10 16:04:29 +0000 |
---|---|---|
committer | Jerry Kuch <jerryk@vmware.com> | 2010-11-10 16:04:29 +0000 |
commit | 67ee034be7bd9e60bcc0cb780dba5a8fe23b2fae (patch) | |
tree | 0d015998ef2005c2cbc017294651526a1323b3b0 /generate_deps | |
parent | 59b4142070bf526299c400aef84370d022eb52b0 (diff) | |
download | rabbitmq-server-67ee034be7bd9e60bcc0cb780dba5a8fe23b2fae.tar.gz |
generate_deps should no longer trip on detritus.
Diffstat (limited to 'generate_deps')
-rw-r--r-- | generate_deps | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/generate_deps b/generate_deps index 29587b5a..92bca9ae 100644 --- a/generate_deps +++ b/generate_deps @@ -2,18 +2,19 @@ %% -*- erlang -*- -mode(compile). -main([IncludeDir, ErlDir, EbinDir, TargetFile]) -> - ErlDirContents = filelib:wildcard("*.erl", ErlDir), - ErlFiles = [filename:join(ErlDir, FileName) || FileName <- ErlDirContents], +main([TargetFile, EbinDir | ErlsAndHrls ]) -> + ErlFiles = lists:filter(fun (Path) -> lists:suffix(".erl", Path) end, + ErlsAndHrls), Modules = sets:from_list( [list_to_atom(filename:basename(FileName, ".erl")) || - FileName <- ErlDirContents]), - Headers = sets:from_list( - [filename:join(IncludeDir, FileName) || - FileName <- filelib:wildcard("*.hrl", IncludeDir)]), + FileName <- ErlFiles]), + HrlFiles = lists:filter(fun (Path) -> lists:suffix(".hrl", Path) end, + ErlsAndHrls), + IncludeDirs = lists:usort([filename:dirname(Path) || Path <- HrlFiles]), + Headers = sets:from_list(HrlFiles), Deps = lists:foldl( fun (Path, Deps1) -> - dict:store(Path, detect_deps(IncludeDir, EbinDir, + dict:store(Path, detect_deps(IncludeDirs, EbinDir, Modules, Headers, Path), Deps1) end, dict:new(), ErlFiles), @@ -33,8 +34,8 @@ main([IncludeDir, ErlDir, EbinDir, TargetFile]) -> ok = file:sync(Hdl), ok = file:close(Hdl). -detect_deps(IncludeDir, EbinDir, Modules, Headers, Path) -> - {ok, Forms} = epp:parse_file(Path, [IncludeDir], [{use_specs, true}]), +detect_deps(IncludeDirs, EbinDir, Modules, Headers, Path) -> + {ok, Forms} = epp:parse_file(Path, IncludeDirs, [{use_specs, true}]), lists:foldl( fun ({attribute, _LineNumber, Attribute, Behaviour}, Deps) when Attribute =:= behaviour orelse Attribute =:= behavior -> |