Browse Source

Add deps/2, include ?COMPILE_OPTS

Sina Samavati 11 years ago
parent
commit
26f722d406
2 changed files with 10 additions and 12 deletions
  1. 0 2
      src/mad.hrl
  2. 10 10
      src/mad_compile.erl

+ 0 - 2
src/mad.hrl

@@ -1,2 +0,0 @@
--define(CONTAINER_PATH, filename:join([mad_utils:home(), ".mad", "container"])).
--define(COMPILE_OPTS(Inc, Ebin), [report, {i, Inc}, {outdir, Ebin}]).

+ 10 - 10
src/mad_compile.erl

@@ -1,32 +1,32 @@
 -module(mad_compile).
 
--export([deps/1]).
+-export([deps/2]).
 -export([app/1]).
 
--include("mad.hrl").
+-define(COMPILE_OPTS(Inc, Ebin), [report, {i, Inc}, {outdir, Ebin}]).
 
 
 %% compile dependencies
-deps([]) ->
+deps(_, []) ->
     ok;
-deps([H|T]) ->
+deps(Cwd, [H|T]) ->
     {Name, _} = mad_deps:name_and_repo(H),
     case get(Name) of
         compiled ->
             ok;
         _ ->
-            dep(Name)
+            dep(Cwd, Name)
     end,
-    deps(T).
+    deps(Cwd, T).
 
 %% compile a dependency
-dep(DepName) ->
+dep(Cwd, Name) ->
     %% check dependencies of the dependency
     Cwd = mad_utils:cwd(),
-    DepPath = filename:join([Cwd, "deps", DepName]),
+    DepPath = filename:join([Cwd, "deps", Name]),
     Conf = mad_utils:rebar_conf(DepPath),
     Conf1 = mad_utils:script(DepPath, Conf),
-    deps(mad_utils:get_value(deps, Conf1, [])),
+    deps(Cwd, mad_utils:get_value(deps, Conf1, [])),
 
     %% add lib_dirs to path
     LibDirs = mad_utils:lib_dirs(DepPath, Conf1),
@@ -47,7 +47,7 @@ dep(DepName) ->
             Opts = mad_utils:get_value(erl_opts, Conf1, []),
             mad_utils:exec("mkdir", ["-p", EbinDir]),
             lists:foreach(compile_fun(SrcDir, IncDir, EbinDir, Opts), Files),
-            put(DepName, compiled)
+            put(Name, compiled)
     end.
 
 app(Dir) ->