summaryrefslogtreecommitdiff
path: root/src/rebar_erlc_compiler.erl
diff options
context:
space:
mode:
authorTuncer Ayaz <tuncer.ayaz@gmail.com>2011-03-10 15:07:41 +0100
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2011-03-28 18:39:38 +0200
commit6d75bfbeb0c981e25c1b30b481118ea52a3b377e (patch)
treee8a311712291c0290b908f2d2f83ab9ed00a56ec /src/rebar_erlc_compiler.erl
parent68f47435636cb72e6088fb68eacf5aad764f13cd (diff)
Clean up specs
Diffstat (limited to 'src/rebar_erlc_compiler.erl')
-rw-r--r--src/rebar_erlc_compiler.erl57
1 files changed, 30 insertions, 27 deletions
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index df9e1c0..a9a8360 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -67,7 +67,7 @@
%% 'old_inets'}]}.
%%
--spec compile(Config::#config{}, AppFile::string()) -> 'ok'.
+-spec compile(Config::rebar_config:config(), AppFile::file:filename()) -> 'ok'.
compile(Config, _AppFile) ->
rebar_base_compiler:run(Config,
check_files(rebar_config:get_local(
@@ -86,7 +86,7 @@ compile(Config, _AppFile) ->
"mibs", ".mib", "priv/mibs", ".bin",
fun compile_mib/3).
--spec clean(Config::#config{}, AppFile::string()) -> 'ok'.
+-spec clean(Config::rebar_config:config(), AppFile::file:filename()) -> 'ok'.
clean(_Config, _AppFile) ->
lists:foreach(fun(F) -> ok = rebar_file_utils:rm_rf(F) end,
["ebin/*.beam", "priv/mibs/*.bin"]),
@@ -94,7 +94,7 @@ clean(_Config, _AppFile) ->
YrlFiles = rebar_utils:find_files("src", "^.*\\.[x|y]rl\$"),
rebar_file_utils:delete_each(
[ binary_to_list(iolist_to_binary(re:replace(F, "\\.[x|y]rl$", ".erl")))
- || F <- YrlFiles ]),
+ || F <- YrlFiles ]),
%% Erlang compilation is recursive, so it's possible that we have a nested
%% directory structure in ebin with .beam files within. As such, we want
@@ -110,7 +110,8 @@ clean(_Config, _AppFile) ->
%% .erl Compilation API (externally used by only eunit)
%% ===================================================================
--spec doterl_compile(Config::#config{}, OutDir::string()) -> 'ok'.
+-spec doterl_compile(Config::rebar_config:config(),
+ OutDir::file:filename()) -> 'ok'.
doterl_compile(Config, OutDir) ->
doterl_compile(Config, OutDir, []).
@@ -165,14 +166,15 @@ doterl_compile(Config, OutDir, MoreSources) ->
%% Internal functions
%% ===================================================================
--spec include_path(Source::string(), Config::#config{}) -> [string(), ...].
+-spec include_path(Source::file:filename(),
+ Config::rebar_config:config()) -> [file:filename(), ...].
include_path(Source, Config) ->
ErlOpts = rebar_config:get(Config, erl_opts, []),
["include", filename:dirname(Source)]
++ proplists:get_all_values(i, ErlOpts).
--spec inspect(Source::string(),
- IncludePath::[string(),...]) -> {string(), [string()]}.
+-spec inspect(Source::file:filename(),
+ IncludePath::[file:filename(), ...]) -> {string(), [string()]}.
inspect(Source, IncludePath) ->
ModuleDefault = filename:basename(Source, ".erl"),
case epp:open(Source, IncludePath) of
@@ -183,7 +185,7 @@ inspect(Source, IncludePath) ->
{ModuleDefault, []}
end.
--spec inspect_epp(Epp::pid(), Source::string(), Module::string(),
+-spec inspect_epp(Epp::pid(), Source::file:filename(), Module::file:filename(),
Includes::[string()]) -> {string(), [string()]}.
inspect_epp(Epp, Source, Module, Includes) ->
case epp:parse_erl_form(Epp) of
@@ -218,15 +220,16 @@ inspect_epp(Epp, Source, Module, Includes) ->
inspect_epp(Epp, Source, Module, Includes)
end.
--spec needs_compile(Source::string(), Target::string(),
+-spec needs_compile(Source::file:filename(), Target::file:filename(),
Hrls::[string()]) -> boolean().
needs_compile(Source, Target, Hrls) ->
TargetLastMod = filelib:last_modified(Target),
lists:any(fun(I) -> TargetLastMod < filelib:last_modified(I) end,
[Source] ++ Hrls).
--spec internal_erl_compile(Source::string(), Config::#config{},
- Outdir::string(),
+-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) ->
%% Determine the target name and includes list by inspecting the source file
@@ -237,7 +240,7 @@ internal_erl_compile(Source, Config, Outdir, ErlOpts) ->
ok = filelib:ensure_dir(Target),
%% If the file needs compilation, based on last mod date of includes or
- %% the target,
+ %% the target
case needs_compile(Source, Target, Hrls) of
true ->
Opts = [{outdir, filename:dirname(Target)}] ++
@@ -263,8 +266,8 @@ internal_erl_compile(Source, Config, Outdir, ErlOpts) ->
skipped
end.
--spec compile_mib(Source::string(), Target::string(),
- Config::#config{}) -> 'ok'.
+-spec compile_mib(Source::file:filename(), Target::file:filename(),
+ Config::rebar_config:config()) -> 'ok'.
compile_mib(Source, Target, Config) ->
ok = rebar_utils:ensure_dir(Target),
Opts = [{outdir, "priv/mibs"}, {i, ["priv/mibs"]}] ++
@@ -276,22 +279,22 @@ compile_mib(Source, Target, Config) ->
?FAIL
end.
--spec compile_xrl(Source::string(), Target::string(),
- Config::#config{}) -> 'ok'.
+-spec compile_xrl(Source::file:filename(), Target::file:filename(),
+ Config::rebar_config:config()) -> 'ok'.
compile_xrl(Source, Target, Config) ->
Opts = [{scannerfile, Target}, {return, true}
|rebar_config:get(Config, xrl_opts, [])],
compile_xrl_yrl(Source, Target, Opts, leex).
--spec compile_yrl(Source::string(), Target::string(),
- Config::#config{}) -> 'ok'.
+-spec compile_yrl(Source::file:filename(), Target::file:filename(),
+ Config::rebar_config:config()) -> 'ok'.
compile_yrl(Source, Target, Config) ->
Opts = [{parserfile, Target}, {return, true}
|rebar_config:get(Config, yrl_opts, [])],
compile_xrl_yrl(Source, Target, Opts, yecc).
--spec compile_xrl_yrl(Source::string(), Target::string(), Opts::list(),
- Mod::atom()) -> 'ok'.
+-spec compile_xrl_yrl(Source::file:filename(), Target::file:filename(),
+ Opts::list(), Mod::atom()) -> 'ok'.
compile_xrl_yrl(Source, Target, Opts, Mod) ->
case needs_compile(Source, Target, []) of
true ->
@@ -317,17 +320,17 @@ gather_src([], Srcs) ->
gather_src([Dir|Rest], Srcs) ->
gather_src(Rest, Srcs ++ rebar_utils:find_files(Dir, ".*\\.erl\$")).
--spec src_dirs(SrcDirs::[string()]) -> [string(),...].
+-spec src_dirs(SrcDirs::[string()]) -> [file:filename(), ...].
src_dirs([]) ->
["src"];
src_dirs(SrcDirs) ->
SrcDirs ++ src_dirs([]).
--spec dirs(Dir::string()) -> [string()].
+-spec dirs(Dir::file:filename()) -> [file:filename()].
dirs(Dir) ->
[F || F <- filelib:wildcard(filename:join([Dir, "*"])), filelib:is_dir(F)].
--spec delete_dir(Dir::string(),
+-spec delete_dir(Dir::file:filename(),
Subdirs::[string()]) -> 'ok' | {'error', atom()}.
delete_dir(Dir, []) ->
file:del_dir(Dir);
@@ -335,8 +338,8 @@ delete_dir(Dir, Subdirs) ->
lists:foreach(fun(D) -> delete_dir(D, dirs(D)) end, Subdirs),
file:del_dir(Dir).
--spec compile_priority(File::string()) -> 'normal' | 'behaviour' |
- 'parse_transform'.
+-spec compile_priority(File::file:filename()) -> 'normal' | 'behaviour' |
+ 'parse_transform'.
compile_priority(File) ->
case epp_dodger:parse_file(File) of
{error, _} ->
@@ -369,7 +372,7 @@ compile_priority(File) ->
%% Filter a list of erl_opts platform_define options such that only
%% those which match the provided architecture regex are returned.
%%
--spec filter_defines(ErlOpts::list(),Acc::list()) -> list().
+-spec filter_defines(ErlOpts::list(), Acc::list()) -> list().
filter_defines([], Acc) ->
lists:reverse(Acc);
filter_defines([{platform_define, ArchRegex, Key} | Rest], Acc) ->
@@ -392,7 +395,7 @@ filter_defines([Opt | Rest], Acc) ->
%%
%% Ensure all files in a list are present and abort if one is missing
%%
--spec check_files(FileList::[string()]) -> [string()].
+-spec check_files(FileList::[file:filename()]) -> [file:filename()].
check_files(FileList) ->
[check_file(F) || F <- FileList].