summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--README.md7
-rwxr-xr-xbootstrap6
-rw-r--r--ebin/rebar.app8
-rw-r--r--include/rebar.hrl2
-rw-r--r--priv/shell-completion/bash/rebar4
-rw-r--r--src/rebar.erl24
-rw-r--r--src/rebar_abnfc_compiler.erl4
-rw-r--r--src/rebar_asn1_compiler.erl2
-rw-r--r--src/rebar_base_compiler.erl4
-rw-r--r--src/rebar_core.erl80
-rw-r--r--src/rebar_ct.erl8
-rw-r--r--src/rebar_deps.erl2
-rw-r--r--src/rebar_edoc.erl51
-rw-r--r--src/rebar_erlc_compiler.erl6
-rw-r--r--src/rebar_erlydtl_compiler.erl4
-rw-r--r--src/rebar_escripter.erl4
-rw-r--r--src/rebar_eunit.erl2
-rw-r--r--src/rebar_file_utils.erl2
-rw-r--r--src/rebar_lfe_compiler.erl4
-rw-r--r--src/rebar_neotoma_compiler.erl4
-rw-r--r--src/rebar_otp_app.erl8
-rw-r--r--src/rebar_protobuffs_compiler.erl4
-rw-r--r--src/rebar_reltool.erl36
-rw-r--r--src/rebar_utils.erl8
-rw-r--r--src/rebar_xref.erl2
26 files changed, 195 insertions, 96 deletions
diff --git a/Makefile b/Makefile
index 6f307c5..1fda878 100644
--- a/Makefile
+++ b/Makefile
@@ -20,3 +20,8 @@ dialyzer: dialyzer_warnings
dialyzer_warnings:
-@dialyzer -q -n ebin -Wunmatched_returns -Werror_handling \
-Wrace_conditions > dialyzer_warnings
+
+binary: VSN = $(shell ./rebar -V)
+binary: clean all
+ cp rebar ../rebar.wiki/rebar
+ (cd ../rebar.wiki && git commit -m "Update $(VSN)" rebar) \ No newline at end of file
diff --git a/README.md b/README.md
index 74e3392..443475e 100644
--- a/README.md
+++ b/README.md
@@ -27,15 +27,14 @@ Should you want to clone the rebar repository, you will also require git.
#### Downloading
-Clone the git repository:
+You can download a pre-built binary version of rebar from:
-```sh
-$ git clone git://github.com/basho/rebar.git
-```
+https://github.com/basho/rebar/wiki/rebar
#### Building rebar
```sh
+$ git clone git://github.com/basho/rebar.git
$ cd rebar
$ ./bootstrap
Recompile: src/getopt
diff --git a/bootstrap b/bootstrap
index e86ad8e..c8a40de 100755
--- a/bootstrap
+++ b/bootstrap
@@ -24,12 +24,16 @@ main(Args) ->
false -> undefined
end,
+ %% Extract the system info of the version of OTP we use to compile rebar
+ OtpInfo = string:strip(erlang:system_info(otp_release), both, $\n),
+
%% Compile all src/*.erl to ebin
case make:files(filelib:wildcard("src/*.erl"),
[{outdir, "ebin"}, {i, "include"},
DebugFlag,
{d, 'BUILD_TIME', Built},
- {d, 'VCS_INFO', VcsInfo}]) of
+ {d, 'VCS_INFO', VcsInfo},
+ {d, 'OTP_INFO', OtpInfo}]) of
up_to_date ->
ok;
error ->
diff --git a/ebin/rebar.app b/ebin/rebar.app
index 0c6e4c3..111a4c6 100644
--- a/ebin/rebar.app
+++ b/ebin/rebar.app
@@ -3,7 +3,7 @@
{application, rebar,
[{description, "Rebar: Erlang Build Tool"},
- {vsn, "2"},
+ {vsn, "2.0.0"},
{modules, [ rebar,
rebar_abnfc_compiler,
rebar_appups,
@@ -40,7 +40,11 @@
{registered, []},
{applications, [kernel,
stdlib,
- sasl]},
+ sasl,
+ compiler,
+ crypto,
+ syntax_tools,
+ tools]},
{env, [
%% Default log level
{log_level, error},
diff --git a/include/rebar.hrl b/include/rebar.hrl
index 0f4e90f..7568898 100644
--- a/include/rebar.hrl
+++ b/include/rebar.hrl
@@ -1,5 +1,5 @@
--define(FAIL, throw({error, failed})).
+-define(ABORT, rebar_utils:abort()).
-define(ABORT(Str, Args), rebar_utils:abort(Str, Args)).
-define(CONSOLE(Str, Args), io:format(Str, Args)).
diff --git a/priv/shell-completion/bash/rebar b/priv/shell-completion/bash/rebar
index 964c1ad..005325d 100644
--- a/priv/shell-completion/bash/rebar
+++ b/priv/shell-completion/bash/rebar
@@ -8,8 +8,8 @@ _rebar()
prev="${COMP_WORDS[COMP_CWORD-1]}"
sopts="-h -c -v -V -f -j"
lopts=" --help --commands --verbose --force --jobs= --version"
- cmdsnvars="check-deps clean compile create create-app create-node \
- ct doc delete-deps eunit get-deps generate generate-upgrade \
+ cmdsnvars="check-deps clean compile create create-app create-node ct \
+ doc delete-deps escriptize eunit get-deps generate generate-upgrade \
help list-deps list-templates update-deps version xref overlay \
apps= case= force=1 jobs= suites= verbose=1 appid= previous_release= \
nodeid= root_dir= skip_deps=true skip_apps= template= template_dir="
diff --git a/src/rebar.erl b/src/rebar.erl
index 1f72a4c..e11df3a 100644
--- a/src/rebar.erl
+++ b/src/rebar.erl
@@ -41,6 +41,10 @@
-define(VCS_INFO, "undefined").
-endif.
+-ifndef(OTP_INFO).
+-define(OTP_INFO, "undefined").
+-endif.
+
%% ====================================================================
%% Public API
%% ====================================================================
@@ -49,13 +53,13 @@ main(Args) ->
case catch(run(Args)) of
ok ->
ok;
- {error, failed} ->
- halt(1);
+ rebar_abort ->
+ rebar_utils:delayed_halt(1);
Error ->
%% Nothing should percolate up from rebar_core;
%% Dump this error to console
io:format("Uncaught error in rebar_core: ~p\n", [Error]),
- halt(1)
+ rebar_utils:delayed_halt(1)
end.
%% ====================================================================
@@ -158,6 +162,9 @@ parse_args(Args) ->
rebar_config:set_global(enable_profiling,
proplists:get_bool(profile, Options)),
+ %% Setup flag to keep running after a single command fails
+ rebar_config:set_global(keep_going, proplists:get_bool(keep_going, Options)),
+
%% Set global variables based on getopt options
set_log_level(Options),
set_global_flag(Options, force),
@@ -182,7 +189,7 @@ parse_args(Args) ->
{error, {Reason, Data}} ->
?ERROR("~s ~p~n~n", [Reason, Data]),
help(),
- halt(1)
+ rebar_utils:delayed_halt(1)
end.
%%
@@ -202,8 +209,8 @@ set_log_level(Options) ->
%%
version() ->
{ok, Vsn} = application:get_key(rebar, vsn),
- ?CONSOLE("rebar version: ~s date: ~s vcs: ~s\n",
- [Vsn, ?BUILD_TIME, ?VCS_INFO]).
+ ?CONSOLE("rebar ~s ~s ~s ~s\n",
+ [Vsn, ?OTP_INFO, ?BUILD_TIME, ?VCS_INFO]).
%%
@@ -229,7 +236,7 @@ show_info_maybe_halt(Opts, NonOptArgs) ->
[] ->
?CONSOLE("No command to run specified!~n",[]),
help(),
- halt(1);
+ rebar_utils:delayed_halt(1);
_ ->
ok
end.
@@ -300,7 +307,8 @@ option_spec_list() ->
{defines, $D, undefined, string, "Define compiler macro"},
{jobs, $j, "jobs", integer, JobsHelp},
{config, $C, "config", string, "Rebar config file to use"},
- {profile, $p, "profile", undefined, "Profile this run of rebar"}
+ {profile, $p, "profile", undefined, "Profile this run of rebar"},
+ {keep_going, $k, "keep-going", undefined, "Keep running after a command fails"}
].
%%
diff --git a/src/rebar_abnfc_compiler.erl b/src/rebar_abnfc_compiler.erl
index 0e6749a..cb56854 100644
--- a/src/rebar_abnfc_compiler.erl
+++ b/src/rebar_abnfc_compiler.erl
@@ -90,7 +90,7 @@ compile_abnfc(Source, _Target, Config) ->
" https://github.com/nygge/abnfc~n"
" and install it into your erlang library dir~n"
"===============================================~n~n", []),
- ?FAIL;
+ ?ABORT;
true ->
AbnfcOpts = abnfc_opts(Config),
SourceExt = option(source_ext, AbnfcOpts),
@@ -103,6 +103,6 @@ compile_abnfc(Source, _Target, Config) ->
Error ->
?ERROR("Compiling grammar ~s failed:~n ~p~n",
[Source, Error]),
- ?FAIL
+ ?ABORT
end
end.
diff --git a/src/rebar_asn1_compiler.erl b/src/rebar_asn1_compiler.erl
index 40129c9..c9dca1f 100644
--- a/src/rebar_asn1_compiler.erl
+++ b/src/rebar_asn1_compiler.erl
@@ -65,7 +65,7 @@ compile_asn1(Source, Target, Config) ->
ok
end;
{error, _Reason} ->
- ?FAIL
+ ?ABORT
end.
asn_generated_files(AsnDir, SrcDir, IncDir) ->
diff --git a/src/rebar_base_compiler.erl b/src/rebar_base_compiler.erl
index 10a495d..b4308e5 100644
--- a/src/rebar_base_compiler.erl
+++ b/src/rebar_base_compiler.erl
@@ -149,7 +149,7 @@ compile_queue(Pids, Targets) ->
{fail, Error} ->
?DEBUG("Worker compilation failed: ~p\n", [Error]),
- ?FAIL;
+ ?ABORT;
{compiled, Source} ->
?CONSOLE("Compiled ~s\n", [Source]),
@@ -166,7 +166,7 @@ compile_queue(Pids, Targets) ->
{'DOWN', _Mref, _, _Pid, Info} ->
?DEBUG("Worker failed: ~p\n", [Info]),
- ?FAIL
+ ?ABORT
end.
compile_worker(QueuePid, Config, CompileFn) ->
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index 484b446..14ff754 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -64,35 +64,51 @@ skip_dirs() ->
%% ===================================================================
process_commands([], _ParentConfig) ->
- case erlang:get(operations) of
- 0 ->
- %% none of the commands had an effect
- ?FAIL;
+ AbortTrapped = rebar_config:get_global(abort_trapped, false),
+ case {erlang:get(operations), AbortTrapped} of
+ {0, _} ->
+ %% None of the commands had any effect
+ ?ABORT;
+ {_, true} ->
+ %% An abort was previously trapped
+ ?ABORT;
_ ->
ok
end;
process_commands([Command | Rest], ParentConfig) ->
- %% Reset skip dirs
- lists:foreach(fun (D) -> erlang:erase({skip_dir, D}) end, skip_dirs()),
- Operations = erlang:get(operations),
-
- %% Convert the code path so that all the entries are absolute paths.
- %% If not, code:set_path() may choke on invalid relative paths when trying
- %% to restore the code path from inside a subdirectory.
- true = rebar_utils:expand_code_path(),
- _ = process_dir(rebar_utils:get_cwd(), ParentConfig,
- Command, sets:new()),
- case erlang:get(operations) of
- Operations ->
- %% This command didn't do anything
- ?CONSOLE("Command '~p' not understood or not applicable~n",
- [Command]);
- _ ->
- ok
+ try
+ %% Reset skip dirs
+ lists:foreach(fun (D) -> erlang:erase({skip_dir, D}) end, skip_dirs()),
+ Operations = erlang:get(operations),
+
+ %% Convert the code path so that all the entries are absolute paths.
+ %% If not, code:set_path() may choke on invalid relative paths when trying
+ %% to restore the code path from inside a subdirectory.
+ true = rebar_utils:expand_code_path(),
+ _ = process_dir(rebar_utils:get_cwd(), ParentConfig,
+ Command, sets:new()),
+ case erlang:get(operations) of
+ Operations ->
+ %% This command didn't do anything
+ ?CONSOLE("Command '~p' not understood or not applicable~n",
+ [Command]);
+ _ ->
+ ok
+ end,
+ %% Wipe out vsn cache to avoid invalid hits when
+ %% dependencies are updated
+ ets:delete_all_objects(rebar_vsn_cache)
+ catch
+ throw:rebar_abort ->
+ case rebar_config:get_global(keep_going, false) of
+ false ->
+ ?ABORT;
+ true ->
+ ?WARN("Continuing on after abort: ~p\n", [Rest]),
+ rebar_config:set_global(abort_trapped, true),
+ ok
+ end
end,
- %% Wipe out vsn cache to avoid invalid hits when
- %% dependencies are updated
- ets:delete_all_objects(rebar_vsn_cache),
process_commands(Rest, ParentConfig).
@@ -104,10 +120,12 @@ process_dir(Dir, ParentConfig, Command, DirSet) ->
true ->
AbsDir = filename:absname(Dir),
- case processing_base_dir(Dir) of
- false ->
- ?CONSOLE("==> Entering directory `~s'\n", [AbsDir]);
+ ShouldPrintDir = not (is_skip_dir(Dir) orelse processing_base_dir(Dir)),
+
+ case ShouldPrintDir of
true ->
+ ?CONSOLE("==> Entering directory `~s'\n", [AbsDir]);
+ _ ->
ok
end,
@@ -128,10 +146,10 @@ process_dir(Dir, ParentConfig, Command, DirSet) ->
Res = maybe_process_dir(ModuleSet, Config, CurrentCodePath,
Dir, Command, DirSet),
- case processing_base_dir(Dir) of
- false ->
- ?CONSOLE("==> Leaving directory `~s'\n", [AbsDir]);
+ case ShouldPrintDir of
true ->
+ ?CONSOLE("==> Leaving directory `~s'\n", [AbsDir]);
+ false ->
ok
end,
@@ -360,7 +378,7 @@ execute(Command, Modules, Config, ModuleFile, Env) ->
apply_hooks(post_hooks, Config, Command, Env),
ok;
{error, failed} ->
- ?FAIL;
+ ?ABORT;
{Module, {error, _} = Other} ->
?ABORT("~p failed while processing ~s in module ~s: ~s\n",
[Command, Dir, Module,
diff --git a/src/rebar_ct.erl b/src/rebar_ct.erl
index b8060b2..27a01e8 100644
--- a/src/rebar_ct.erl
+++ b/src/rebar_ct.erl
@@ -83,7 +83,7 @@ clear_log(RawLog) ->
ok = file:write_file(RawLog, LogHeader);
{error, Reason} ->
?ERROR("Could not create log dir - ~p\n", [Reason]),
- ?FAIL
+ ?ABORT
end.
%% calling ct with erl does not return non-zero on failure - have to check
@@ -98,12 +98,12 @@ check_log(RawLog) ->
MakeFailed ->
show_log(RawLog),
?ERROR("Building tests failed\n",[]),
- ?FAIL;
+ ?ABORT;
RunFailed ->
show_log(RawLog),
?ERROR("One or more tests failed\n",[]),
- ?FAIL;
+ ?ABORT;
true ->
?CONSOLE("DONE.\n~s\n", [Msg])
@@ -263,7 +263,7 @@ find_suite_path(Suite, TestDir) ->
case filelib:is_regular(Path) of
false ->
?ERROR("Suite ~s not found\n", [Suite]),
- ?FAIL;
+ ?ABORT;
true ->
Path
end.
diff --git a/src/rebar_deps.erl b/src/rebar_deps.erl
index f06eb76..dc2fe84 100644
--- a/src/rebar_deps.erl
+++ b/src/rebar_deps.erl
@@ -123,7 +123,7 @@ setup_env(_Config) ->
?CONSOLE("Dependency not available: "
"~p-~s (~p)\n", [App, Vsn, Src])
end, MissingDeps),
- ?FAIL
+ ?ABORT
end.
'get-deps'(Config, _) ->
diff --git a/src/rebar_edoc.erl b/src/rebar_edoc.erl
index 27e0015..b2cd671 100644
--- a/src/rebar_edoc.erl
+++ b/src/rebar_edoc.erl
@@ -50,9 +50,31 @@
doc(Config, File) ->
%% Save code path
CodePath = setup_code_path(),
- {ok, AppName, _AppData} = rebar_app_utils:load_app_file(File),
+
+ %% Get the edoc_opts and app file info
EDocOpts = rebar_config:get(Config, edoc_opts, []),
- ok = edoc:application(AppName, ".", EDocOpts),
+ {ok, AppName, _AppData} = rebar_app_utils:load_app_file(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
+ true ->
+ ?INFO("Regenerating edocs for ~p\n", [AppName]),
+ ok = edoc:application(AppName, ".", EDocOpts);
+ false ->
+ ?INFO("Skipping regeneration of edocs for ~p\n", [AppName]),
+ ok
+ end,
+
%% Restore code path
true = code:set_path(CodePath),
ok.
@@ -71,3 +93,28 @@ setup_code_path() ->
ebin_dir() ->
filename:join(rebar_utils:get_cwd(), "ebin").
+
+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,
+ try
+ lists:foldl(fun(P, _) ->
+ filelib:fold_files(P, ".*.erl", true,
+ CheckFile, false)
+ end, undefined, Paths),
+ false
+ catch
+ throw:newer_file_exists ->
+ true
+ end.
+
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index 6535324..dc700e1 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -261,7 +261,7 @@ internal_erl_compile(Source, Config, Outdir, ErlOpts) ->
{ok, _} ->
ok;
_ ->
- ?FAIL
+ ?ABORT
end;
false ->
skipped
@@ -282,7 +282,7 @@ compile_mib(Source, Target, Config) ->
rebar_file_utils:mv(Hrl_filename, "include"),
ok;
{error, compilation_failed} ->
- ?FAIL
+ ?ABORT
end.
-spec compile_xrl(Source::file:filename(), Target::file:filename(),
@@ -306,7 +306,7 @@ compile_xrl_yrl(Source, Target, Opts, Mod) ->
{ok, _} ->
ok;
_X ->
- ?FAIL
+ ?ABORT
end;
false ->
skipped
diff --git a/src/rebar_erlydtl_compiler.erl b/src/rebar_erlydtl_compiler.erl
index 9c47a63..2a9cb63 100644
--- a/src/rebar_erlydtl_compiler.erl
+++ b/src/rebar_erlydtl_compiler.erl
@@ -120,7 +120,7 @@ compile_dtl(Source, Target, Config) ->
" http://code.google.com/p/erlydtl/~n"
" and install it into your erlang library dir~n"
"===============================================~n~n", []),
- ?FAIL;
+ ?ABORT;
_ ->
case needs_compile(Source, Target, Config) of
true ->
@@ -146,7 +146,7 @@ do_compile(Source, Target, Config) ->
Reason ->
?ERROR("Compiling template ~s failed:~n ~p~n",
[Source, Reason]),
- ?FAIL
+ ?ABORT
end.
module_name(Target) ->
diff --git a/src/rebar_escripter.erl b/src/rebar_escripter.erl
index f7f45ba..0d091c8 100644
--- a/src/rebar_escripter.erl
+++ b/src/rebar_escripter.erl
@@ -69,12 +69,12 @@ escriptize(Config, AppFile) ->
{error, WriteError} ->
?ERROR("Failed to write ~p script: ~p\n",
[AppName, WriteError]),
- ?FAIL
+ ?ABORT
end;
{error, ZipError} ->
?ERROR("Failed to construct ~p escript: ~p\n",
[AppName, ZipError]),
- ?FAIL
+ ?ABORT
end,
%% Finally, update executable perms for our script
diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl
index b34ad84..d1e847b 100644
--- a/src/rebar_eunit.erl
+++ b/src/rebar_eunit.erl
@@ -329,7 +329,7 @@ cover_init(true, BeamFiles) ->
[] ->
%% No modules compiled successfully...fail
?ERROR("Cover failed to compile any modules; aborting.~n", []),
- ?FAIL;
+ ?ABORT;
_ ->
%% At least one module compiled successfully
diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl
index 2a782f0..6eb2ab1 100644
--- a/src/rebar_file_utils.erl
+++ b/src/rebar_file_utils.erl
@@ -106,7 +106,7 @@ delete_each([File | Rest]) ->
delete_each(Rest);
{error, Reason} ->
?ERROR("Failed to delete file ~s: ~p\n", [File, Reason]),
- ?FAIL
+ ?ABORT
end.
%% ===================================================================
diff --git a/src/rebar_lfe_compiler.erl b/src/rebar_lfe_compiler.erl
index d2c2dfe..3fe30b9 100644
--- a/src/rebar_lfe_compiler.erl
+++ b/src/rebar_lfe_compiler.erl
@@ -57,7 +57,7 @@ compile_lfe(Source, _Target, Config) ->
" {git, \"git://github.com/rvirding/lfe\",~n"
" {tag, \"v0.6.1\"}}}~n"
"~n", []),
- ?FAIL;
+ ?ABORT;
_ ->
Opts = [{i, "include"}, {outdir, "ebin"}, report]
++ rebar_config:get_list(Config, erl_opts, []),
@@ -65,6 +65,6 @@ compile_lfe(Source, _Target, Config) ->
{ok, _} ->
ok;
_ ->
- ?FAIL
+ ?ABORT
end
end.
diff --git a/src/rebar_neotoma_compiler.erl b/src/rebar_neotoma_compiler.erl
index 9bff892..d0f618f 100644
--- a/src/rebar_neotoma_compiler.erl
+++ b/src/rebar_neotoma_compiler.erl
@@ -80,7 +80,7 @@ compile_neo(Source, Target, Config) ->
" https://github.com/seancribbs/neotoma~n"
" and install it into your erlang library dir~n"
"===============================================~n~n", []),
- ?FAIL;
+ ?ABORT;
_ ->
case needs_compile(Source, Target, Config) of
true ->
@@ -104,7 +104,7 @@ do_compile(Source, _Target, Config) ->
Reason ->
?ERROR("Compiling peg ~s failed:~n ~p~n",
[Source, Reason]),
- ?FAIL
+ ?ABORT
end.
needs_compile(Source, Target, Config) ->
diff --git a/src/rebar_otp_app.erl b/src/rebar_otp_app.erl
index 89730a6..0b2e8be 100644
--- a/src/rebar_otp_app.erl
+++ b/src/rebar_otp_app.erl
@@ -146,12 +146,12 @@ validate_name(AppName, File) ->
false ->
?ERROR("Invalid ~s: name of application (~p) "
"must match filename.\n", [File, AppName]),
- ?FAIL
+ ?ABORT
end.
validate_modules(AppName, undefined) ->
?ERROR("Missing modules declaration in ~p.app~n", [AppName]),
- ?FAIL;
+ ?ABORT;
validate_modules(AppName, Mods) ->
%% Construct two sets -- one for the actual .beam files in ebin/
@@ -169,7 +169,7 @@ validate_modules(AppName, Mods) ->
M <- MissingBeams]),
?ERROR("One or more modules listed in ~p.app are not "
"present in ebin/*.beam:\n~s", [AppName, Msg1]),
- ?FAIL
+ ?ABORT
end,
%% Identify .beam files NOT list in the .app, but present in ebin/
@@ -181,7 +181,7 @@ validate_modules(AppName, Mods) ->
M <- MissingMods]),
?ERROR("One or more .beam files exist that are not "
"listed in ~p.app:\n~s", [AppName, Msg2]),
- ?FAIL
+ ?ABORT
end.
ebin_modules() ->
diff --git a/src/rebar_protobuffs_compiler.erl b/src/rebar_protobuffs_compiler.erl
index 249588c..ea34d4f 100644
--- a/src/rebar_protobuffs_compiler.erl
+++ b/src/rebar_protobuffs_compiler.erl
@@ -53,7 +53,7 @@ compile(_Config, _AppFile) ->
false ->
?ERROR("Protobuffs library not present in code path!\n",
[]),
- ?FAIL
+ ?ABORT
end
end.
@@ -115,7 +115,7 @@ compile_each([{Proto, Beam, Hrl} | Rest]) ->
Other ->
?ERROR("Protobuff compile of ~s failed: ~p\n",
[Proto, Other]),
- ?FAIL
+ ?ABORT
end;
false ->
ok
diff --git a/src/rebar_reltool.erl b/src/rebar_reltool.erl
index 42c7f15..cf817e8 100644
--- a/src/rebar_reltool.erl
+++ b/src/rebar_reltool.erl
@@ -58,10 +58,10 @@ generate(Config, ReltoolFile) ->
ok ->
ok;
{error, failed} ->
- ?FAIL;
+ ?ABORT;
Other2 ->
?ERROR("Unexpected error: ~p\n", [Other2]),
- ?FAIL
+ ?ABORT
end.
overlay(_Config, ReltoolFile) ->
@@ -223,7 +223,7 @@ run_reltool(Server, _Config, ReltoolConfig) ->
mk_target_dir(TargetDir) ->
- case file:make_dir(TargetDir) of
+ case filelib:ensure_dir(filename:join(TargetDir, "dummy")) of
ok ->
ok;
{error, eexist} ->
@@ -235,8 +235,12 @@ mk_target_dir(TargetDir) ->
_ ->
?ERROR("Release target directory ~p already exists!\n",
[TargetDir]),
- ?FAIL
- end
+ ?ABORT
+ end;
+ {error, Reason} ->
+ ?ERROR("Failed to make target dir ~p: ~s\n",
+ [TargetDir, file:format_error(Reason)]),
+ ?ABORT
end.
@@ -255,7 +259,8 @@ dump_spec(Spec) ->
execute_overlay([], _Vars, _BaseDir, _TargetDir) ->
ok;
execute_overlay([{mkdir, Out} | Rest], Vars, BaseDir, TargetDir) ->
- OutFile = rebar_templater:render(filename:join([TargetDir, Out, "dummy"]), Vars),
+ OutFile = rebar_templater:render(
+ filename:join([TargetDir, Out, "dummy"]), Vars),
ok = filelib:ensure_dir(OutFile),
?DEBUG("Created dir ~s\n", [filename:dirname(OutFile)]),
execute_overlay(Rest, Vars, BaseDir, TargetDir);
@@ -272,16 +277,19 @@ execute_overlay([{copy, In, Out} | Rest], Vars, BaseDir, TargetDir) ->
end,
rebar_file_utils:cp_r([InFile], OutFile),
execute_overlay(Rest, Vars, BaseDir, TargetDir);
-execute_overlay([{template_wildcard, Wildcard, OutDir} | Rest], Vars, BaseDir, TargetDir) ->
+execute_overlay([{template_wildcard, Wildcard, OutDir} | Rest], Vars,
+ BaseDir, TargetDir) ->
%% Generate a series of {template, In, Out} instructions from the wildcard
%% that will get processed per normal
Ifun = fun(F, Acc0) ->
- [{template, F, filename:join(OutDir, filename:basename(F))} | Acc0]
+ [{template, F,
+ filename:join(OutDir, filename:basename(F))} | Acc0]
end,
NewInstrs = lists:foldl(Ifun, Rest, filelib:wildcard(Wildcard, BaseDir)),
case length(NewInstrs) =:= length(Rest) of
true ->
- ?WARN("template_wildcard: ~s did not match any files!\n", [Wildcard]);
+ ?WARN("template_wildcard: ~s did not match any files!\n",
+ [Wildcard]);
false ->
ok
end,
@@ -318,7 +326,8 @@ execute_overlay([{replace, Out, Regex, Replacement, Opts} | Rest],
Vars, BaseDir, TargetDir) ->
Filename = rebar_templater:render(filename:join(TargetDir, Out), Vars),
{ok, OrigData} = file:read_file(Filename),
- Data = re:replace(OrigData, Regex, rebar_templater:render(Replacement, Vars),
+ Data = re:replace(OrigData, Regex,
+ rebar_templater:render(Replacement, Vars),
[global, {return, binary}] ++ Opts),
case file:write_file(Filename, Data) of
ok ->
@@ -337,9 +346,10 @@ apply_file_info(InFile, OutFile) ->
create_RELEASES(TargetDir, RelName, RelVsn) ->
ReleasesDir = filename:join(TargetDir, "releases"),
- case release_handler:create_RELEASES(TargetDir, ReleasesDir,
- filename:join([ReleasesDir, RelVsn, RelName ++ ".rel"]),
- filename:join(TargetDir, "lib")) of
+ case release_handler:create_RELEASES(
+ TargetDir, ReleasesDir,
+ filename:join([ReleasesDir, RelVsn, RelName ++ ".rel"]),
+ filename:join(TargetDir, "lib")) of
ok ->
ok;
{error, Reason} ->
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index b01a35a..8f71bab 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -37,7 +37,7 @@
ensure_dir/1,
beam_to_mod/2, beams/1,
erl_to_mod/1,
- abort/2,
+ abort/0, abort/2,
escript_foldl/3,
find_executable/1,
prop_check/3,
@@ -137,10 +137,14 @@ ensure_dir(Path) ->
Error
end.
+-spec abort() -> no_return().
+abort() ->
+ throw(rebar_abort).
+
-spec abort(string(), [term()]) -> no_return().
abort(String, Args) ->
?ERROR(String, Args),
- delayed_halt(1).
+ abort().
%% TODO: Rename emulate_escript_foldl to escript_foldl and remove
%% this function when the time is right. escript:foldl/3 was an
diff --git a/src/rebar_xref.erl b/src/rebar_xref.erl
index 94103eb..73afdf9 100644
--- a/src/rebar_xref.erl
+++ b/src/rebar_xref.erl
@@ -90,7 +90,7 @@ xref(Config, _) ->
case lists:member(false, [ExportsNoWarn, UndefNoWarn, QueryNoWarn]) of
true ->
- ?FAIL;
+ ?ABORT;
false ->
ok
end.