Skip to content
Permalink
Browse files

Delegate Erlang/OTP version check to Elixir

  • Loading branch information...
josevalim committed May 15, 2019
1 parent d63a7a4 commit 10fd3164399c13da75f087783b6ebe9dd03ab3d7
Showing with 4 additions and 22 deletions.
  1. +2 −2 lib/elixir/src/elixir.erl
  2. +2 −20 lib/mix/lib/mix/tasks/escript.build.ex
@@ -106,12 +106,12 @@ preload_common_modules() ->
ok.

parse_otp_release() ->
%% Whenever we change this check, we should also change escript.build and Makefile.
%% Whenever we change this check, we should also change Makefile.
case string:to_integer(erlang:system_info(otp_release)) of
{Num, _} when Num >= 20 ->
Num;
_ ->
io:format(standard_error, "unsupported Erlang/OTP version, expected Erlang/OTP 20+~n", []),
io:format(standard_error, "ERROR! Unsupported Erlang/OTP version, expected Erlang/OTP 20+~n", []),
erlang:halt(1)
end.

@@ -344,15 +344,14 @@ defmodule Mix.Tasks.Escript.Build do
end

error_message = [
"Could not start application ",
"ERROR! Could not start application ",
:erlang.atom_to_binary(app, :utf8),
": ",
formatted_error,
?\n
]

io_error(error_message)

:erlang.halt(1)
end
end
@@ -368,23 +367,6 @@ defmodule Mix.Tasks.Escript.Build do

defp main_body_for(:elixir) do
quote do
erl_version = :erlang.system_info(:otp_release)

case :string.to_integer(erl_version) do
{num, _} when num >= 20 ->
:ok

_ ->
error_message = [
"Incompatible Erlang/OTP release: ",
erl_version,
".\nThis escript requires at least Erlang/OTP 20.0\n"
]

io_error(error_message)
:erlang.halt(1)
end

case :application.ensure_all_started(:elixir) do
{:ok, _} ->
load_config(@config)
@@ -393,7 +375,7 @@ defmodule Mix.Tasks.Escript.Build do
Kernel.CLI.run(fn _ -> @module.main(args) end)

error ->
io_error(["Failed to start Elixir.\n", :io_lib.format('error: ~p~n', [error])])
io_error(["ERROR! Failed to start Elixir.\n", :io_lib.format('error: ~p~n', [error])])
:erlang.halt(1)
end
end

0 comments on commit 10fd316

Please sign in to comment.
You can’t perform that action at this time.