Skip to content
Permalink
Browse files

Update to support Elixir 1.8

nerves_uart and circuits_uart still need to be updated
  • Loading branch information...
ConnorRigby committed Mar 7, 2019
1 parent fb587e4 commit dfe01ae1b63f87130e7b1781507f0dd14aa2acbf
@@ -1,15 +1,15 @@
version: 2.0
defaults: &defaults
docker:
- image: nervesproject/nerves_system_br:1.5.2
- image: nervesproject/nerves_system_br:1.6.8
environment:
ELIXIR_VERSION: 1.7.3
ELIXIR_VERSION: 1.8.1

install_elixir: &install_elixir
run:
name: Install Elixir
command: |
wget https://github.com/elixir-lang/elixir/releases/download/v1.7.3/Precompiled.zip
wget https://github.com/elixir-lang/elixir/releases/download/v1.8.1/Precompiled.zip
unzip -d /usr/local/elixir Precompiled.zip
echo 'export PATH=/usr/local/elixir/bin:$PATH' >> $BASH_ENV
@@ -129,7 +129,7 @@ jobs:
environment:
MIX_ENV: test
MIX_TARGET: host
ELIXIR_VERSION: 1.7.3
ELIXIR_VERSION: 1.8.1
steps:
- checkout
- run: git submodule update --init --recursive
@@ -254,7 +254,7 @@ jobs:
<<: *defaults
environment:
MIX_ENV: prod
ELIXIR_VERSION: 1.7.3
ELIXIR_VERSION: 1.8.1
steps:
- checkout
- run:
@@ -309,7 +309,7 @@ jobs:
<<: *defaults
environment:
MIX_ENV: prod
ELIXIR_VERSION: 1.7.3
ELIXIR_VERSION: 1.8.1
steps:
- checkout
- run:
@@ -1,2 +1,2 @@
erlang 21.0.1
elixir 1.7.3-otp-21
erlang 21.2.4
elixir 1.8.1-otp-21
@@ -1,6 +1,9 @@
ALL :=
CLEAN :=

PREFIX = $(MIX_COMPILE_PATH)/../priv
BUILD = $(MIX_COMPILE_PATH)/../obj

ifeq ($(ERL_EI_INCLUDE_DIR),)

$(warning ERL_EI_INCLUDE_DIR not set. Invoke via mix)
@@ -35,7 +38,7 @@ fbos_clean_arduino_firmware:
cd c_src/farmbot-arduino-firmware && make clean BUILD_DIR=$(PWD)/_build FBARDUINO_FIRMWARE_SRC_DIR=$(PWD)/c_src/farmbot-arduino-firmware/src BIN_DIR=$(PWD)/priv

fbos_build_calendar_nif:
make -f c_src/build_calendar/Makefile all ERL_EI_INCLUDE_DIR=$(ERL_EI_INCLUDE_DIR) ERL_EI_LIBDIR=$(ERL_EI_LIBDIR)
make -f c_src/build_calendar/Makefile all ERL_EI_INCLUDE_DIR=$(ERL_EI_INCLUDE_DIR) ERL_EI_LIBDIR=$(ERL_EI_LIBDIR) BUILD=$(BUILD) PREFIX=$(PREFIX)

fbos_clean_build_calendar_nif:
make -f c_src/build_calendar/Makefile clean ERL_EI_INCLUDE_DIR=$(ERL_EI_INCLUDE_DIR) ERL_EI_LIBDIR=$(ERL_EI_LIBDIR)
make -f c_src/build_calendar/Makefile clean ERL_EI_INCLUDE_DIR=$(ERL_EI_INCLUDE_DIR) ERL_EI_LIBDIR=$(ERL_EI_LIBDIR) BUILD=$(BUILD) PREFIX=$(PREFIX)
@@ -9,7 +9,7 @@ ERL_LDFLAGS ?= -L$(ERL_EI_LIBDIR)
NIF_LDFLAGS += -fPIC -shared
NIF_CFLAGS ?= -fPIC -O2 -Wall

NIF=priv/build_calendar.so
NIF=$(PREFIX)/build_calendar.so

ifeq ($(CROSSCOMPILE),)
ifeq ($(shell uname),Darwin)
@@ -1,7 +1,7 @@
use Mix.Config

# Mix configs.
target = Mix.Project.config()[:target]
target = Mix.target()
env = Mix.env()

