Skip to content

Commit 1dc9193

Browse files
author
José Valim
committed
Rely on print_app for mix deps.compile and ensure path deps are compiled
1 parent dacb30a commit 1dc9193

File tree

15 files changed

+84
-72
lines changed

15 files changed

+84
-72
lines changed

lib/mix/lib/mix/dep/umbrella.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ defmodule Mix.Dep.Umbrella do
5151

5252
defp to_umbrella_dep(paths, build) do
5353
Enum.map paths, fn({app, path}) ->
54-
opts = [path: path, dest: Path.expand(path),
54+
opts = [path: path, dest: Path.expand(path), from_umbrella: true,
5555
env: Mix.env, build: Path.join([build, "lib", Atom.to_string(app)])]
5656
%Mix.Dep{
5757
scm: Mix.SCM.Path,

lib/mix/lib/mix/project_stack.ex

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,21 @@ defmodule Mix.ProjectStack do
1010

1111
@spec start_link :: {:ok, pid}
1212
def start_link() do
13-
Agent.start_link fn -> %{stack: [], post_config: [], cache: HashDict.new} end, name: __MODULE__
13+
initial = %{stack: [], post_config: [], cache: HashDict.new}
14+
Agent.start_link fn -> initial end, name: __MODULE__
1415
end
1516

1617
@spec push(module, config, file) :: :ok | {:error, file}
1718
def push(module, config, file) do
1819
get_and_update fn %{stack: stack} = state ->
20+
# Consider the first children to always have io_done
21+
# because we don't need to print anything unless another
22+
# project talks ahold of the shell.
23+
io_done? = stack == []
24+
1925
config = Keyword.merge(config, state.post_config)
20-
project = %{name: module, config: config, file: file, recursing?: false, io_done: false, tasks: HashSet.new}
26+
project = %{name: module, config: config, file: file,
27+
recursing?: false, io_done: io_done?, tasks: HashSet.new}
2128

2229
cond do
2330
file = find_project_named(module, stack) ->
@@ -59,11 +66,14 @@ defmodule Mix.ProjectStack do
5966
def print_app? do
6067
get_and_update fn %{stack: stack} = state ->
6168
case stack do
62-
[h|t] ->
63-
output = not h.io_done and not umbrella?(stack) and in_umbrella?(stack)
64-
{output, %{state | stack: [%{h | io_done: true}|t]}}
6569
[] ->
6670
{false, state}
71+
[%{io_done: true}|_] ->
72+
{false, state}
73+
[h|t] ->
74+
h = %{h | io_done: true}
75+
t = Enum.map(t, &%{&1 | io_done: false})
76+
{true, %{state | stack: [h|t]}}
6777
end
6878
end
6979
end
@@ -130,19 +140,6 @@ defmodule Mix.ProjectStack do
130140
end
131141
end
132142

133-
defp in_umbrella?(stack) do
134-
Enum.any?(stack, fn(%{config: conf}) ->
135-
conf[:apps_path] != nil
136-
end)
137-
end
138-
139-
defp umbrella?(stack) do
140-
case stack do
141-
[%{name: name, config: config}|_] when name != nil -> config[:apps_path] != nil
142-
_ -> false
143-
end
144-
end
145-
146143
defp find_project_named(name, stack) do
147144
name && Enum.find_value(stack, fn
148145
%{name: n, file: file} when n === name -> file
@@ -165,5 +162,4 @@ defmodule Mix.ProjectStack do
165162
defp cast(fun) do
166163
Agent.cast __MODULE__, fun
167164
end
168-
169165
end

lib/mix/lib/mix/scm.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ defmodule Mix.SCM do
1010

1111
@doc """
1212
Returns a boolean if the dependency can be fetched
13-
or it is meant to be previously available in the filesystem.
13+
or it is meant to be previously available in the
14+
filesystem.
1415
"""
1516
defcallback fetchable? :: boolean
1617

lib/mix/lib/mix/shell/io.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ defmodule Mix.Shell.IO do
2121
to stdout as it comes.
2222
"""
2323
def cmd(command) do
24-
print_app
2524
Mix.Shell.cmd(command, &IO.write(&1))
2625
end
2726

lib/mix/lib/mix/shell/process.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ defmodule Mix.Shell.Process do
5454
the current process.
5555
"""
5656
def cmd(command) do
57-
print_app
5857
Mix.Shell.cmd(command, fn(data) ->
5958
send self, {:mix_shell, :run, [data]}
6059
end)

lib/mix/lib/mix/task.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ defmodule Mix.Task do
213213
recursive = recursive(module)
214214

215215
if umbrella? && recursive && Mix.ProjectStack.enable_recursion do
216-
config = [build_path: Mix.Project.build_path]
216+
# Get all dependency configuration but not the deps path
217+
# as we leave the control of the deps path still to the
218+
# umbrella child.
219+
config = Mix.Project.deps_config |> Keyword.delete(:deps_path)
217220
res = for %Mix.Dep{app: app, opts: opts} <- Mix.Dep.Umbrella.loaded do
218221
Mix.Project.in_project(app, opts[:path], config, fun)
219222
end

lib/mix/lib/mix/tasks/cmd.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ defmodule Mix.Tasks.Cmd do
1616
than zero.
1717
"""
1818
def run(args) do
19+
Mix.shell.print_app
1920
case Mix.shell.cmd(Enum.join(args, " ")) do
2021
0 -> :ok
2122
s -> exit(s)

lib/mix/lib/mix/tasks/compile.elixir.ex

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ defmodule Mix.Tasks.Compile.Elixir do
5151
manifest = manifest()
5252
configs = Mix.Project.config_files ++ Mix.Tasks.Compile.Erlang.manifests
5353

54-
force = opts[:force] || path_deps_changed?(manifest)
54+
force = opts[:force] || local_deps_changed?(manifest)
5555
|| Mix.Utils.stale?(configs, [manifest])
5656

5757
result = Mix.Compilers.Elixir.compile(manifest, srcs, [:ex], dest, force, fn ->
@@ -85,16 +85,13 @@ defmodule Mix.Tasks.Compile.Elixir do
8585
Code.compiler_options Keyword.merge(opts, extra)
8686
end
8787

88-
defp path_deps_changed?(manifest) do
88+
defp local_deps_changed?(manifest) do
8989
manifest = Path.absname(manifest)
9090

91-
deps = Enum.filter(Mix.Dep.children([]), fn dep ->
92-
dep.scm == Mix.SCM.Path
93-
end)
94-
95-
Enum.any?(deps, fn(dep) ->
96-
Mix.Dep.in_dependency(dep, fn(_) ->
97-
Mix.Utils.stale?(Mix.Tasks.Compile.manifests, [manifest])
91+
Enum.any?(Mix.Dep.children([]), fn(dep) ->
92+
not dep.scm.fetchable? and Mix.Dep.in_dependency(dep, fn(_) ->
93+
files = Mix.Project.config_files ++ Mix.Tasks.Compile.manifests
94+
Mix.Utils.stale?(files, [manifest])
9895
end)
9996
end)
10097
end

lib/mix/lib/mix/tasks/deps.check.ex

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ defmodule Mix.Tasks.Deps.Check do
1414
## Command line options
1515
1616
* `--no-compile` - do not compile dependencies
17-
* `--quiet` - do not output on compilation
1817
1918
"""
2019
def run(args) do
21-
{opts, _, _} = OptionParser.parse(args, switches: [quiet: :boolean])
20+
{opts, _, _} = OptionParser.parse(args)
2221
lock = Mix.Dep.Lock.read
2322
all = Enum.map(loaded(env: Mix.env), &check_lock(&1, lock))
2423

@@ -41,16 +40,21 @@ defmodule Mix.Tasks.Deps.Check do
4140

4241
defp partition_deps([dep|deps], not_ok, compile) do
4342
cond do
44-
ok?(dep) -> partition_deps(deps, not_ok, compile)
45-
compile?(dep) -> partition_deps(deps, not_ok, [dep|compile])
46-
true -> partition_deps(deps, [dep|not_ok], compile)
43+
compile?(dep) -> partition_deps(deps, not_ok, [dep|compile])
44+
ok?(dep) and local?(dep) -> partition_deps(deps, not_ok, [dep|compile])
45+
ok?(dep) -> partition_deps(deps, not_ok, compile)
46+
true -> partition_deps(deps, [dep|not_ok], compile)
4747
end
4848
end
4949

5050
defp partition_deps([], not_ok, compile) do
5151
{Enum.reverse(not_ok), Enum.reverse(compile)}
5252
end
5353

54+
defp local?(dep) do
55+
not dep.scm.fetchable? and dep.opts[:from_umbrella] != true
56+
end
57+
5458
defp compile?(%Mix.Dep{status: {:elixirlock, _}}), do: true
5559
defp compile?(%Mix.Dep{status: {:noappfile, _}}), do: true
5660
defp compile?(%Mix.Dep{status: :compile}), do: true

lib/mix/lib/mix/tasks/deps.compile.ex

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ defmodule Mix.Tasks.Deps.Compile do
2121
2222
{:some_dependency, "0.1.0", git: "...", compile: "command to compile"}
2323
24-
## Command line options
25-
26-
* `--quiet` - do not output verbose messages
27-
2824
"""
2925

3026
import Mix.Dep, only: [loaded: 1, available?: 1, loaded_by_name: 2,
@@ -33,7 +29,7 @@ defmodule Mix.Tasks.Deps.Compile do
3329
def run(args) do
3430
Mix.Project.get! # Require the project to be available
3531

36-
case OptionParser.parse(args, switches: [quiet: :boolean]) do
32+
case OptionParser.parse(args) do
3733
{opts, [], _} ->
3834
compile(Enum.filter(loaded(env: Mix.env), &compilable?/1), opts)
3935
{opts, tail, _} ->
@@ -42,18 +38,14 @@ defmodule Mix.Tasks.Deps.Compile do
4238
end
4339

4440
@doc false
45-
def compile(deps, run_opts) do
41+
def compile(deps, _opts) do
4642
shell = Mix.shell
4743
config = Mix.Project.deps_config
4844

4945
compiled =
5046
Enum.map(deps, fn %Mix.Dep{app: app, status: status, opts: opts} = dep ->
5147
check_unavailable!(app, status)
5248

53-
unless run_opts[:quiet] || opts[:compile] == false do
54-
shell.info "* Compiling #{app}"
55-
end
56-
5749
compiled = cond do
5850
not nil?(opts[:compile]) ->
5951
do_compile dep

0 commit comments

Comments
 (0)