Skip to content

Commit f175f5f

Browse files
committed
Ensure flags are passed down to umbrella children
Closes elixir-lang#14852. Closes elixir-lang#14860.
1 parent a7258fe commit f175f5f

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

lib/mix/lib/mix/tasks/deps.loadpaths.ex

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ defmodule Mix.Tasks.Deps.Loadpaths do
141141
defp partition([dep | deps], not_ok, compile) do
142142
cond do
143143
Mix.Dep.compilable?(dep) or (Mix.Dep.ok?(dep) and local?(dep)) ->
144-
partition(deps, not_ok, [dep | compile])
144+
if from_umbrella?(dep) do
145+
partition(deps, not_ok, compile)
146+
else
147+
partition(deps, not_ok, [dep | compile])
148+
end
145149

146150
Mix.Dep.ok?(dep) ->
147151
partition(deps, not_ok, compile)
@@ -155,6 +159,14 @@ defmodule Mix.Tasks.Deps.Loadpaths do
155159
{Enum.reverse(not_ok), Enum.reverse(compile)}
156160
end
157161

162+
# Children from the umbrella are compiled sequentially by the umbrella project itself.
163+
# We could start compiling them as dependencies, and therefore in parallel, but because
164+
# `mix compile` in an umbrella is expected to return the diagnostics of all children,
165+
# we would need a pass after compilation to compite diagnostics.
166+
defp from_umbrella?(dep) do
167+
dep.opts[:from_umbrella]
168+
end
169+
158170
defp reload_deps(deps) do
159171
deps
160172
|> Enum.map(& &1.app)

lib/mix/test/mix/umbrella_test.exs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ defmodule Mix.UmbrellaTest do
6666
# Ensure we can compile and run checks
6767
Mix.Task.run("deps.compile")
6868
Mix.Task.run("deps.loadpaths")
69-
Mix.Task.run("compile", ["--verbose"])
69+
Mix.Task.run("compile")
7070

7171
# Extra applications are picked even for umbrellas
7272
assert :code.where_is_file(~c"runtime_tools.app") != :non_existing
@@ -83,6 +83,13 @@ defmodule Mix.UmbrellaTest do
8383
assert_received {:mix_shell, :info, [":foo env is dev"]}
8484
assert_received {:mix_shell, :info, [":bar env is dev"]}
8585

86+
# Ensure we can compile --force
87+
Mix.Task.clear()
88+
Mix.Task.run("compile", ["--force"])
89+
assert_received {:mix_shell, :info, ["Generated foo app"]}
90+
assert_received {:mix_shell, :info, ["Generated bar app"]}
91+
92+
# Ensure we can start even with --no-compile
8693
Mix.Task.clear()
8794
Mix.Task.run("app.start", ["--no-compile"])
8895
end)
@@ -282,23 +289,6 @@ defmodule Mix.UmbrellaTest do
282289
end)
283290
end
284291

285-
test "compile for umbrella as dependency with os partitions" do
286-
System.put_env("MIX_OS_DEPS_COMPILE_PARTITION_COUNT", "2")
287-
288-
in_fixture("umbrella_dep", fn ->
289-
Mix.Project.in_project(:umbrella_dep, ".", fn _ ->
290-
output = ExUnit.CaptureIO.capture_io(fn -> Mix.Task.run("compile") end)
291-
assert output =~ ~r/\d> :foo env is prod/
292-
assert output =~ ~r/\d> :bar env is prod/
293-
294-
assert_received {:mix_shell, :info, ["mix deps.compile running across 2 OS processes"]}
295-
assert Bar.bar() == "hello world"
296-
end)
297-
end)
298-
after
299-
System.delete_env("MIX_OS_DEPS_COMPILE_PARTITION_COUNT")
300-
end
301-
302292
defmodule CycleDeps do
303293
def project do
304294
[

0 commit comments

Comments
 (0)