-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmix.exs
77 lines (69 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
defmodule BeamQN.MixProject do
use Mix.Project
def project do
[
app: :beamqn,
version: "0.1.0",
elixir: "~> 1.14",
start_permanent: Mix.env() == :prod,
deps: deps(),
# Prevent multiple CBQN checkouts.
deps_path: "_build/default/lib/",
aliases: aliases()
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
# {:dep_from_hexpm, "~> 0.3.0"},
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}
{:cbqn, git: "https://github.com/dzaima/CBQN.git", ref: "4f898f3", app: false, compile: compile_cbqn()}
]
end
defp aliases do
[
"deps.compile": ["deps.get", "deps.compile", fn _args -> Mix.Shell.cmd(compile_cbqn(), [cd: "#{Mix.Project.deps_path()}/cbqn"], &print_info/1) end],
"deps.clean": ["deps.clean", &clean_cbqn/1],
compile: ["compile", &compile_beamqn/1]
]
end
defp print_info(s) do
Mix.Shell.IO.info(String.trim(s))
end
defp compile_beamqn(_args) do
case :os.type() do
{_family, os} when os in [:linux, :darwin, :solaris] ->
Mix.Shell.cmd("DEPS_DIR=#{Mix.Project.deps_path()} make -C c_src", [], &print_info/1)
{_family, os} when os in [:freebsd] ->
Mix.Shell.cmd("DEPS_DIR=#{Mix.Project.deps_path()} gmake -C c_src", [], &print_info/1)
end
end
defp compile_cbqn do
case :os.type() do
{_family, os} when os in [:linux, :darwin, :solaris] ->
"make f='-DNO_MMAP -DUSE_SETJMP' FFI=0 static-lib"
{_family, os} when os in [:freebsd] ->
"gmake f='-DNO_MMAP -DUSE_SETJMP' FFI=0 static-lib"
end
end
defp clean_cbqn(_args) do
if File.exists?("#{Mix.Project.deps_path()}/cbqn") do
case :os.type() do
{_family, os} when os in [:linux, :darwin, :solaris] ->
Mix.Shell.cmd("make clean", [cd: "#{Mix.Project.deps_path()}/cbqn"], &print_info/1)
{_family, os} when os in [:freebsd] ->
Mix.Shell.cmd("gmake clean", [cd: "#{Mix.Project.deps_path()}/cbqn"], &print_info/1)
end
case :os.type() do
{_family, os} when os in [:linux, :darwin, :solaris, :freebsd] ->
Mix.Shell.cmd("rm -f libcbqn.a", [cd: "#{Mix.Project.deps_path()}/cbqn"], &print_info/1)
end
end
end
end