|
@@ -31,31 +31,42 @@ compile_port(Dir,Specs0,Config) ->
|
|
Env1 = [{"PORT_IN_FILES", F},{"PORT_OUT_FILE", Obj}] ++ Env ++ default_env(),
|
|
Env1 = [{"PORT_IN_FILES", F},{"PORT_OUT_FILE", Obj}] ++ Env ++ default_env(),
|
|
CmdCC = string:strip(expand(System,TplCC,Env1)),
|
|
CmdCC = string:strip(expand(System,TplCC,Env1)),
|
|
Cmd = expand(System,CmdCC,[{"CXXFLAGS",""},{"LDFLAGS",""},{"CFLAGS",""}]),
|
|
Cmd = expand(System,CmdCC,[{"CXXFLAGS",""},{"LDFLAGS",""},{"CFLAGS",""}]),
|
|
|
|
+ mad:info("cc ~s~n",[Cmd]),
|
|
{_,Status,Report} = sh:run("cc",string:tokens(Cmd," "),binary,Dir,Env),
|
|
{_,Status,Report} = sh:run("cc",string:tokens(Cmd," "),binary,Dir,Env),
|
|
case Status of
|
|
case Status of
|
|
- 0 -> {ok,Obj};
|
|
|
|
|
|
+ 0 -> {ok,Obj} ;
|
|
_ -> {error, "Port Compilation Error:~n" ++ io_lib:format("~ts",[Report])},true
|
|
_ -> {error, "Port Compilation Error:~n" ++ io_lib:format("~ts",[Report])},true
|
|
end;
|
|
end;
|
|
- true -> {ok,Obj}
|
|
|
|
|
|
+ true -> {even,Obj}
|
|
end
|
|
end
|
|
end,
|
|
end,
|
|
|
|
|
|
- Res = lists:foldl(fun({ok,X},Acc) -> [X|Acc];
|
|
|
|
|
|
+ Res = lists:foldl(fun({ok,X},Acc) -> [{ok,X}|Acc];
|
|
|
|
+ ({even,X},Acc) -> [{even,X}|Acc];
|
|
({error,Err},_)-> {error,Err}
|
|
({error,Err},_)-> {error,Err}
|
|
end,[],[Compile(F) || F <- Files]),
|
|
end,[],[Compile(F) || F <- Files]),
|
|
- case Res of
|
|
|
|
- {error, _}=Err -> Err;
|
|
|
|
- Objs -> 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",""}]),
|
|
|
|
- {_,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
|
|
|
|
|
|
+
|
|
|
|
+ %%if any ok recompile target
|
|
|
|
+ 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
|
|
end,
|
|
end,
|
|
[Job(S)||S<-Specs].
|
|
[Job(S)||S<-Specs].
|