mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 19:19:54 +00:00
clean up .yrl and .xrl handling
This commit is contained in:
parent
e6e36834f9
commit
4f470fcddd
1 changed files with 21 additions and 22 deletions
|
@ -41,13 +41,13 @@
|
||||||
-spec compile(Config::#config{}, AppFile::string()) -> 'ok'.
|
-spec compile(Config::#config{}, AppFile::string()) -> 'ok'.
|
||||||
compile(Config, _AppFile) ->
|
compile(Config, _AppFile) ->
|
||||||
rebar_base_compiler:run(Config,
|
rebar_base_compiler:run(Config,
|
||||||
rebar_config:get_list(Config, xrl_yrl_first_files, []),
|
rebar_config:get_list(Config, xrl_first_files, []),
|
||||||
"src", ".xrl", "src", ".erl",
|
"src", ".xrl", "src", ".erl",
|
||||||
fun compile_xrl_yrl/3),
|
fun compile_xrl/3),
|
||||||
rebar_base_compiler:run(Config,
|
rebar_base_compiler:run(Config,
|
||||||
rebar_config:get_list(Config, xrl_yrl_first_files, []),
|
rebar_config:get_list(Config, yrl_first_files, []),
|
||||||
"src", ".yrl", "src", ".erl",
|
"src", ".yrl", "src", ".erl",
|
||||||
fun compile_xrl_yrl/3),
|
fun compile_yrl/3),
|
||||||
doterl_compile(Config, "ebin"),
|
doterl_compile(Config, "ebin"),
|
||||||
rebar_base_compiler:run(Config, rebar_config:get_list(Config, mib_first_files, []),
|
rebar_base_compiler:run(Config, rebar_config:get_list(Config, mib_first_files, []),
|
||||||
"mibs", ".mib", "priv/mibs", ".bin",
|
"mibs", ".mib", "priv/mibs", ".bin",
|
||||||
|
@ -211,12 +211,24 @@ compile_mib(Source, Target, Config) ->
|
||||||
?FAIL
|
?FAIL
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec compile_xrl_yrl(Source::string(), Target::string(), Config::#config{}) -> 'ok'.
|
-spec compile_xrl(Source::string(), Target::string(), Config::#config{}) -> 'ok'.
|
||||||
compile_xrl_yrl(Source, Target, Config) ->
|
compile_xrl(Source, Target, Config) ->
|
||||||
case xrl_yrl_needs_compile(Source, Target) of
|
Opts = [{scannerfile, Target}, {return, true}
|
||||||
|
|rebar_config:get(Config, xrl_opts, [])],
|
||||||
|
compile_xrl_yrl(Source, Target, Config, Opts, leex).
|
||||||
|
|
||||||
|
-spec compile_yrl(Source::string(), Target::string(), Config::#config{}) -> 'ok'.
|
||||||
|
compile_yrl(Source, Target, Config) ->
|
||||||
|
Opts = [{parserfile, Target}, {return, true}
|
||||||
|
|rebar_config:get(Config, yrl_opts, [])],
|
||||||
|
compile_xrl_yrl(Source, Target, Config, Opts, yecc).
|
||||||
|
|
||||||
|
-spec compile_xrl_yrl(Source::string(), Target::string(), Config::#config{},
|
||||||
|
Opts::list(), Mod::atom()) -> 'ok'.
|
||||||
|
compile_xrl_yrl(Source, Target, Config, Opts, Mod) ->
|
||||||
|
case needs_compile(Source, Target, []) of
|
||||||
true ->
|
true ->
|
||||||
{match, [Ext]} = re:run(Source, "[x|y]rl$", [{capture, first, list}]),
|
case Mod:file(Source, Opts) of
|
||||||
case compile_xrl_yrl1(Source, Target, Config, Ext) of
|
|
||||||
{ok, _, []} ->
|
{ok, _, []} ->
|
||||||
ok;
|
ok;
|
||||||
{ok, _, _Warnings} ->
|
{ok, _, _Warnings} ->
|
||||||
|
@ -233,19 +245,6 @@ compile_xrl_yrl(Source, Target, Config) ->
|
||||||
skipped
|
skipped
|
||||||
end.
|
end.
|
||||||
|
|
||||||
compile_xrl_yrl1(Source, Target, Config, "yrl") ->
|
|
||||||
Opts = [{parserfile, Target}, {return, true}
|
|
||||||
|rebar_config:get(Config, yrl_opts, [])],
|
|
||||||
yecc:file(Source, Opts);
|
|
||||||
compile_xrl_yrl1(Source, Target, Config, "xrl") ->
|
|
||||||
Opts = [{scannerfile, Target}, {return, true}
|
|
||||||
|rebar_config:get(Config, xrl_opts, [])],
|
|
||||||
leex:file(Source, Opts).
|
|
||||||
|
|
||||||
-spec xrl_yrl_needs_compile(Source::string(), Target::string()) -> boolean().
|
|
||||||
xrl_yrl_needs_compile(Source, Target) ->
|
|
||||||
filelib:last_modified(Target) < filelib:last_modified(Source).
|
|
||||||
|
|
||||||
gather_src([], Srcs) ->
|
gather_src([], Srcs) ->
|
||||||
Srcs;
|
Srcs;
|
||||||
gather_src([Dir|Rest], Srcs) ->
|
gather_src([Dir|Rest], Srcs) ->
|
||||||
|
|
Loading…
Reference in a new issue