-
Notifications
You must be signed in to change notification settings - Fork 266
/
mix.exs
224 lines (200 loc) · 5.87 KB
/
mix.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
defmodule Farmbot.Mixfile do
use Mix.Project
@target System.get_env("MIX_TARGET") || "host"
@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
defp arduino_commit do
opts = [cd: "c_src/farmbot-arduino-firmware"]
System.cmd("git", ~w"rev-parse --verify HEAD", opts)
|> elem(0)
|> String.trim()
end
def project do
[
app: :farmbot,
description: "The Brains of the Farmbot Project",
elixir: "~> 1.6",
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,
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),
dialyzer: [
plt_add_deps: :transitive,
plt_add_apps: [:mix],
flags: []
],
preferred_cli_env: [
test: :test,
coveralls: :test,
"coveralls.detail": :test,
"coveralls.post": :test,
"coveralls.html": :test,
"coveralls.circle": :test
],
source_url: "https://github.com/Farmbot/farmbot_os",
homepage_url: "http://farmbot.io",
docs: docs()
]
end
def application("host") do
[
mod: {Farmbot, []},
extra_applications: [:logger, :eex, :ssl, :inets, :runtime_tools]
]
end
def application(_target) 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",
logo: "priv/static/farmbot_logo.png",
source_ref: commit(),
extras: [
"docs/BUILDING.md",
"docs/FAQ.md",
"README.md",
"CHANGELOG.md",
"CONTRIBUTING.md"
]
]
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
[
{:nerves, "~> 1.3", runtime: false},
{:nerves_hub_cli, "~> 0.5", runtime: false},
{:elixir_make, "~> 0.4", runtime: false},
{:shoehorn, "~> 0.4"},
{:gen_stage, "~> 0.14"},
{:phoenix_html, "~> 2.12"},
{:httpoison, "~> 1.3"},
{:poison, "~> 3.1.0"},
{:jason, "~> 1.1"},
{:timex, "~> 3.4"},
{:fs, "~> 3.4"},
{:nerves_uart, "~> 1.2"},
{:cowboy, "~> 2.5"},
{:plug, "~> 1.6"},
{:cors_plug, "~> 1.5"},
{:amqp, "~> 1.0"},
# AMQP hacks
{:jsx, "~> 2.9", override: true},
{:ranch, "~> 1.6", override: true},
{:ranch_proxy_protocol, "~> 2.1", override: true},
# End hacks
{:rsa, "~> 0.0.1"},
{:joken, "~> 1.5"},
{:uuid, "~> 1.1"},
{:ring_logger, "~> 0.5"},
{:bbmustache, "~> 1.6"},
{:sqlite_ecto2, "~> 2.2"},
{:logger_backend_sqlite, "~> 2.1"}
]
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.3"},
{:nerves_wpa_supplicant, "~> 0.3"},
{:dhcp_server, "~> 0.6"},
{:elixir_ale, "~> 1.1"},
{:mdns, "~> 1.0"}
]
end
defp system("rpi3"),
do: [{:farmbot_system_rpi3, "1.5.1-farmbot.1", runtime: false}]
defp system("rpi0"),
do: [{:farmbot_system_rpi0, "1.5.1-farmbot.0", runtime: false}]
defp system("rpi"),
do: [{:farmbot_system_rpi, "1.5.1-farmbot.0", runtime: false}]
defp package do
[
name: "farmbot",
maintainers: ["Farmbot.io"],
licenses: ["MIT"],
links: %{"github" => "https://github.com/farmbot/farmbot_os"}
]
end
defp elixirc_paths(:test, "host") do
["./lib", "./platform/host", "./test/support"]
end
defp elixirc_paths(_, "host") do
["./lib", "./platform/host"]
end
defp elixirc_paths(_env, _target) do
["./lib", "./platform/target"]
end
defp aliases(:test, "host") do
[test: ["ecto.drop", "ecto.create --quiet", "ecto.migrate", "test"]]
end
defp aliases(_env, "host"),
do: [
"firmware.slack": ["farmbot.firmware.slack"],
"firmware.sign": ["farmbot.firmware.sign"]
]
defp aliases(_env, _system) do
[
"firmware.slack": ["farmbot.firmware.slack"],
"firmware.sign": ["farmbot.firmware.sign"],
loadconfig: [&bootstrap/1]
]
end
defp bootstrap(args) do
Application.start(:nerves_bootstrap)
Mix.Task.run("loadconfig", args)
end
end