Skip to content

Commit 5595ff0

Browse files
authored
Disable warnings_as_errors for rebar3 dependencies (#5481)
1 parent 389d632 commit 5595ff0

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

lib/mix/lib/mix/rebar.ex

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,20 @@ defmodule Mix.Rebar do
170170
Enum.map(config, &[:io_lib.print(&1) | ".\n"])
171171
end
172172

173+
@doc """
174+
Update Rebar configuration to be more suitable for dependencies.
175+
176+
Drops `warnings_as_errors` from `erl_opts`.
177+
"""
178+
def dependency_config(config) do
179+
Enum.map(config, fn
180+
{:erl_opts, opts} ->
181+
{:erl_opts, Enum.reject(opts, &(&1 == :warnings_as_errors))}
182+
other ->
183+
other
184+
end)
185+
end
186+
173187
@doc """
174188
Parses the dependencies in given `rebar.config` to Mix's dependency format.
175189
"""

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,16 @@ defmodule Mix.Tasks.Deps.Compile do
163163
cmd = "#{rebar_cmd(dep)} bare compile --paths #{inspect lib_path}"
164164

165165
File.mkdir_p!(dep_path)
166-
File.write!(config_path, Mix.Rebar.serialize_config(dep.extra))
166+
File.write!(config_path, rebar_config(dep))
167167
do_command dep, config, cmd, false, env
168168
end
169169

170+
defp rebar_config(dep) do
171+
dep.extra
172+
|> Mix.Rebar.dependency_config
173+
|> Mix.Rebar.serialize_config
174+
end
175+
170176
defp rebar_cmd(%Mix.Dep{manager: manager} = dep) do
171177
Mix.Rebar.rebar_cmd(manager) || handle_rebar_not_found(dep)
172178
end
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
CONFIG ++ [{'SCRIPT', SCRIPT}] ++ [{deps, [{git_rebar, "0.1..*", {git, filename:absname("../../test/fixtures/git_rebar"), master}}]}].
1+
CONFIG ++
2+
[{'SCRIPT', SCRIPT}] ++
3+
[{erl_opts, [warnings_as_errors]}] ++
4+
[{deps, [{git_rebar, "0.1..*", {git, filename:absname("../../test/fixtures/git_rebar"), master}}]}].

lib/mix/test/mix/rebar_test.exs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@ defmodule Mix.RebarTest do
9898

9999
end
100100

101+
test "convert rebar config to dependency config" do
102+
config = Mix.Rebar.load_config(fixture_path("rebar_dep"))
103+
dep_config = Mix.Rebar.dependency_config(config)
104+
105+
assert config[:erl_opts] == [:warnings_as_errors]
106+
assert dep_config[:erl_opts] == []
107+
end
108+
101109
test "parse Rebar dependencies from rebar.config" do
102110
Mix.Project.push(RebarAsDep)
103111

0 commit comments

Comments
 (0)