Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: efine/rebar
...
head fork: efine/rebar
  • 7 commits
  • 12 files changed
  • 0 commit comments
  • 2 contributors
View
2  dialyzer_reference
@@ -1,2 +1,2 @@
-rebar_utils.erl:162: Call to missing or unexported function escript:foldl/3
+rebar_utils.erl:163: Call to missing or unexported function escript:foldl/3
View
2  ebin/rebar.app
@@ -3,7 +3,7 @@
{application, rebar,
[{description, "Rebar: Erlang Build Tool"},
- {vsn, "3.0.0"},
+ {vsn, "2.9.0"},
{modules, [ rebar,
rebar_abnfc_compiler,
rebar_app_utils,
View
33 src/rebar_base_compiler.erl
@@ -29,8 +29,7 @@
-include("rebar.hrl").
-export([run/4, run/7, run/8,
- ok_tuple/2, error_tuple/4]).
-
+ ok_tuple/3, error_tuple/5]).
%% ===================================================================
%% Public API
@@ -80,11 +79,12 @@ run(Config, FirstFiles, SourceDir, SourceExt, TargetDir, TargetExt,
simple_compile_wrapper(S, Target, Compile3Fn, C, CheckLastMod)
end).
-ok_tuple(Source, Ws) ->
- {ok, format_warnings(Source, Ws)}.
+ok_tuple(Config, Source, Ws) ->
+ {ok, format_warnings(Config, Source, Ws)}.
-error_tuple(Source, Es, Ws, Opts) ->
- {error, format_errors(Source, Es), format_warnings(Source, Ws, Opts)}.
+error_tuple(Config, Source, Es, Ws, Opts) ->
+ {error, format_errors(Config, Source, Es),
+ format_warnings(Config, Source, Ws, Opts)}.
%% ===================================================================
%% Internal functions
@@ -211,18 +211,18 @@ compile_worker(QueuePid, Config, CompileFn) ->
ok
end.
-format_errors(Source, Errors) ->
- format_errors(Source, "", Errors).
+format_errors(Config, Source, Errors) ->
+ format_errors(Config, Source, "", Errors).
-format_warnings(Source, Warnings) ->
- format_warnings(Source, Warnings, []).
+format_warnings(Config, Source, Warnings) ->
+ format_warnings(Config, Source, Warnings, []).
-format_warnings(Source, Warnings, Opts) ->
+format_warnings(Config, Source, Warnings, Opts) ->
Prefix = case lists:member(warnings_as_errors, Opts) of
true -> "";
false -> "Warning: "
end,
- format_errors(Source, Prefix, Warnings).
+ format_errors(Config, Source, Prefix, Warnings).
maybe_report([{error, {error, _Es, _Ws}=ErrorsAndWarnings}, {source, _}]) ->
maybe_report(ErrorsAndWarnings);
@@ -235,8 +235,13 @@ maybe_report(_) ->
report(Messages) ->
lists:foreach(fun(Msg) -> io:format("~s", [Msg]) end, Messages).
-format_errors(Source, Extra, Errors) ->
- AbsSource = filename:absname(Source),
+format_errors(Config, Source, Extra, Errors) ->
+ AbsSource = case rebar_utils:processing_base_dir(Config) of
+ true ->
+ Source;
+ false ->
+ filename:absname(Source)
+ end,
[[format_error(AbsSource, Extra, Desc) || Desc <- Descs]
|| {_, Descs} <- Errors].
View
5 src/rebar_core.erl
@@ -242,16 +242,13 @@ remember_cwd_subdir(Cwd, Subdirs) ->
maybe_load_local_config(Dir, ParentConfig) ->
%% We need to ensure we don't overwrite custom
%% config when we are dealing with base_dir.
- case processing_base_dir(ParentConfig, Dir) of
+ case rebar_utils:processing_base_dir(ParentConfig, Dir) of
true ->
ParentConfig;
false ->
rebar_config:new(ParentConfig)
end.
-processing_base_dir(Config, Dir) ->
- Dir == rebar_config:get_xconf(Config, base_dir).
-
%%
%% Given a list of directories and a set of previously processed directories,
%% process each one we haven't seen yet
View
81 src/rebar_edoc.erl
@@ -54,18 +54,7 @@ doc(Config, File) ->
{ok, Config1, AppName, _AppData} =
rebar_app_utils:load_app_file(Config, File),
- %% Determine the age of the summary file
- EDocInfoName = filename:join(proplists:get_value(dir, EDocOpts, "doc"),
- "edoc-info"),
- EDocInfoLastMod = filelib:last_modified(EDocInfoName),
-
- %% For each source directory, look for a more recent file than
- %% SumaryLastMod; in that case, we go ahead and do a full regen
- NeedsRegen = newer_file_exists(proplists:get_value(source_path,
- EDocOpts, ["src"]),
- EDocInfoLastMod),
-
- case NeedsRegen of
+ case needs_regen(EDocOpts) of
true ->
?INFO("Regenerating edocs for ~p\n", [AppName]),
ok = edoc:application(AppName, ".", EDocOpts);
@@ -87,33 +76,59 @@ setup_code_path() ->
%% and the like can work properly when generating their own
%% documentation.
CodePath = code:get_path(),
- true = code:add_patha(ebin_dir()),
+ true = code:add_patha(rebar_utils:ebin_dir()),
CodePath.
-ebin_dir() ->
- filename:join(rebar_utils:get_cwd(), "ebin").
+-spec file_modified_since(Filename::string(),
+ SinceTime::non_neg_integer()) -> true | no_return().
+file_modified_since(Filename, SinceTime) ->
+ FLast = filelib:last_modified(Filename),
+ case FLast > SinceTime of
+ true ->
+ throw({newer_file_exists, {Filename, FLast}});
+ false ->
+ false
+ end.
+
+-spec newer_file_exists(Paths::[string()], LastMod::non_neg_integer()) ->
+ false | no_return().
newer_file_exists(Paths, LastMod) ->
- CheckFile = fun(Filename, _) ->
- FLast = filelib:last_modified(Filename),
- case FLast > LastMod of
- true ->
- ?DEBUG("~p is more recent than edoc-info: "
- "~120p > ~120p\n",
- [Filename, FLast, LastMod]),
- throw(newer_file_exists);
- false ->
- false
- end
- end,
+ CheckFile = fun(Fn, _Acc) ->
+ file_modified_since(Fn, LastMod)
+ end,
+ lists:foldl(fun(P, _) ->
+ filelib:fold_files(P, ".*.erl", true,
+ CheckFile, false)
+ end, undefined, Paths),
+ false.
+
+%% Needs regen if any dependent file is changed since the last
+%% edoc run. Dependent files are the erlang source files,
+%% and the overview file, if it exists.
+-spec needs_regen(EDocOpts::edoc:proplist()) -> boolean().
+needs_regen(EDocOpts) ->
+ DocDir = proplists:get_value(dir, EDocOpts, "doc"),
+ OverviewFile = proplists:get_value(overview, EDocOpts, "overview.edoc"),
+ SrcPath = proplists:get_value(source_path, EDocOpts, ["src"]),
+
+ %% Determine the age of the info file
+ EDocInfoName = filename:join(DocDir, "edoc-info"),
+ EDocInfoLastMod = filelib:last_modified(EDocInfoName),
+
+ %% First check if the overview file has changed - no point in
+ %% checking all the source files if we know we have to regen.
+ %% Then, for each source directory, look for a more recent file than
+ %% EDocInfoLastMod.
+ EDocOverviewName = filename:join(DocDir, OverviewFile),
try
- lists:foldl(fun(P, _) ->
- filelib:fold_files(P, ".*.erl", true,
- CheckFile, false)
- end, undefined, Paths),
- false
+ file_modified_since(EDocOverviewName, EDocInfoLastMod) orelse
+ newer_file_exists(SrcPath, EDocInfoLastMod)
catch
- throw:newer_file_exists ->
+ throw: {newer_file_exists, {Filename, FMod}} ->
+ ?DEBUG("~p is more recent than edoc-info: "
+ "~120p > ~120p\n",
+ [Filename, FMod, EDocInfoLastMod]),
true
end.
View
76 src/rebar_erlc_compiler.erl
@@ -87,7 +87,7 @@ compile(Config, _AppFile) ->
fun compile_mib/3),
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) ->
MibFiles = rebar_utils:find_files("mibs", "^.*\\.mib\$"),
MIBs = [filename:rootname(filename:basename(MIB)) || MIB <- MibFiles],
@@ -217,8 +217,7 @@ is_lib_avail(Config, DictKey, Mod, Hrl, Name) ->
{Config, IsAvail}
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, []).
@@ -258,7 +257,7 @@ doterl_compile(Config, OutDir, MoreSources) ->
true = code:add_path(filename:absname("ebin")),
rebar_base_compiler:run(Config, NewFirstErls, OtherErls,
fun(S, C) ->
- internal_erl_compile(S, C, OutDir, ErlOpts)
+ internal_erl_compile(C, S, OutDir, ErlOpts)
end),
true = code:set_path(CurrPath),
ok.
@@ -268,15 +267,15 @@ doterl_compile(Config, OutDir, MoreSources) ->
%% 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) ->
ErlOpts = rebar_config:get(Config, erl_opts, []),
["include", filename:dirname(Source)]
++ 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) ->
ModuleDefault = filename:basename(Source, ".erl"),
case epp:open(Source, IncludePath) of
@@ -287,8 +286,8 @@ inspect(Source, IncludePath) ->
{ModuleDefault, []}
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) ->
case epp:parse_erl_form(Epp) of
{ok, {attribute, _, module, ModInfo}} ->
@@ -323,18 +322,16 @@ inspect_epp(Epp, Source, Module, Includes) ->
inspect_epp(Epp, Source, Module, Includes)
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) ->
TargetLastMod = filelib:last_modified(Target),
lists:any(fun(I) -> TargetLastMod < filelib:last_modified(I) end,
[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
{Module, Hrls} = inspect(Source, include_path(Source, Config)),
@@ -352,16 +349,17 @@ internal_erl_compile(Source, Config, Outdir, ErlOpts) ->
{ok, _Mod} ->
ok;
{ok, _Mod, Ws} ->
- rebar_base_compiler:ok_tuple(Source, Ws);
+ rebar_base_compiler:ok_tuple(Config, Source, Ws);
{error, Es, Ws} ->
- rebar_base_compiler:error_tuple(Source, Es, Ws, Opts)
+ rebar_base_compiler:error_tuple(Config, Source,
+ Es, Ws, Opts)
end;
false ->
skipped
end.
--spec compile_mib(Source::file:filename(), Target::file:filename(),
- Config::rebar_config:config()) -> 'ok'.
+-spec compile_mib(file:filename(), file:filename(),
+ rebar_config:config()) -> 'ok'.
compile_mib(Source, Target, Config) ->
ok = rebar_utils:ensure_dir(Target),
ok = rebar_utils:ensure_dir(filename:join("include", "dummy.hrl")),
@@ -378,30 +376,31 @@ compile_mib(Source, Target, Config) ->
?FAIL
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) ->
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) ->
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
true ->
case Mod:file(Source, Opts ++ [{return, true}]) of
{ok, _} ->
ok;
{ok, _Mod, Ws} ->
- rebar_base_compiler:ok_tuple(Source, Ws);
+ rebar_base_compiler:ok_tuple(Config, Source, Ws);
{error, Es, Ws} ->
- rebar_base_compiler:error_tuple(Source, Es, Ws, Opts)
+ rebar_base_compiler:error_tuple(Config, Source,
+ Es, Ws, Opts)
end;
false ->
skipped
@@ -413,21 +412,20 @@ gather_src([Dir|Rest], Srcs) ->
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) ->
[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, []) ->
file:del_dir(Dir);
delete_dir(Dir, Subdirs) ->
lists:foreach(fun(D) -> delete_dir(D, dirs(D)) end, Subdirs),
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) ->
case epp_dodger:parse_file(File) of
{error, _} ->
@@ -462,7 +460,7 @@ compile_priority(File) ->
%%
%% 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_file(F) || F <- FileList].
View
2  src/rebar_erlydtl_compiler.erl
@@ -83,7 +83,7 @@
compile(Config, _AppFile) ->
DtlOpts = erlydtl_opts(Config),
OrigPath = code:get_path(),
- true = code:add_path(filename:join(rebar_utils:get_cwd(), "ebin")),
+ true = code:add_path(rebar_utils:ebin_dir()),
Result = rebar_base_compiler:run(Config, [],
option(doc_root, DtlOpts),
option(source_ext, DtlOpts),
View
5 src/rebar_lfe_compiler.erl
@@ -63,9 +63,10 @@ compile_lfe(Source, _Target, Config) ->
++ rebar_config:get_list(Config, erl_opts, []),
case lfe_comp:file(Source, Opts) of
{ok, _Mod, Ws} ->
- rebar_base_compiler:ok_tuple(Source, Ws);
+ rebar_base_compiler:ok_tuple(Config, Source, Ws);
{error, Es, Ws} ->
- rebar_base_compiler:error_tuple(Source, Es, Ws, Opts);
+ rebar_base_compiler:error_tuple(Config, Source,
+ Es, Ws, Opts);
_ ->
?FAIL
end
View
25 src/rebar_port_compiler.erl
@@ -100,7 +100,7 @@ compile(Config, _AppFile) ->
SharedEnv = rebar_config:get_env(Config, ?MODULE),
%% Compile each of the sources
- NewBins = compile_sources(Specs, SharedEnv),
+ NewBins = compile_sources(Config, Specs, SharedEnv),
%% Make sure that the target directories exist
?INFO("Using specs ~p\n", [Specs]),
@@ -177,16 +177,16 @@ replace_extension(File, OldExt, NewExt) ->
%% == compile and link ==
%%
-compile_sources(Specs, SharedEnv) ->
+compile_sources(Config, Specs, SharedEnv) ->
lists:foldl(
fun(#spec{sources=Sources, type=Type, opts=Opts}, NewBins) ->
Env = proplists:get_value(env, Opts, SharedEnv),
- compile_each(Sources, Type, Env, NewBins)
+ compile_each(Config, Sources, Type, Env, NewBins)
end, [], Specs).
-compile_each([], _Type, _Env, NewBins) ->
+compile_each(_Config, [], _Type, _Env, NewBins) ->
lists:reverse(NewBins);
-compile_each([Source | Rest], Type, Env, NewBins) ->
+compile_each(Config, [Source | Rest], Type, Env, NewBins) ->
Ext = filename:extension(Source),
Bin = replace_extension(Source, Ext, ".o"),
case needs_compile(Source, Bin) of
@@ -194,17 +194,22 @@ compile_each([Source | Rest], Type, Env, NewBins) ->
Template = select_compile_template(Type, compiler(Ext)),
Cmd = expand_command(Template, Env, Source, Bin),
ShOpts = [{env, Env}, return_on_error, {use_stdout, false}],
- exec_compiler(Source, Cmd, ShOpts),
- compile_each(Rest, Type, Env, [Bin | NewBins]);
+ exec_compiler(Config, Source, Cmd, ShOpts),
+ compile_each(Config, Rest, Type, Env, [Bin | NewBins]);
false ->
?INFO("Skipping ~s\n", [Source]),
- compile_each(Rest, Type, Env, NewBins)
+ compile_each(Config, Rest, Type, Env, NewBins)
end.
-exec_compiler(Source, Cmd, ShOpts) ->
+exec_compiler(Config, Source, Cmd, ShOpts) ->
case rebar_utils:sh(Cmd, ShOpts) of
{error, {_RC, RawError}} ->
- AbsSource = filename:absname(Source),
+ AbsSource = case rebar_utils:processing_base_dir(Config) of
+ true ->
+ Source;
+ false ->
+ filename:absname(Source)
+ end,
?CONSOLE("Compiling ~s\n", [AbsSource]),
Error = re:replace(RawError, Source, AbsSource,
[{return, list}, global]),
View
5 src/rebar_shell.erl
@@ -38,7 +38,7 @@ shell(_Config, _AppFile) ->
%% for the "top level" directory
case is_deps_dir(rebar_utils:get_cwd()) of
false ->
- true = code:add_pathz(ebin_dir()),
+ true = code:add_pathz(rebar_utils:ebin_dir()),
user_drv:start(),
%% this call never returns (until user quits shell)
shell:server(false, false);
@@ -47,9 +47,6 @@ shell(_Config, _AppFile) ->
end,
ok.
-ebin_dir() ->
- filename:join(rebar_utils:get_cwd(), "ebin").
-
is_deps_dir(Dir) ->
case lists:reverse(filename:split(Dir)) of
[_, "deps" | _] ->
View
17 src/rebar_utils.erl
@@ -51,7 +51,8 @@
erl_opts/1,
src_dirs/1,
test_dir/0,
- ebin_dir/0]).
+ ebin_dir/0,
+ processing_base_dir/1, processing_base_dir/2]).
-include("rebar.hrl").
@@ -301,17 +302,24 @@ erl_opts(Config) ->
[debug_info|Opts]
end.
--spec src_dirs(SrcDirs::[string()]) -> [file:filename(), ...].
+-spec src_dirs([string()]) -> [file:filename(), ...].
src_dirs([]) ->
["src"];
src_dirs(SrcDirs) ->
SrcDirs.
test_dir() ->
- filename:join(rebar_utils:get_cwd(), ?TEST_DIR).
+ filename:join(get_cwd(), ?TEST_DIR).
ebin_dir() ->
- filename:join(rebar_utils:get_cwd(), "ebin").
+ filename:join(get_cwd(), "ebin").
+
+processing_base_dir(Config) ->
+ Cwd = rebar_utils:get_cwd(),
+ processing_base_dir(Config, Cwd).
+
+processing_base_dir(Config, Dir) ->
+ Dir =:= rebar_config:get_xconf(Config, base_dir).
%% ====================================================================
%% Internal functions
@@ -489,7 +497,6 @@ vcs_vsn_invoke(Cmd, Dir) ->
%% 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().
filter_defines([], Acc) ->
lists:reverse(Acc);
filter_defines([{platform_define, ArchRegex, Key} | Rest], Acc) ->
View
2  src/rebar_xref.erl
@@ -53,7 +53,7 @@ xref(Config, _) ->
%% Save the code path prior to doing anything
OrigPath = code:get_path(),
- true = code:add_path(filename:join(rebar_utils:get_cwd(), "ebin")),
+ true = code:add_path(rebar_utils:ebin_dir()),
%% Get list of xref checks we want to run
XrefChecks = rebar_config:get(Config, xref_checks,

No commit comments for this range

Something went wrong with that request. Please try again.