config :logger, [
@@ -76,11 +76,11 @@ config :nerves, :firmware,
import_config("nerves_hub.exs")

case target do
"host" ->
:host ->
import_config("host/#{env}.exs")

_ ->
custom_rootfs_overlay_dir = "config/target/rootfs_overlay_#{Mix.Project.config[:target]}"
custom_rootfs_overlay_dir = "config/target/rootfs_overlay_#{target}"
import_config("target/#{env}.exs")
if File.exists?("config/target/#{target}.exs"),
do: import_config("target/#{target}.exs")
@@ -352,7 +352,7 @@ defmodule Farmbot.BotState.Transport.AMQP do
client_properties: [
{"version", :longstr, Farmbot.Project.version()},
{"commit", :longstr, Farmbot.Project.commit()},
{"target", :longstr, Farmbot.Project.target()},
{"target", :longstr, to_string(Farmbot.Project.target())},
{"opened", :longstr, to_string(DateTime.utc_now())},
{"product", :longstr, "farmbot_os"},
{"bot", :longstr, bot},
@@ -18,13 +18,13 @@ defmodule Farmbot.Firmware.UartHandler.AutoDetector do

#TODO(Connor) - Maybe make this configurable?
case Farmbot.Project.target() do
"rpi3" ->
:rpi3 ->
@ignore_devs ["ttyAMA0", "ttyS0", "ttyS3"]
"rpi" ->
:rpi ->
@ignore_devs ["ttyS0", "ttyS3"]
"rpi0" ->
:rpi0 ->
@ignore_devs ["ttyS0", "ttyS3"]
"host" ->
:host ->
@ignore_devs ["ttyS0"]
end

@@ -166,7 +166,7 @@ defmodule Farmbot.Firmware.UartHandler.Update do
end
end

if Farmbot.Project.target() in ["rpi0", "rpi"] do
if Farmbot.Project.target() in [:rpi0, :rpi] do
@reset_pin 19
defp reset_init do
{:ok, pid} = ElixirALE.GPIO.start_link(@reset_pin, :output)
@@ -2,11 +2,11 @@ defmodule Farmbot.Project do
@moduledoc "Farmbot project config"

@version Mix.Project.config[:version]
@target Mix.Project.config[:target]
@commit Mix.Project.config[:commit]
@branch Mix.Project.config[:branch]
@arduino_commit Mix.Project.config[:arduino_commit]
@env Mix.env()
@target Mix.target()

@external_resource ".git"

120 mix.exs
@@ -1,11 +1,13 @@
defmodule Farmbot.Mixfile do
use Mix.Project
@target System.get_env("MIX_TARGET") || "host"
@all_targets [:rpi0, :rpi3, :rpi]

@version Path.join(__DIR__, "VERSION") |> File.read!() |> String.trim()
@commit System.cmd("git", ~w"rev-parse --verify HEAD") |> elem(0) |> String.trim()
@branch System.cmd("git", ~w"rev-parse --abbrev-ref HEAD") |> elem(0) |> String.trim()
System.put_env("NERVES_FW_VCS_IDENTIFIER", @commit)
System.put_env("NERVES_FW_MISC", @branch)

defp commit, do: @commit

defp branch, do: @branch
@@ -22,27 +24,22 @@ defmodule Farmbot.Mixfile do
[
app: :farmbot,
description: "The Brains of the Farmbot Project",
elixir: "~> 1.6",
elixir: "~> 1.8",
package: package(),
make_clean: ["clean"],
make_env: make_env(),
compilers: [:elixir_make] ++ Mix.compilers(),
test_coverage: [tool: ExCoveralls],
version: @version,
target: @target,
commit: commit(),
branch: branch(),
arduino_commit: arduino_commit(),
archives: [nerves_bootstrap: "~> 1.2"],
build_embedded: Mix.env() == :prod,
build_embedded: Mix.target() != :host,
start_permanent: Mix.env() == :prod,
deps_path: "deps/#{@target}",
build_path: "_build/#{@target}",
lockfile: "mix.lock.#{@target}",
config_path: "config/config.exs",
elixirc_paths: elixirc_paths(Mix.env(), @target),
aliases: aliases(Mix.env(), @target),
deps: deps() ++ deps(@target),
elixirc_paths: elixirc_paths(Mix.env(), Mix.target()),
aliases: aliases(Mix.env(), Mix.target()),
deps: deps(),
dialyzer: [
plt_add_deps: :transitive,
plt_add_apps: [:mix],
@@ -62,23 +59,13 @@ defmodule Farmbot.Mixfile do
]
end

def application("host") do
[
mod: {Farmbot, []},
extra_applications: [:logger, :eex, :ssl, :inets, :runtime_tools]
]
end

def application(_target) do
def application() do
[
mod: {Farmbot, []},
extra_applications: [:logger, :eex, :ssl, :inets, :runtime_tools],
included_applications: [:nerves_hub]
]
end

def application(), do: application(@target)

defp docs do
[
main: "building",
@@ -94,25 +81,12 @@ defmodule Farmbot.Mixfile do
]
end

defp make_env do
case System.get_env("ERL_EI_INCLUDE_DIR") do
nil ->
%{
"ERL_EI_INCLUDE_DIR" => Path.join([:code.root_dir(), "usr", "include"]),
"ERL_EI_LIBDIR" => Path.join([:code.root_dir(), "usr", "lib"]),
"MIX_TARGET" => @target
}

_ ->
%{}
end
end

defp deps do
[
# Common deps
{:nerves, "~> 1.3", runtime: false},
{:nerves_hub_cli, "~> 0.5.1", runtime: false},
{:elixir_make, "~> 0.4", runtime: false},
{:elixir_make, "~> 0.5", runtime: false},
{:shoehorn, "~> 0.4"},
{:gen_stage, "~> 0.14"},
{:phoenix_html, "~> 2.12"},
@@ -137,51 +111,38 @@ defmodule Farmbot.Mixfile do
{:ring_logger, "~> 0.5"},
{:bbmustache, "~> 1.6"},
{:sqlite_ecto2, "~> 2.2"},
{:logger_backend_sqlite, "~> 2.1"}
{:logger_backend_sqlite, "~> 2.1"},

# Host only deps
{:ex_doc, "~> 0.19", only: :dev, targets: :host},
{:excoveralls, "~> 0.10", only: :test, targets: :host},
{:dialyxir, "~> 1.0.0-rc.3", only: :dev, runtime: false, targets: :host},
{:credo, "~> 0.10", only: [:dev, :test], runtime: false, targets: :host},
{:mock, "~> 0.3", only: :test, targets: :host},
{:faker, "~> 0.11", only: :test, targets: :host},

# Target Deps
{:nerves_runtime, "~> 0.8", targets: @all_targets},
{:nerves_hub, "~> 0.2.0", targets: @all_targets},
{:nerves_firmware, "~> 0.4", targets: @all_targets},
{:nerves_firmware_ssh, "~> 0.3", targets: @all_targets},
{:nerves_init_gadget, "~> 0.5", only: :dev, targets: @all_targets},
{:nerves_time, "~> 0.2", targets: @all_targets},
{:nerves_network, "~> 0.5", targets: @all_targets},
{:nerves_wpa_supplicant, "~> 0.5.1", targets: @all_targets},
{:dhcp_server, "~> 0.7", targets: @all_targets},
{:elixir_ale, "~> 1.1", targets: @all_targets},
{:mdns, "~> 1.0", targets: @all_targets},

{:farmbot_system_rpi3, "1.6.3-farmbot.0", runtime: false, targets: :rpi3},
{:farmbot_system_rpi0, "1.6.3-farmbot.0", runtime: false, targets: :rpi0},
{:farmbot_system_rpi, "1.6.3-farmbot.0", runtime: false, targets: :rpi}
]
end

defp deps("host") do
[
{:ex_doc, "~> 0.19", only: :dev},
{:excoveralls, "~> 0.10", only: :test},
{:dialyxir, "~> 1.0.0-rc.3", only: :dev, runtime: false},
{:credo, "~> 0.10", only: [:dev, :test], runtime: false},
{:mock, "~> 0.3", only: :test},
{:faker, "~> 0.11", only: :test}
]
end

defp deps(target) do
system(target) ++
[
{:nerves_runtime, "~> 0.8"},
{:nerves_hub, "~> 0.2.0"},
{:nerves_firmware, "~> 0.4"},
{:nerves_firmware_ssh, "~> 0.3"},
{:nerves_init_gadget, "~> 0.5", only: :dev},
{:nerves_time, "~> 0.2"},
{:nerves_network, "~> 0.5"},
{:nerves_wpa_supplicant, "~> 0.5.1"},
{:dhcp_server, "~> 0.6"},
{:elixir_ale, "~> 1.1"},
{:mdns, "~> 1.0"}
]
end

defp system("rpi3"),
do: [{:farmbot_system_rpi3, "1.6.1-farmbot.1", runtime: false}]

defp system("rpi0"),
do: [{:farmbot_system_rpi0, "1.6.1-farmbot.1", runtime: false}]

defp system("rpi"),
do: [{:farmbot_system_rpi, "1.6.1-farmbot.1", runtime: false}]

defp package do
[
name: "farmbot",
maintainers: ["Farmbot.io"],
licenses: ["MIT"],
links: %{"github" => "https://github.com/farmbot/farmbot_os"}
]
@@ -204,15 +165,10 @@ defmodule Farmbot.Mixfile do
end

defp aliases(_env, "host"),
do: [
"firmware.slack": ["farmbot.firmware.slack"],
"firmware.sign": ["farmbot.firmware.sign"]
]
do: []

defp aliases(_env, _system) do
[
"firmware.slack": ["farmbot.firmware.slack"],
"firmware.sign": ["farmbot.firmware.sign"],
loadconfig: [&bootstrap/1]
]
end
Oops, something went wrong.

0 comments on commit dfe01ae

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