Namdak Tonpa 8 лет назад
Родитель
Сommit
419450295c
3 измененных файлов с 13 добавлено и 7 удалено
  1. 1 1
      include/mad.hrl
  2. BIN
      mad
  3. 12 6
      src/compile/mad_port.erl

+ 1 - 1
include/mad.hrl

@@ -1 +1 @@
--define(VERSION,"9c196a").
+-define(VERSION,"451634").


+ 12 - 6
src/compile/mad_port.erl

@@ -11,17 +11,23 @@ compile(Dir,Config) ->
         [] -> [false];
          X -> compile_port(Dir,X,Config) end.
 
-compile_port(Dir,Specs,Config) ->
-    {_,S} = os:type(),
-    System = atom_to_list(S),
+compile_port(Dir,Specs0,Config) ->
+    {_,Flavour} = os:type(),
+    System = atom_to_list(Flavour),
+    Specs = [ {O,F} || {Sys,O,F} <- Specs0, Sys == System] ++
+            [ {O,F} || {O,F} <- Specs0],
     filelib:ensure_dir(Dir ++ "/priv/"),
-    Env = [ {Var,Val} || {Sys,Var,Val} <- mad_utils:get_value(port_env, Config, []), Sys == System ],
+    Env =  [ {Var,Val} || {Sys,Var,Val} <- mad_utils:get_value(port_env, Config, []), Sys == System ] ++
+          [ {Var,Val} || {Var,Val} <- mad_utils:get_value(port_env, Config, []) ] ++
+           [{"LDFLAGS",[]},{"CFLAGS",[]}],
     [ begin
            Template = string:join(filelib:wildcard(Dir ++ "/" ++ Files)," ") 
               ++ " CFLAGS LDFLAGS -o " ++ Dir ++ "/" ++ Out,
        Args = string:strip(replace_env(Template,Env),both,32),
+       %mad:info("Args: ~p~n",[Args]),
+       %mad:info("Env: ~p~n",[Env]),
        {_,Status,Report} = sh:run("cc",string:tokens(Args," "),binary,Dir,Env),
        case Status of
           0 -> false;
-          _ -> mad:info("Port Compilation Error: ~p",[Report]), true end
-      end || {Sys,Out,Files} <- Specs, Sys == System].
+          _ -> mad:info("Port Compilation Error:~n" ++ io_lib:format("~ts",[Report]),[]), true end
+      end || {Out,Files} <- Specs ].