在工作中,经常遇到需要停下手上的功能修复以往功能的bug
只编译指定的文件就很有必要

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
%% @doc 编译指定文件
%% @spec m([File::string()]) -> up_to_date | error.
%% <pre>
%% m(["a", "b"])
%% </pre>
m(FileList) ->
ComFileList = get_file_list(FileList, []),
Rtn = make:files(ComFileList),
Rtn.

get_file_list([], FileList) -> FileList;
get_file_list([File|List], FileList) ->
{ok, [{DirList, _}]} = file:consult("./Emakefile"),
F = fun(Dir, L) ->
WildCard = io_lib:format("~s*~s*.erl", [Dir, File]),
L ++ filelib:wildcard(WildCard)
end,
NewFileList = lists:foldl(F, [], DirList) ++ FileList,
get_file_list(List, NewFileList).