-
Notifications
You must be signed in to change notification settings - Fork 3
/
mix.exs
95 lines (82 loc) · 2.4 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
defmodule GraphQL.Parser.Mixfile do
use Mix.Project
@version "0.0.3"
def project do
[app: :graphql_parser,
name: "GraphQL.Parser",
version: @version,
elixir: "~> 1.2",
compilers: [:nif] ++ Mix.compilers,
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
description: description,
package: package,
docs: docs,
deps: deps]
end
def application do
[applications: [:logger]]
end
defp deps do
[{:poison, "~> 2.0"},
{:earmark, "~> 0.1", only: :dev},
{:ex_doc, "~> 0.11", only: :dev}]
end
defp description do
"""
An elixir interface for libgraphqlparser implemented as a NIF for parsing
GraphQL.
"""
end
defp package do
[maintainers: ["Vignesh Rajagopalan"],
licenses: ["MIT"],
links: %{"GitHub" => "https://github.com/aarvay/graphql_parser"},
files: ["lib", "src", "Makefile", "mix.exs", "README.md",
"libgraphqlparser/ast/ast.ast", "libgraphqlparser/ast/*.py",
"libgraphqlparser/c/*.cpp", "libgraphqlparser/c/*.h",
"libgraphqlparser/*.h", "libgraphqlparser/*.cpp",
"libgraphqlparser/*.lpp", "libgraphqlparser/*.hh",
"libgraphqlparser/*.hpp", "libgraphqlparser/*.ypp",
"libgraphqlparser/CMakeLists.txt", "libgraphqlparser/LICENSE",
"libgraphqlparser/PATENTS", "libgraphqlparser/README.md"]]
end
defp docs do
[source_ref: "v#{@version}",
extras: ["README.md"],
main: "README"]
end
end
defmodule GraphQL.Parser.MixHelper do
def check_exit_status({res, exit_status_code}) do
if exit_status_code != 0 do
raise Mix.Error, message: """
Build command exited with status code: #{exit_status_code}.
Make sure you're running `mix compile` from project's root.
"""
end
IO.binwrite res # verbose
end
end
defmodule Mix.Tasks.Compile.Nif do
use Mix.Task
import GraphQL.Parser.MixHelper
@shortdoc "Compiles the NIF library"
def run(_) do
try do
File.mkdir_p!("priv")
System.cmd("make", [], stderr_to_stdout: true) |> check_exit_status
rescue
e in Mix.Error ->
raise e
e in ErlangError ->
case e.original do
:enoent ->
raise Mix.Error, message: """
Please check if `cmake` and `make` are installed
"""
end
end
Mix.Project.build_structure
end
end