-
Notifications
You must be signed in to change notification settings - Fork 5
/
mix.exs
79 lines (67 loc) · 1.94 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
Code.require_file "./bootstrap/skylight_bootstrap.ex"
defmodule Mix.Tasks.Compile.Skylight do
use Mix.Task
@shortdoc "Fetches Skylight binaries and compiles native C code"
def run(_args) do
result = with :ok <- ensure_artifacts_exist(),
:ok <- SkylightBootstrap.extract_and_move(),
do: compile_c_code()
case result do
{:error, message} ->
Mix.shell.error message
raise "Failed to compile Skylight: '#{message}'"
_ -> result
end
end
defp ensure_artifacts_exist do
unless SkylightBootstrap.artifacts_already_exist? do
SkylightBootstrap.fetch()
else
:ok
end
end
defp compile_c_code do
Mix.shell.info "Compiling native C code..."
check_executable!("make")
{result, _errcode} = System.cmd("make", ["priv/skylight_nif.so"], stderr_to_stdout: true)
IO.binwrite(result)
end
defp check_executable!(exec) do
unless System.find_executable(exec) do
Mix.raise "`#{exec}` not found in path."
end
end
end
defmodule Skylight.Mixfile do
use Mix.Project
def project do
[app: :skylight,
version: "0.0.1",
elixir: "~> 1.1",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
compilers: [:skylight] ++ Mix.compilers,
aliases: [test: "test --no-start"],
elixirc_paths: elixirc_paths(),
deps: deps]
end
def application do
[applications: [:logger, :crypto, :uuid],
env: [version: "0.8.1",
lazy_start: true,
auth_url: "https://auth.skylight.io/agent",
validate_authentication: false],
mod: {Skylight, []}]
end
defp elixirc_paths do
~w(lib bootstrap/mix/tasks)
end
defp deps do
[{:uuid, "~> 1.1"},
{:plug, ">= 1.0.0", optional: true},
{:cowboy, ">= 1.0.0", optional: true},
{:ecto, ">= 1.0.0", optional: true},
{:cowboy, ">= 1.0.0", only: :test},
{:ex_doc, "~> 0.10", only: :docs}]
end
end