summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--README.md9
-rw-r--r--THANKS1
-rwxr-xr-xbootstrap6
-rw-r--r--ebin/rebar.app2
-rw-r--r--priv/shell-completion/bash/rebar7
-rw-r--r--rebar.config.sample5
-rw-r--r--src/rebar.erl8
-rw-r--r--src/rebar_core.erl14
-rw-r--r--src/rebar_deps.erl45
-rw-r--r--src/rebar_port_compiler.erl6
-rw-r--r--src/rebar_reltool.erl30
-rw-r--r--src/rebar_utils.erl5
13 files changed, 80 insertions, 63 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 cff8412..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
@@ -125,7 +124,7 @@ Command 'debug' not understood or not applicable
Congratulations! You now have a self-contained script called "rebar" in
your current working directory. Place this script anywhere in your path
and you can use rebar to build OTP-compliant apps.
-make: [xref_warnings] Error 1 (ignored)
+==> rebar (xref)
make: [dialyzer_warnings] Error 2 (ignored)
```
diff --git a/THANKS b/THANKS
index bad9694..f38b7e6 100644
--- a/THANKS
+++ b/THANKS
@@ -90,3 +90,4 @@ Ali Yakout
Adam Schepis
Amit Kapoor
Ulf Wiger
+Nick Vatamaniuc
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 3b17df7..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,
diff --git a/priv/shell-completion/bash/rebar b/priv/shell-completion/bash/rebar
index c8690c2..005325d 100644
--- a/priv/shell-completion/bash/rebar
+++ b/priv/shell-completion/bash/rebar
@@ -8,12 +8,11 @@ _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= \
- alt_urls=true"
+ nodeid= root_dir= skip_deps=true skip_apps= template= template_dir="
if [[ ${cur} == --* ]] ; then
COMPREPLY=( $(compgen -W "${lopts}" -- ${cur}) )
diff --git a/rebar.config.sample b/rebar.config.sample
index ebcaff9..dc4253b 100644
--- a/rebar.config.sample
+++ b/rebar.config.sample
@@ -115,10 +115,7 @@
{deps, [application_name,
{application_name, "1.0.*"},
{application_name, "1.0.*",
- {git, "git://github.com/basho/rebar.git", {branch, "master"}}},
- {application_name, "1.0.*",
- {git, "git://github.com/basho/rebar.git", {branch, "master"}},
- [{alt_url, "https://github.com/basho/rebar.git"}]}]}.
+ {git, "git://github.com/basho/rebar.git", {branch, "master"}}}]}.
%% == Subdirectories ==
diff --git a/src/rebar.erl b/src/rebar.erl
index 1f72a4c..4c1d20d 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
%% ====================================================================
@@ -202,8 +206,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]).
%%
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index 484b446..7828c66 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -104,10 +104,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 +130,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,
diff --git a/src/rebar_deps.erl b/src/rebar_deps.erl
index c64d761..f06eb76 100644
--- a/src/rebar_deps.erl
+++ b/src/rebar_deps.erl
@@ -229,30 +229,15 @@ find_deps(Mode, [App | Rest], Acc) when is_atom(App) ->
find_deps(Mode, [{App, VsnRegex} | Rest], Acc) when is_atom(App) ->
find_deps(Mode, [{App, VsnRegex, undefined} | Rest], Acc);
find_deps(Mode, [{App, VsnRegex, Source} | Rest], Acc) ->
- find_deps(Mode, [{App, VsnRegex, Source, []} | Rest], Acc);
-find_deps(Mode, [{App, VsnRegex, Source, Opts} | Rest], Acc) ->
Dep = #dep { app = App,
vsn_regex = VsnRegex,
- source = get_source(Source, Opts) },
+ source = Source },
{Availability, FoundDir} = find_dep(Dep),
find_deps(Mode, Rest, acc_deps(Mode, Availability, Dep, FoundDir, Acc));
find_deps(_Mode, [Other | _Rest], _Acc) ->
?ABORT("Invalid dependency specification ~p in ~s\n",
[Other, rebar_utils:get_cwd()]).
-get_source(undefined, _Opts) ->
- undefined;
-get_source(Source, Opts) ->
- setelement(2, Source, dep_url(element(2, Source), Opts)).
-
-dep_url(Url, Opts) ->
- case rebar_config:get_global(alt_urls, "false") of
- "true" ->
- proplists:get_value(alt_url, Opts, Url);
- "false" ->
- Url
- end.
-
find_dep(Dep) ->
%% Find a dep based on its source,
%% e.g. {git, "https://github.com/mochi/mochiweb.git", "HEAD"}
@@ -400,7 +385,10 @@ download_source(AppDir, {svn, Url, Rev}) ->
ok = filelib:ensure_dir(AppDir),
rebar_utils:sh(?FMT("svn checkout -r ~s ~s ~s",
[Rev, Url, filename:basename(AppDir)]),
- [{cd, filename:dirname(AppDir)}]).
+ [{cd, filename:dirname(AppDir)}]);
+download_source(AppDir, {rsync, Url}) ->
+ ok = filelib:ensure_dir(AppDir),
+ rebar_utils:sh(?FMT("rsync -az --delete ~s/ ~s", [Url, AppDir]), []).
update_source(Dep) ->
%% It's possible when updating a source, that a given dep does not have a
@@ -441,7 +429,10 @@ update_source(AppDir, {svn, _Url, Rev}) ->
update_source(AppDir, {hg, _Url, Rev}) ->
rebar_utils:sh(?FMT("hg pull -u -r ~s", [Rev]), [{cd, AppDir}]);
update_source(AppDir, {bzr, _Url, Rev}) ->
- rebar_utils:sh(?FMT("bzr update -r ~s", [Rev]), [{cd, AppDir}]).
+ rebar_utils:sh(?FMT("bzr update -r ~s", [Rev]), [{cd, AppDir}]);
+update_source(AppDir, {rsync, Url}) ->
+ rebar_utils:sh(?FMT("rsync -az --delete ~s/ ~s",[Url,AppDir]),[]).
+
@@ -454,7 +445,7 @@ source_engine_avail(Source) ->
source_engine_avail(Name, Source).
source_engine_avail(Name, Source)
- when Name == hg; Name == git; Name == svn; Name == bzr ->
+ when Name == hg; Name == git; Name == svn; Name == bzr; Name == rsync ->
case vcs_client_vsn(Name) >= required_vcs_client_vsn(Name) of
true ->
true;
@@ -475,10 +466,11 @@ vcs_client_vsn(Path, VsnArg, VsnRegex) ->
false
end.
-required_vcs_client_vsn(hg) -> {1, 1};
-required_vcs_client_vsn(git) -> {1, 5};
-required_vcs_client_vsn(bzr) -> {2, 0};
-required_vcs_client_vsn(svn) -> {1, 6}.
+required_vcs_client_vsn(hg) -> {1, 1};
+required_vcs_client_vsn(git) -> {1, 5};
+required_vcs_client_vsn(bzr) -> {2, 0};
+required_vcs_client_vsn(svn) -> {1, 6};
+required_vcs_client_vsn(rsync) -> {2, 0}.
vcs_client_vsn(hg) ->
vcs_client_vsn(rebar_utils:find_executable("hg"), " --version",
@@ -491,7 +483,10 @@ vcs_client_vsn(bzr) ->
"Bazaar \\(bzr\\) (\\d+).(\\d+)");
vcs_client_vsn(svn) ->
vcs_client_vsn(rebar_utils:find_executable("svn"), " --version",
- "svn, version (\\d+).(\\d+)").
+ "svn, version (\\d+).(\\d+)");
+vcs_client_vsn(rsync) ->
+ vcs_client_vsn(rebar_utils:find_executable("rsync"), " --version",
+ "rsync version (\\d+).(\\d+)").
has_vcs_dir(git, Dir) ->
filelib:is_dir(filename:join(Dir, ".git"));
@@ -502,6 +497,8 @@ has_vcs_dir(bzr, Dir) ->
has_vcs_dir(svn, Dir) ->
filelib:is_dir(filename:join(Dir, ".svn"))
orelse filelib:is_dir(filename:join(Dir, "_svn"));
+has_vcs_dir(rsync, _) ->
+ true;
has_vcs_dir(_, _) ->
true.
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
index 65106d9..cdd9be6 100644
--- a/src/rebar_port_compiler.erl
+++ b/src/rebar_port_compiler.erl
@@ -304,9 +304,9 @@ maybe_switch_extension(_OsType, Target) ->
switch_to_dll_or_exe(Target) ->
case filename:extension(Target) of
- ".so" -> filename:rootname(Target, ".so") ++ ".dll";
- [] -> Target ++ ".exe";
- Other -> Other
+ ".so" -> filename:rootname(Target, ".so") ++ ".dll";
+ [] -> Target ++ ".exe";
+ _Other -> Target
end.
%% TODO: DEPRECATED: remove support for non-port_specs syntax [old_*()]
diff --git a/src/rebar_reltool.erl b/src/rebar_reltool.erl
index 42c7f15..c114811 100644
--- a/src/rebar_reltool.erl
+++ b/src/rebar_reltool.erl
@@ -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} ->
@@ -236,7 +236,11 @@ mk_target_dir(TargetDir) ->
?ERROR("Release target directory ~p already exists!\n",
[TargetDir]),
?FAIL
- end
+ end;
+ {error, Reason} ->
+ ?ERROR("Failed to make target dir ~p: ~s\n",
+ [TargetDir, file:format_error(Reason)]),
+ ?FAIL
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 a70be7d..b01a35a 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -423,9 +423,8 @@ emulate_escript_foldl(Fun, Acc, File) ->
end.
vcs_vsn_cmd(git) ->
- %% Explicitly git-describe a committish to accommodate for projects
- %% in subdirs which don't have a GIT_DIR. In that case we will
- %% get a description of the last commit that touched the subdir.
+ %% git describe the last commit that touched CWD
+ %% required for correct versioning of apps in subdirs, such as apps/app1
case os:type() of
{win32,nt} ->
"FOR /F \"usebackq tokens=* delims=\" %i in "