|
|
@ -23,8 +23,8 @@ |
|
|
|
-define(esCfgSync, esCfgSync). |
|
|
|
-define(rootSrcDir, <<"src">>). |
|
|
|
|
|
|
|
-define(logSuccess(Format), canLog(success) andalso io:format("eSync[~p:~p|~p] " ++ Format, [?MODULE, ?FUNCTION_NAME, ?LINE])). |
|
|
|
-define(logSuccess(Format, Args), canLog(success) andalso io:format("eSync[~p:~p|~p] " ++ Format, [?MODULE, ?FUNCTION_NAME, ?LINE] ++ Args)). |
|
|
|
-define(logSuccess(Format), canLog(success) andalso error_logger:info_msg("eSync[~p:~p|~p] " ++ Format, [?MODULE, ?FUNCTION_NAME, ?LINE])). |
|
|
|
-define(logSuccess(Format, Args), canLog(success) andalso error_logger:info_msg("eSync[~p:~p|~p] " ++ Format, [?MODULE, ?FUNCTION_NAME, ?LINE] ++ Args)). |
|
|
|
|
|
|
|
-define(logErrors(Format), canLog(errors) andalso error_logger:info_msg("eSync[~p:~p|~p] " ++ Format, [?MODULE, ?FUNCTION_NAME, ?LINE])). |
|
|
|
-define(logErrors(Format, Args), canLog(errors) andalso error_logger:info_msg("eSync[~p:~p|~p] " ++ Format, [?MODULE, ?FUNCTION_NAME, ?LINE] ++ Args)). |
|
|
@ -235,7 +235,6 @@ handleInfo({Port, {data, Data}}, Status, #state{srcFiles = Srcs, hrlFiles = Hrls |
|
|
|
?logSuccess("eSync connect fileSync success..."), |
|
|
|
%% 然后收集一下监听目录下的src文件 |
|
|
|
{BSrcs, BHrls, BConfigs, BBeams} = collSrcFiles(true), |
|
|
|
?logSuccess("eSync connect fileSync success...222"), |
|
|
|
{nextS, running, State#state{srcFiles = BSrcs, hrlFiles = BHrls, configs = BConfigs, beams = BBeams}, {isHib, true}}; |
|
|
|
_ -> |
|
|
|
?logErrors("error, receive unexpect port msg ~p~n", [Data]), |
|
|
@ -481,7 +480,6 @@ determineIncludeDirFromBeamDir(IncludeBase, IncludeDir, BeamDir) -> |
|
|
|
|
|
|
|
%% get the src dir |
|
|
|
getRootSrcDirFromSrcDir(SrcDir) -> |
|
|
|
?logSuccess("IMY******************getRootSrcDirFromSrcDirSrcDir ~p ~n", [SrcDir]), |
|
|
|
NewDirName = filename:dirname(SrcDir), |
|
|
|
BaseName = filename:basename(SrcDir), |
|
|
|
case BaseName of |
|
|
@ -655,17 +653,12 @@ collSrcFiles(IsAddPath) -> |
|
|
|
{AddExtraSrcDirs, AddOnlySrcDirs, OnlySrcDirs, DelSrcDirs} = mergeExtraDirs(IsAddPath), |
|
|
|
CollFiles = filelib:fold_files(filename:absname(<<"./">>), ?RegExp, true, |
|
|
|
fun(OneFile, {Srcs, Hrls, Configs, Beams} = Acc) -> |
|
|
|
?logSuccess("IMY******************xxx111 ~p ~p ~p ~n", [OneFile, OnlySrcDirs, DelSrcDirs]), |
|
|
|
?logSuccess("IMY******************xxx111xxx ~n", []), |
|
|
|
case isOnlyDir(OnlySrcDirs, OneFile) andalso (not isDelDir(DelSrcDirs, OneFile)) of |
|
|
|
true -> |
|
|
|
?logSuccess("IMY******************xxx1110000 ~n"), |
|
|
|
MTimeSec = dateTimeToSec(filelib:last_modified(OneFile)), |
|
|
|
case filename:extension(OneFile) of |
|
|
|
<<".beam">> -> |
|
|
|
?logSuccess("IMY******************xxx11101111~n"), |
|
|
|
BeamMod = binary_to_atom(filename:basename(OneFile, <<".beam">>)), |
|
|
|
?logSuccess("IMY******************xxx111012222~n"), |
|
|
|
setelement(4, Acc, Beams#{BeamMod => MTimeSec}); |
|
|
|
<<".config">> -> |
|
|
|
setelement(3, Acc, Configs#{OneFile => MTimeSec}); |
|
|
@ -674,7 +667,6 @@ collSrcFiles(IsAddPath) -> |
|
|
|
<<>> -> |
|
|
|
Acc; |
|
|
|
_ -> |
|
|
|
?logSuccess("IMY******************xxx222 ~n"), |
|
|
|
RootSrcDir = |
|
|
|
case getRootSrcDirFromSrcDir(OneFile) of |
|
|
|
undefined -> |
|
|
@ -682,14 +674,11 @@ collSrcFiles(IsAddPath) -> |
|
|
|
RetSrcDir -> |
|
|
|
RetSrcDir |
|
|
|
end, |
|
|
|
?logSuccess("IMY******************xxx333 ~n"), |
|
|
|
case getOptions(RootSrcDir) of |
|
|
|
undefined -> |
|
|
|
Mod = binary_to_atom(filename:basename(OneFile, filename:extension(OneFile))), |
|
|
|
?logSuccess("IMY******************xxx444 ~n"), |
|
|
|
case getModOpts(Mod) of |
|
|
|
{ok, Options} -> |
|
|
|
?logSuccess("IMY******************xxx555 ~n"), |
|
|
|
setOptions(RootSrcDir, Options); |
|
|
|
_ -> |
|
|
|
ignore |
|
|
@ -700,7 +689,6 @@ collSrcFiles(IsAddPath) -> |
|
|
|
setelement(1, Acc, Srcs#{OneFile => MTimeSec}) |
|
|
|
end; |
|
|
|
_ -> |
|
|
|
?logSuccess("IMY******************xxx199900 ~p~n", [OneFile]), |
|
|
|
Acc |
|
|
|
end |
|
|
|
end, {#{}, #{}, #{}, #{}}), |
|
|
@ -765,11 +753,8 @@ isMatchDir([], _SrcDir) -> |
|
|
|
isMatchDir([SrcDir | _ReplaceDirs], SrcDir) -> |
|
|
|
true; |
|
|
|
isMatchDir([OneDir | ReplaceDirs], SrcDir) -> |
|
|
|
?logSuccess("IMY******************isMatchDir ~p ~p ~p ~n", [OneDir, SrcDir, ReplaceDirs]), |
|
|
|
case re:run(SrcDir, OneDir) of |
|
|
|
nomatch -> |
|
|
|
?logSuccess("IMY******************isMatchDir222 ~n", []), |
|
|
|
isMatchDir(ReplaceDirs, SrcDir); |
|
|
|
nomatch -> isMatchDir(ReplaceDirs, SrcDir); |
|
|
|
_ -> true |
|
|
|
end. |
|
|
|
|
|
|
|