Skip to content

Commit

Permalink
Merge branch 'nested-dirs'
Browse files Browse the repository at this point in the history
Conflicts:
	compiler/erlang_check.erl
  • Loading branch information
jimenezrick committed May 11, 2013
2 parents 7c6e98b + ae5824c commit 5029637
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions compiler/erlang_check.erl
@@ -1,18 +1,15 @@
#!/usr/bin/env escript

main([File]) ->
Dir = filename:dirname(File),
Dir = get_root(filename:dirname(File)),
Defs = [strong_validation,
warn_export_all,
warn_export_vars,
warn_shadow_vars,
warn_obsolete_guard,
warn_unused_import,
report,
{i, Dir ++ "/include"},
{i, Dir ++ "/../include"},
{i, Dir ++ "/../../include"},
{i, Dir ++ "/../../../include"}],
{i, Dir ++ "/include"}],
RebarFile = rebar_file(Dir),
RebarOpts = rebar_opts(RebarFile),
code:add_patha(filename:absname("ebin")),
Expand All @@ -31,6 +28,7 @@ rebar_file(Dir) ->
end.

rebar_opts(RebarFile) ->
Dir = get_root(filename:dirname(RebarFile)),
case file:consult(RebarFile) of
{ok, Terms} ->
RebarLibDirs = proplists:get_value(lib_dirs, Terms, []),
Expand All @@ -40,10 +38,21 @@ rebar_opts(RebarFile) ->
end, RebarLibDirs),
RebarDepsDir = proplists:get_value(deps_dir, Terms, "deps"),
code:add_pathsa(filelib:wildcard(RebarDepsDir ++ "/*/ebin")),
IncludeDeps = {i, RebarDepsDir},
IncludeDeps = {i, filename:join(Dir, RebarDepsDir)},
proplists:get_value(erl_opts, Terms, []) ++ [IncludeDeps];
{error, _} when RebarFile == "rebar.config" ->
[];
{error, _} ->
rebar_opts("rebar.config")
end.

get_root(Dir) ->
Path = filename:split(filename:absname(Dir)),
filename:join(get_root(lists:reverse(Path), Path)).

get_root([], Path) ->
Path;
get_root(["src" | Tail], _Path) ->
lists:reverse(Tail);
get_root([_ | Tail], Path) ->
get_root(Tail, Path).

0 comments on commit 5029637

Please sign in to comment.