speedup Makefile resolution

pull/443/head
connor rigby 2018-02-13 08:08:26 -08:00
parent dfbc24e2d0
commit a033f0fa87
2 changed files with 11 additions and 14 deletions

View File

@ -1,11 +1,5 @@
# Erlang Nif Stuff
ifeq ($(ERL_EI_INCLUDE_DIR),)
ERL_ROOT_DIR = $(shell erl -eval "io:format(\"~s~n\", [code:root_dir()])" -s init stop -noshell)
ifeq ($(ERL_ROOT_DIR),)
$(error Could not find the Erlang installation. Check to see that 'erl' is in your PATH)
endif
ERL_EI_INCLUDE_DIR = "$(ERL_ROOT_DIR)/usr/include"
ERL_EI_LIBDIR = "$(ERL_ROOT_DIR)/usr/lib"
$(error ERL_EI_INCLUDE_DIR not set. Invoke via mix)
endif
# Set Erlang-specific compile and linker flags

17
mix.exs
View File

@ -27,8 +27,9 @@ defmodule Farmbot.Mixfile do
app: :farmbot,
description: "The Brains of the Farmbot Project",
package: package(),
compilers: compilers(),
make_clean: ["clean"],
make_env: make_env(),
compilers: [:elixir_make] ++ Mix.compilers,
test_coverage: [tool: ExCoveralls],
version: @version,
target: @target,
@ -41,7 +42,6 @@ defmodule Farmbot.Mixfile do
build_path: "_build/#{@target}",
lockfile: "mix.lock.#{@target}",
config_path: "config/config.exs",
lockfile: "mix.lock",
elixirc_paths: elixirc_paths(Mix.env(), @target),
aliases: aliases(Mix.env(), @target),
deps: deps() ++ deps(@target),
@ -81,11 +81,14 @@ defmodule Farmbot.Mixfile do
]
end
defp compilers do
case :init.get_plain_arguments() |> List.last() do
a when a in ['mix', 'compile', 'firmware'] ->
[:elixir_make] ++ Mix.compilers
_ -> Mix.compilers
defp make_env do
case System.get_env("ERL_EI_INCLUDE_DIR") do
nil ->
%{
"ERL_EI_INCLUDE_DIR" => "#{:code.root_dir()}/usr/include",
"ERL_EI_LIBDIR" => "#{:code.root_dir()}/usr/lib"
}
_ -> %{}
end
end