Browse Source

mad is now aware of system deps. this should fix #26

Namdak Tonpa 10 years ago
parent
commit
80659cfd60
2 changed files with 11 additions and 3 deletions
  1. BIN
      mad
  2. 11 3
      src/mad_plan.erl

BIN
mad


+ 11 - 3
src/mad_plan.erl

@@ -24,13 +24,21 @@ orderapps() ->
        file:consult(F) of
        file:consult(F) of
          {ok,[{application,Name,Opt}]} -> 
          {ok,[{application,Name,Opt}]} -> 
               Apps = proplists:get_value(applications,Opt,[]),
               Apps = proplists:get_value(applications,Opt,[]),
-              [ { A,Name} || A <- Apps ];
-         {error,_} -> io:format("AppName: ~p~n",[F]), skip
+              [ case lists:member(A,mad_repl:system()) of
+                     false -> {A,Name};
+                     true -> [{A,Name}]++ system_deps(A) end || A <- Apps ];
+         {error,_} ->
+            io:format("AppName: ~p~n",[F]), skip
     end || F <- filelib:wildcard("{apps,deps}/*/ebin/*.app")  ++ 
     end || F <- filelib:wildcard("{apps,deps}/*/ebin/*.app")  ++ 
                 filelib:wildcard("ebin/*.app"), not filelib:is_dir(F) ]),
                 filelib:wildcard("ebin/*.app"), not filelib:is_dir(F) ]),
-    {ok,Sorted} = sort(Pairs),
+    {ok,Sorted} = sort(lists:flatten(Pairs)),
     Sorted.
     Sorted.
 
 
+system_deps(A) ->
+   case file:consult(code:where_is_file(lists:concat([A,".app"]))) of
+        {ok,[{application,Name,Opt}]} -> [ {A,Name} || A <- proplists:get_value(applications,Opt,[]) ];
+        {error,_} -> [] end.
+
 main(_) ->
 main(_) ->
     Ordered = orderapps(),
     Ordered = orderapps(),
     io:format("Ordered: ~p~n\r",[Ordered]),
     io:format("Ordered: ~p~n\r",[Ordered]),