Skip to content

Commit a58c007

Browse files
author
José Valim
committed
Avoid missing behaviour warnings when compiling erlang files
1 parent ce6f4e6 commit a58c007

File tree

7 files changed

+12
-4
lines changed

7 files changed

+12
-4
lines changed

lib/mix/lib/mix/compilers/elixir.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ defmodule Mix.Compilers.Elixir do
9999

100100
defp compile_manifest(manifest, entries, stale, dest, on_start) do
101101
Mix.Project.build_structure
102+
true = Code.prepend_path(dest)
103+
102104
on_start.()
103105
cwd = File.cwd!
104106

lib/mix/lib/mix/compilers/erlang.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ defmodule Mix.Compilers.Erlang do
7272
# Build the project structure so we can write down compiled files.
7373
Mix.Project.build_structure
7474

75+
# Let's prepend the newly created path so compiled files
76+
# can be accessed still during compilation (for behaviours
77+
# and what not).
78+
Code.prepend_path(Mix.Project.compile_path)
79+
7580
# Remove manifest entries with no source
7681
Enum.each(removed, &File.rm/1)
7782

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ defmodule Mix.Tasks.Compile.Elixir do
6565
|| Mix.Utils.stale?(configs, [manifest])
6666

6767
Mix.Compilers.Elixir.compile(manifest, srcs, skip, [:ex], dest, force, fn ->
68-
true = Code.prepend_path(dest)
6968
set_compiler_opts(project, opts, [])
7069
end)
7170
end

lib/mix/lib/mix/tasks/compile.erlang.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,6 @@ defmodule Mix.Tasks.Compile.Erlang do
167167
end
168168

169169
defp module_from_artifact(artifact) do
170-
artifact |> Path.basename |> Path.rootname
170+
artifact |> Path.basename |> Path.rootname |> String.to_atom
171171
end
172172
end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ defmodule Mix.Tasks.Deps.Check do
8484
to_prune = Enum.reduce(all, paths, &(&2 -- Mix.Dep.load_paths(&1)))
8585

8686
Enum.map(to_prune, fn path ->
87-
# Path may not be in code path
87+
# Path cannot be in code path when deleting
8888
_ = Code.delete_path(path)
8989
File.rm_rf!(path |> Path.dirname)
9090
end)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-module(b).
22
-compile(export_all).
33

4+
-callback c() -> term().
45
-record(br, {cell=undefined}).
56

6-
b() -> #br{cell=specified}.
7+
b() -> #br{cell=specified}.

lib/mix/test/fixtures/compile_erlang/src/c.erl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
-compile(export_all).
33

44
-include("r.hrl").
5+
-behaviour(b).
56

67
c() -> #r{cell=specified}.

0 commit comments

Comments
 (0)