Skip to content

Commit b87e58e

Browse files
ericmjJosé Valim
authored and
José Valim
committed
Run make clean for erlang.mk (#5698)
Signed-off-by: José Valim <[email protected]>
1 parent 6cb09a7 commit b87e58e

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

lib/mix/lib/mix/dep/loader.ex

+3-3
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ defmodule Mix.Dep.Loader do
279279
# files in the dependency
280280
Enum.map(children, &to_dep(&1, from, manager))
281281
else
282-
rebar_children(config, manager)
282+
rebar_children(config, manager, opts[:dest])
283283
end
284284

285285
{%{dep | extra: config}, deps}
@@ -304,8 +304,8 @@ defmodule Mix.Dep.Loader do
304304
|> elem(0)
305305
end
306306

307-
defp rebar_children(root_config, manager) do
308-
from = Path.absname("rebar.config")
307+
defp rebar_children(root_config, manager, dest) do
308+
from = Path.absname(Path.join(dest, "rebar.config"))
309309
Mix.Rebar.recur(root_config, fn config ->
310310
overrides = overrides(manager, config)
311311
config

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

+25-7
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,29 @@ defmodule Mix.Tasks.Deps.Compile do
191191
Mix.raise "\"#{manager}\" installation failed"
192192
end
193193

194-
defp do_make(%{opts: opts} = dep, config) do
195-
os_type = :os.type
194+
defp do_make(dep, config) do
195+
command = make_command(dep)
196+
do_command(dep, config, command, true, [{"IS_DEP", "1"}])
197+
end
198+
199+
defp make_command(dep) do
200+
makefile_win? = makefile_win?(dep)
196201

197202
command =
198-
cond do
199-
match?({:win32, _}, os_type) and File.regular?(Path.join(opts[:dest], "Makefile.win")) ->
203+
case :os.type do
204+
{:win32, _} when makefile_win? ->
200205
"nmake /F Makefile.win"
201-
match?({:unix, type} when type in [:freebsd, :openbsd], os_type) ->
206+
{:unix, type} when type in [:freebsd, :openbsd] ->
202207
"gmake"
203-
true ->
208+
_ ->
204209
"make"
205210
end
206-
do_command(dep, config, command, true, [{"IS_DEP", "1"}])
211+
212+
if erlang_mk?(dep) do
213+
"#{command} clean && #{command}"
214+
else
215+
command
216+
end
207217
end
208218

209219
defp do_compile(%Mix.Dep{opts: opts} = dep, config) do
@@ -248,4 +258,12 @@ defmodule Mix.Tasks.Deps.Compile do
248258
req
249259
end
250260
end
261+
262+
defp erlang_mk?(%Mix.Dep{opts: opts}) do
263+
File.regular?(Path.join(opts[:dest], "erlang.mk"))
264+
end
265+
266+
defp makefile_win?(%Mix.Dep{opts: opts}) do
267+
File.regular?(Path.join(opts[:dest], "Makefile.win"))
268+
end
251269
end

0 commit comments

Comments
 (0)