|
@ -87,7 +87,7 @@ compile(Config, _AppFile) -> |
|
|
fun compile_mib/3), |
|
|
fun compile_mib/3), |
|
|
doterl_compile(Config, "ebin"). |
|
|
doterl_compile(Config, "ebin"). |
|
|
|
|
|
|
|
|
-spec clean(Config::rebar_config:config(), AppFile::file:filename()) -> 'ok'. |
|
|
|
|
|
|
|
|
-spec clean(rebar_config:config(), file:filename()) -> 'ok'. |
|
|
clean(_Config, _AppFile) -> |
|
|
clean(_Config, _AppFile) -> |
|
|
MibFiles = rebar_utils:find_files("mibs", "^.*\\.mib\$"), |
|
|
MibFiles = rebar_utils:find_files("mibs", "^.*\\.mib\$"), |
|
|
MIBs = [filename:rootname(filename:basename(MIB)) || MIB <- MibFiles], |
|
|
MIBs = [filename:rootname(filename:basename(MIB)) || MIB <- MibFiles], |
|
@ -217,8 +217,7 @@ is_lib_avail(Config, DictKey, Mod, Hrl, Name) -> |
|
|
{Config, IsAvail} |
|
|
{Config, IsAvail} |
|
|
end. |
|
|
end. |
|
|
|
|
|
|
|
|
-spec doterl_compile(Config::rebar_config:config(), |
|
|
|
|
|
OutDir::file:filename()) -> 'ok'. |
|
|
|
|
|
|
|
|
-spec doterl_compile(rebar_config:config(), file:filename()) -> 'ok'. |
|
|
doterl_compile(Config, OutDir) -> |
|
|
doterl_compile(Config, OutDir) -> |
|
|
doterl_compile(Config, OutDir, []). |
|
|
doterl_compile(Config, OutDir, []). |
|
|
|
|
|
|
|
@ -258,7 +257,7 @@ doterl_compile(Config, OutDir, MoreSources) -> |
|
|
true = code:add_path(filename:absname("ebin")), |
|
|
true = code:add_path(filename:absname("ebin")), |
|
|
rebar_base_compiler:run(Config, NewFirstErls, OtherErls, |
|
|
rebar_base_compiler:run(Config, NewFirstErls, OtherErls, |
|
|
fun(S, C) -> |
|
|
fun(S, C) -> |
|
|
internal_erl_compile(S, C, OutDir, ErlOpts) |
|
|
|
|
|
|
|
|
internal_erl_compile(C, S, OutDir, ErlOpts) |
|
|
end), |
|
|
end), |
|
|
true = code:set_path(CurrPath), |
|
|
true = code:set_path(CurrPath), |
|
|
ok. |
|
|
ok. |
|
@ -268,15 +267,15 @@ doterl_compile(Config, OutDir, MoreSources) -> |
|
|
%% Internal functions |
|
|
%% Internal functions |
|
|
%% =================================================================== |
|
|
%% =================================================================== |
|
|
|
|
|
|
|
|
-spec include_path(Source::file:filename(), |
|
|
|
|
|
Config::rebar_config:config()) -> [file:filename(), ...]. |
|
|
|
|
|
|
|
|
-spec include_path(file:filename(), |
|
|
|
|
|
rebar_config:config()) -> [file:filename(), ...]. |
|
|
include_path(Source, Config) -> |
|
|
include_path(Source, Config) -> |
|
|
ErlOpts = rebar_config:get(Config, erl_opts, []), |
|
|
ErlOpts = rebar_config:get(Config, erl_opts, []), |
|
|
["include", filename:dirname(Source)] |
|
|
["include", filename:dirname(Source)] |
|
|
++ proplists:get_all_values(i, ErlOpts). |
|
|
++ proplists:get_all_values(i, ErlOpts). |
|
|
|
|
|
|
|
|
-spec inspect(Source::file:filename(), |
|
|
|
|
|
IncludePath::[file:filename(), ...]) -> {string(), [string()]}. |
|
|
|
|
|
|
|
|
-spec inspect(file:filename(), |
|
|
|
|
|
[file:filename(), ...]) -> {string(), [string()]}. |
|
|
inspect(Source, IncludePath) -> |
|
|
inspect(Source, IncludePath) -> |
|
|
ModuleDefault = filename:basename(Source, ".erl"), |
|
|
ModuleDefault = filename:basename(Source, ".erl"), |
|
|
case epp:open(Source, IncludePath) of |
|
|
case epp:open(Source, IncludePath) of |
|
@ -287,8 +286,8 @@ inspect(Source, IncludePath) -> |
|
|
{ModuleDefault, []} |
|
|
{ModuleDefault, []} |
|
|
end. |
|
|
end. |
|
|
|
|
|
|
|
|
-spec inspect_epp(Epp::pid(), Source::file:filename(), Module::file:filename(), |
|
|
|
|
|
Includes::[string()]) -> {string(), [string()]}. |
|
|
|
|
|
|
|
|
-spec inspect_epp(pid(), file:filename(), file:filename(), |
|
|
|
|
|
[string()]) -> {string(), [string()]}. |
|
|
inspect_epp(Epp, Source, Module, Includes) -> |
|
|
inspect_epp(Epp, Source, Module, Includes) -> |
|
|
case epp:parse_erl_form(Epp) of |
|
|
case epp:parse_erl_form(Epp) of |
|
|
{ok, {attribute, _, module, ModInfo}} -> |
|
|
{ok, {attribute, _, module, ModInfo}} -> |
|
@ -323,18 +322,16 @@ inspect_epp(Epp, Source, Module, Includes) -> |
|
|
inspect_epp(Epp, Source, Module, Includes) |
|
|
inspect_epp(Epp, Source, Module, Includes) |
|
|
end. |
|
|
end. |
|
|
|
|
|
|
|
|
-spec needs_compile(Source::file:filename(), Target::file:filename(), |
|
|
|
|
|
Hrls::[string()]) -> boolean(). |
|
|
|
|
|
|
|
|
-spec needs_compile(file:filename(), file:filename(), |
|
|
|
|
|
[string()]) -> boolean(). |
|
|
needs_compile(Source, Target, Hrls) -> |
|
|
needs_compile(Source, Target, Hrls) -> |
|
|
TargetLastMod = filelib:last_modified(Target), |
|
|
TargetLastMod = filelib:last_modified(Target), |
|
|
lists:any(fun(I) -> TargetLastMod < filelib:last_modified(I) end, |
|
|
lists:any(fun(I) -> TargetLastMod < filelib:last_modified(I) end, |
|
|
[Source] ++ Hrls). |
|
|
[Source] ++ Hrls). |
|
|
|
|
|
|
|
|
-spec internal_erl_compile(Source::file:filename(), |
|
|
|
|
|
Config::rebar_config:config(), |
|
|
|
|
|
Outdir::file:filename(), |
|
|
|
|
|
ErlOpts::list()) -> 'ok' | 'skipped'. |
|
|
|
|
|
internal_erl_compile(Source, Config, Outdir, ErlOpts) -> |
|
|
|
|
|
|
|
|
-spec internal_erl_compile(rebar_config:config(), file:filename(), |
|
|
|
|
|
file:filename(), list()) -> 'ok' | 'skipped'. |
|
|
|
|
|
internal_erl_compile(Config, Source, Outdir, ErlOpts) -> |
|
|
%% Determine the target name and includes list by inspecting the source file |
|
|
%% Determine the target name and includes list by inspecting the source file |
|
|
{Module, Hrls} = inspect(Source, include_path(Source, Config)), |
|
|
{Module, Hrls} = inspect(Source, include_path(Source, Config)), |
|
|
|
|
|
|
|
@ -352,17 +349,18 @@ internal_erl_compile(Source, Config, Outdir, ErlOpts) -> |
|
|
{ok, _Mod} -> |
|
|
{ok, _Mod} -> |
|
|
ok; |
|
|
ok; |
|
|
{ok, _Mod, Ws} -> |
|
|
{ok, _Mod, Ws} -> |
|
|
rebar_base_compiler:ok_tuple(Source, Ws); |
|
|
|
|
|
|
|
|
rebar_base_compiler:ok_tuple(Config, Source, Ws); |
|
|
{error, Es, Ws} -> |
|
|
{error, Es, Ws} -> |
|
|
rebar_base_compiler:error_tuple(Source, Es, Ws, Opts) |
|
|
|
|
|
|
|
|
rebar_base_compiler:error_tuple(Config, Source, |
|
|
|
|
|
Es, Ws, Opts) |
|
|
end; |
|
|
end; |
|
|
false -> |
|
|
false -> |
|
|
skipped |
|
|
skipped |
|
|
end. |
|
|
end. |
|
|
|
|
|
|
|
|
-spec compile_mib(Source::file:filename(), Target::file:filename(), |
|
|
|
|
|
Config::rebar_config:config()) -> 'ok'. |
|
|
|
|
|
compile_mib(Source, Target, Config) -> |
|
|
|
|
|
|
|
|
-spec compile_mib(rebar_config:config(), file:filename(), |
|
|
|
|
|
file:filename()) -> 'ok'. |
|
|
|
|
|
compile_mib(Config, Source, Target) -> |
|
|
ok = rebar_utils:ensure_dir(Target), |
|
|
ok = rebar_utils:ensure_dir(Target), |
|
|
ok = rebar_utils:ensure_dir(filename:join("include", "dummy.hrl")), |
|
|
ok = rebar_utils:ensure_dir(filename:join("include", "dummy.hrl")), |
|
|
Opts = [{outdir, "priv/mibs"}, {i, ["priv/mibs"]}] ++ |
|
|
Opts = [{outdir, "priv/mibs"}, {i, ["priv/mibs"]}] ++ |
|
@ -378,30 +376,31 @@ compile_mib(Source, Target, Config) -> |
|
|
?FAIL |
|
|
?FAIL |
|
|
end. |
|
|
end. |
|
|
|
|
|
|
|
|
-spec compile_xrl(Source::file:filename(), Target::file:filename(), |
|
|
|
|
|
Config::rebar_config:config()) -> 'ok'. |
|
|
|
|
|
|
|
|
-spec compile_xrl(file:filename(), file:filename(), |
|
|
|
|
|
rebar_config:config()) -> 'ok'. |
|
|
compile_xrl(Source, Target, Config) -> |
|
|
compile_xrl(Source, Target, Config) -> |
|
|
Opts = [{scannerfile, Target} | rebar_config:get(Config, xrl_opts, [])], |
|
|
Opts = [{scannerfile, Target} | rebar_config:get(Config, xrl_opts, [])], |
|
|
compile_xrl_yrl(Source, Target, Opts, leex). |
|
|
|
|
|
|
|
|
compile_xrl_yrl(Config, Source, Target, Opts, leex). |
|
|
|
|
|
|
|
|
-spec compile_yrl(Source::file:filename(), Target::file:filename(), |
|
|
|
|
|
Config::rebar_config:config()) -> 'ok'. |
|
|
|
|
|
|
|
|
-spec compile_yrl(file:filename(), file:filename(), |
|
|
|
|
|
rebar_config:config()) -> 'ok'. |
|
|
compile_yrl(Source, Target, Config) -> |
|
|
compile_yrl(Source, Target, Config) -> |
|
|
Opts = [{parserfile, Target} | rebar_config:get(Config, yrl_opts, [])], |
|
|
Opts = [{parserfile, Target} | rebar_config:get(Config, yrl_opts, [])], |
|
|
compile_xrl_yrl(Source, Target, Opts, yecc). |
|
|
|
|
|
|
|
|
compile_xrl_yrl(Config, Source, Target, Opts, yecc). |
|
|
|
|
|
|
|
|
-spec compile_xrl_yrl(Source::file:filename(), Target::file:filename(), |
|
|
|
|
|
Opts::list(), Mod::atom()) -> 'ok'. |
|
|
|
|
|
compile_xrl_yrl(Source, Target, Opts, Mod) -> |
|
|
|
|
|
|
|
|
-spec compile_xrl_yrl(rebar_config:config(), file:filename(), |
|
|
|
|
|
file:filename(), list(), module()) -> 'ok'. |
|
|
|
|
|
compile_xrl_yrl(Config, Source, Target, Opts, Mod) -> |
|
|
case needs_compile(Source, Target, []) of |
|
|
case needs_compile(Source, Target, []) of |
|
|
true -> |
|
|
true -> |
|
|
case Mod:file(Source, Opts ++ [{return, true}]) of |
|
|
case Mod:file(Source, Opts ++ [{return, true}]) of |
|
|
{ok, _} -> |
|
|
{ok, _} -> |
|
|
ok; |
|
|
ok; |
|
|
{ok, _Mod, Ws} -> |
|
|
{ok, _Mod, Ws} -> |
|
|
rebar_base_compiler:ok_tuple(Source, Ws); |
|
|
|
|
|
|
|
|
rebar_base_compiler:ok_tuple(Config, Source, Ws); |
|
|
{error, Es, Ws} -> |
|
|
{error, Es, Ws} -> |
|
|
rebar_base_compiler:error_tuple(Source, Es, Ws, Opts) |
|
|
|
|
|
|
|
|
rebar_base_compiler:error_tuple(Config, Source, |
|
|
|
|
|
Es, Ws, Opts) |
|
|
end; |
|
|
end; |
|
|
false -> |
|
|
false -> |
|
|
skipped |
|
|
skipped |
|
@ -413,21 +412,20 @@ gather_src([Dir|Rest], Srcs) -> |
|
|
gather_src(Rest, Srcs ++ rebar_utils:find_files(Dir, ".*\\.erl\$")). |
|
|
gather_src(Rest, Srcs ++ rebar_utils:find_files(Dir, ".*\\.erl\$")). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-spec dirs(Dir::file:filename()) -> [file:filename()]. |
|
|
|
|
|
|
|
|
-spec dirs(file:filename()) -> [file:filename()]. |
|
|
dirs(Dir) -> |
|
|
dirs(Dir) -> |
|
|
[F || F <- filelib:wildcard(filename:join([Dir, "*"])), filelib:is_dir(F)]. |
|
|
[F || F <- filelib:wildcard(filename:join([Dir, "*"])), filelib:is_dir(F)]. |
|
|
|
|
|
|
|
|
-spec delete_dir(Dir::file:filename(), |
|
|
|
|
|
Subdirs::[string()]) -> 'ok' | {'error', atom()}. |
|
|
|
|
|
|
|
|
-spec delete_dir(file:filename(), [string()]) -> 'ok' | {'error', atom()}. |
|
|
delete_dir(Dir, []) -> |
|
|
delete_dir(Dir, []) -> |
|
|
file:del_dir(Dir); |
|
|
file:del_dir(Dir); |
|
|
delete_dir(Dir, Subdirs) -> |
|
|
delete_dir(Dir, Subdirs) -> |
|
|
lists:foreach(fun(D) -> delete_dir(D, dirs(D)) end, Subdirs), |
|
|
lists:foreach(fun(D) -> delete_dir(D, dirs(D)) end, Subdirs), |
|
|
file:del_dir(Dir). |
|
|
file:del_dir(Dir). |
|
|
|
|
|
|
|
|
-spec compile_priority(File::file:filename()) -> 'normal' | 'behaviour' | |
|
|
|
|
|
'callback' | |
|
|
|
|
|
'parse_transform'. |
|
|
|
|
|
|
|
|
-spec compile_priority(file:filename()) -> 'normal' | 'behaviour' | |
|
|
|
|
|
'callback' | |
|
|
|
|
|
'parse_transform'. |
|
|
compile_priority(File) -> |
|
|
compile_priority(File) -> |
|
|
case epp_dodger:parse_file(File) of |
|
|
case epp_dodger:parse_file(File) of |
|
|
{error, _} -> |
|
|
{error, _} -> |
|
@ -462,7 +460,7 @@ compile_priority(File) -> |
|
|
%% |
|
|
%% |
|
|
%% Ensure all files in a list are present and abort if one is missing |
|
|
%% Ensure all files in a list are present and abort if one is missing |
|
|
%% |
|
|
%% |
|
|
-spec check_files(FileList::[file:filename()]) -> [file:filename()]. |
|
|
|
|
|
|
|
|
-spec check_files([file:filename()]) -> [file:filename()]. |
|
|
check_files(FileList) -> |
|
|
check_files(FileList) -> |
|
|
[check_file(F) || F <- FileList]. |
|
|
[check_file(F) || F <- FileList]. |
|
|
|
|
|
|
|
|