Browse Source

mad with ports compilation

Maxim Sokhatsky 10 years ago
parent
commit
f12ebf7159
3 changed files with 5 additions and 7 deletions
  1. BIN
      mad
  2. 0 1
      rebar.config
  3. 5 6
      src/mad_compile.erl

BIN
mad


+ 0 - 1
rebar.config

@@ -1,3 +1,2 @@
-{cache,"~/.mad/repos"}.
 {deps_dir,"deps"}.
 {deps_dir,"deps"}.
 {deps, [{sh, ".*", {git, "git://github.com/synrc/sh", "HEAD"}}]}.
 {deps, [{sh, ".*", {git, "git://github.com/synrc/sh", "HEAD"}}]}.

+ 5 - 6
src/mad_compile.erl

@@ -63,17 +63,16 @@ port(Dir,Config) ->
 
 
 compile_port(Dir,Specs,Config) ->
 compile_port(Dir,Specs,Config) ->
     {_,System} = os:type(),
     {_,System} = os:type(),
+    filelib:ensure_dir(Dir ++ "/priv/"),
     Env = [ {Var,Val} || {System,Var,Val} <- mad_utils:get_value(port_env, Config, []) ],
     Env = [ {Var,Val} || {System,Var,Val} <- mad_utils:get_value(port_env, Config, []) ],
     [ begin 
     [ begin 
            Template = string:join(filelib:wildcard(Dir ++"/" ++ Files)," ") 
            Template = string:join(filelib:wildcard(Dir ++"/" ++ Files)," ") 
               ++ " CFLAGS LDFLAGS -o " ++ Dir ++ "/" ++ Out,
               ++ " CFLAGS LDFLAGS -o " ++ Dir ++ "/" ++ Out,
-%       Template = string:join(filelib:wildcard(Files)," ") 
-%              ++ " CFLAGS LDFLAGS -o " ++ Out,
-       io:format("Template: ~p",[Template]),
        Args = string:strip(replace_env(Template,Env),both,32),
        Args = string:strip(replace_env(Template,Env),both,32),
-       io:format("Compile Port~n Dir: ~p, Files: ~p, Env: ~p",[Dir,Args,Env]),
-       Res = sh:run("cc",string:tokens(Args," "),binary,Dir,Env),
-       io:format("Compile Result: ~p",[Res])
+       {Atom,Status,Report} = sh:run("cc",string:tokens(Args," "),binary,Dir,Env),
+       case Status == 0 of
+          true -> skip;
+          false -> io:format("Port Compilation Error: ~p",[Report]) end
       end || {System,Out,Files} <- Specs].
       end || {System,Out,Files} <- Specs].
 
 
 replace_env(String, []) -> String;
 replace_env(String, []) -> String;