Skip to content

Commit

Permalink
indent, add error
Browse files Browse the repository at this point in the history
  • Loading branch information
mihawk committed Nov 23, 2016
1 parent 45143eb commit b5a0591
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/compile/mad_port.erl
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,26 @@ compile_port(Dir,Specs0,Config) ->
end,[],[Compile(F) || F <- Files]),

%%if any ok recompile target
case Res of {error,_} = Err -> Err; Res ->
case lists:any(fun({ok,_}) -> true;(_)->false end, Res) of
false -> false; %% all even, no need to link target
true -> Objs = [O||{_,O} <-Res],
Env2 = [{"PORT_IN_FILES", string:join(Objs," ")},
{"PORT_OUT_FILE", Target}] ++ Env ++ default_env(),
TplLD = tpl_ld(TargetType,LinkLang),
CmdLD = string:strip(expand(System,TplLD,Env2)),
Cmd = expand(System,CmdLD,[{"CXXFLAGS",""},{"LDFLAGS",""},{"CFLAGS",""}]),
mad:info("cc ~s~n",[Cmd]),
{_,Status,Report} = sh:run("cc",string:tokens(Cmd," "),binary,Dir,Env),
case Status of
0 -> false;
_ -> mad:info("Port Compilation Error:~n" ++ io_lib:format("~ts",[Report]),[]),
{error, Report},true
end
end
case Res of
{error,_} = Err ->
mad:info("Port Compilation Error:~n" ++ io_lib:format("~p",[Err]),[]),true;
Res ->
case lists:any(fun({ok,_}) -> true;(_)->false end, Res) of
false -> false; %% all even, no need to link target
true -> Objs = [O||{_,O} <-Res],
Env2 = [{"PORT_IN_FILES", string:join(Objs," ")},
{"PORT_OUT_FILE", Target}] ++ Env ++ default_env(),
TplLD = tpl_ld(TargetType,LinkLang),
CmdLD = string:strip(expand(System,TplLD,Env2)),
Cmd = expand(System,CmdLD,[{"CXXFLAGS",""},{"LDFLAGS",""},{"CFLAGS",""}]),
mad:info("cc ~s~n",[Cmd]),
{_,Status,Report} = sh:run("cc",string:tokens(Cmd," "),binary,Dir,Env),
case Status of
0 -> false;
_ -> mad:info("Port Compilation Error:~n" ++ io_lib:format("~ts",[Report]),[]),
{error, Report},true
end
end
end
end,
[Job(S)||S<-Specs].
Expand Down

0 comments on commit b5a0591

Please sign in to comment.