Skip to content

Commit

Permalink
Build core PLTs outside a mix project.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyjh committed Dec 2, 2016
1 parent 247149e commit fde46aa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
11 changes: 7 additions & 4 deletions lib/dialyxir/project.ex
@@ -1,12 +1,15 @@
defmodule Dialyxir.Project do
@moduledoc false

def plts_list(deps) do
def plts_list(deps, include_project \\ true) do
elixir_apps = [:elixir]
erlang_apps = [:erts, :kernel, :stdlib, :crypto]
[{plt_file(), deps ++ elixir_apps ++ erlang_apps},
{elixir_plt(), elixir_apps},
{erlang_plt(), erlang_apps}]
core_plts = [ {elixir_plt(), elixir_apps}, {erlang_plt(), erlang_apps}]
if include_project do
[{plt_file(), deps ++ elixir_apps ++ erlang_apps} | core_plts]
else
core_plts
end
end

def plt_file() do
Expand Down
35 changes: 21 additions & 14 deletions lib/mix/tasks/dialyzer.ex
Expand Up @@ -4,6 +4,8 @@ defmodule Mix.Tasks.Dialyzer do
@moduledoc """
This task compiles the mix project, creates a PLT with dependencies if needed and runs `dialyzer`. Much of its behavior can be managed in configuration as described below.
If executed outside of a mix project, it will build the core PLT files and exit.
## Command line options
* `--no-compile` - do not compile even if needed.
Expand Down Expand Up @@ -80,20 +82,25 @@ defmodule Mix.Tasks.Dialyzer do
def run(args) do
check_dialyzer()
compatibility_notice()
Project.check_config()
{dargs, compile} = Enum.partition(args, &(&1 != "--no-compile"))
{dargs, halt} = Enum.partition(dargs, &(&1 != "--halt-exit-status"))
{dargs, no_check} = Enum.partition(dargs, &(&1 != "--no-check"))
no_check = if in_child? do
IO.puts "In an Umbrella child, not checking PLT..."
["--no-check"]
else
no_check
end
if compile == [], do: Mix.Project.compile([])
unless no_check != [], do: check_plt()
args = List.flatten [dargs, "--no_check_plt", "--plt", "#{Project.plt_file()}", dialyzer_flags(), Project.dialyzer_paths()]
dialyze(args, halt)
if Mix.Project.get() do
Project.check_config()
{dargs, compile} = Enum.partition(args, &(&1 != "--no-compile"))
{dargs, halt} = Enum.partition(dargs, &(&1 != "--halt-exit-status"))
{dargs, no_check} = Enum.partition(dargs, &(&1 != "--no-check"))
no_check = if in_child? do
IO.puts "In an Umbrella child, not checking PLT..."
["--no-check"]
else
no_check
end
if compile == [], do: Mix.Project.compile([])
unless no_check != [], do: check_plt()
args = List.flatten [dargs, "--no_check_plt", "--plt", "#{Project.plt_file()}", dialyzer_flags(), Project.dialyzer_paths()]
dialyze(args, halt)
else
IO.puts "No mix project found - checking core PLTs..."
Project.plts_list([], false) |> Plt.check()
end
end

defp check_plt() do
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Expand Up @@ -4,7 +4,7 @@ defmodule Dialyxir.Mixfile do
def project do
[
app: :dialyxir,
version: "0.4.0",
version: "0.4.1",
elixir: "> 1.3.2",
description: description(),
package: package(),
Expand Down

0 comments on commit fde46aa

Please sign in to comment.