|
@@ -11,17 +11,23 @@ compile(Dir,Config) ->
|
|
[] -> [false];
|
|
[] -> [false];
|
|
X -> compile_port(Dir,X,Config) end.
|
|
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/"),
|
|
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
|
|
[ 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,
|
|
Args = string:strip(replace_env(Template,Env),both,32),
|
|
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),
|
|
{_,Status,Report} = sh:run("cc",string:tokens(Args," "),binary,Dir,Env),
|
|
case Status of
|
|
case Status of
|
|
0 -> false;
|
|
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 ].
|