summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
6 files changed, 60 insertions, 48 deletions
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 "