Rebar dep with no config is given rebar as manager

This commit is contained in:
José Valim
2013-06-02 00:35:30 +09:00
parent be2aedff98
commit 036d016053
5 changed files with 34 additions and 19 deletions
+3 -3
View File
@@ -11,7 +11,7 @@ defrecord Mix.Dep, [ scm: nil, app: nil, requirement: nil, status: nil, opts: ni
* opts - the options given by the developer
* source - any possible configuration associated with the manager field,
rebar.config for rebar or the Mix.Project for Mix
* manager - the project management, possible values: :rebar / :mix / nil
* manager - the project management, possible values: :rebar | :mix | :make | nil
"""
end
@@ -276,7 +276,7 @@ defmodule Mix.Deps do
@doc """
Returns true if dependency is a make project.
"""
def make?(dep) do
File.regular? Path.join(dep.opts[:dest], "Makefile")
def make?(Mix.Dep[manager: manager]) do
manager == :make
end
end
+30 -13
View File
@@ -36,7 +36,7 @@ defmodule Mix.Deps.Retriever do
Receives a dependency and update its status.
"""
def update(Mix.Dep[scm: scm, app: app, requirement: req, opts: opts]) do
update({ app, req, opts }, [scm])
update({ app, req, opts }, [scm], nil)
end
## Helpers
@@ -44,31 +44,38 @@ defmodule Mix.Deps.Retriever do
defp mix_children(config) do
scms = Mix.SCM.available
Mix.Project.recur(config, fn _ ->
(Mix.project[:deps] || []) |> Enum.map(update(&1, scms))
(Mix.project[:deps] || []) |> Enum.map(update(&1, scms, nil))
end) |> List.concat
end
defp rebar_children(dir) do
scms = Mix.SCM.available
Mix.Rebar.recur(dir, fn config ->
Mix.Rebar.deps(config) |> Enum.map(update(&1, scms))
Mix.Rebar.deps(config) |> Enum.map(update(&1, scms, :rebar))
end) |> List.concat
end
defp update(tuple, scms) do
defp update(tuple, scms, manager) do
dep = with_scm_and_status(tuple, scms)
cond do
Mix.Deps.available?(dep) and mixfile?(dep) ->
Mix.Deps.in_dependency(dep, fn project ->
mix_dep(dep, project)
end)
if Mix.Deps.available?(dep) do
cond do
mixfile?(dep) ->
Mix.Deps.in_dependency(dep, fn project ->
mix_dep(dep, project)
end)
Mix.Deps.available?(dep) and rebarconfig?(dep) ->
rebar_dep(dep)
rebarconfig?(dep) ->
rebar_dep(dep)
true ->
dep
makefile?(dep) ->
make_dep(dep)
true ->
dep.manager(manager)
end
else
dep
end
end
@@ -89,6 +96,12 @@ defmodule Mix.Deps.Retriever do
defp rebar_dep(dep), do: dep
defp make_dep(Mix.Dep[manager: nil] = dep) do
dep.manager(:make)
end
defp make_dep(dep), do: dep
defp with_scm_and_status({ app, opts }, scms) when is_atom(app) and is_list(opts) do
with_scm_and_status({ app, nil, opts }, scms)
end
@@ -169,4 +182,8 @@ defmodule Mix.Deps.Retriever do
File.regular?(Path.join(dep.opts[:dest], file))
end)
end
defp makefile?(dep) do
File.regular? Path.join(dep.opts[:dest], "Makefile")
end
end
+1 -1
View File
@@ -70,7 +70,7 @@ defmodule Mix.Rebar do
end
defp parse_dep({ app, req }, deps_dir) do
{ app, compile_req(req), [path: Path.join(deps_dir, app)]}
{ app, compile_req(req), [path: Path.join(deps_dir, app)] }
end
defp parse_dep({ app, req, source }, _deps_dir) do
-1
View File
@@ -155,5 +155,4 @@ defmodule Mix.Tasks.Deps.Compile do
Mix.Tasks.local_rebar_path
end
end
end
-1
View File
@@ -186,7 +186,6 @@ target = Path.expand("fixtures/git_rebar", __DIR__)
unless File.dir?(target) do
File.mkdir_p!(Path.join(target, "src"))
File.write!(Path.join(target, "rebar.config"), "")
File.write!(Path.join([target, "src", "git_rebar.app.src"]), """)
{application, git_rebar,