forked from kbrw/mailibex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mix.exs
70 lines (62 loc) · 2.36 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
defmodule Mix.Tasks.Compile.Iconv do
@shortdoc "Compiles Iconv"
@doc """
For Linux:
1. Install gcc and libconv via your distro's package manager.
For Mac OS X / macOS:
1. Install gcc and libiconv via homebrew.
For Windows:
1. Install (MSYS2)[https://msys2.github.io], then open MSYS2 Shell to download latest repo with `pacman -Sy`.
2. Install gcc from repo with `pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-libiconv`. Choose gcc only option if prompted.
3. Open the MinGW Shell, ensure `which gcc` returns `/mingw64/gcc`.
4. Add elxir bin folder and erlang bin folder to your $PATH, then run `mix deps.compile mailibex`.
4. Once the dll is compiled in your priv folder, MSYS2 is no longer required as the dll compiled is native and redistributable.
"""
def run(_) do
lib_ext = if {:win32, :nt} == :os.type, do: "dll", else: "so"
lib_file = "priv/Elixir.Iconv_nif.#{lib_ext}"
if not File.exists?(lib_file) do
[i_erts]=Path.wildcard("#{:code.root_dir}/erts*/include")
i_ei=:code.lib_dir(:erl_interface,:include)
l_ei=:code.lib_dir(:erl_interface,:lib)
args = "-L\"#{l_ei}\" -lerl_interface -lei -I\"#{i_ei}\" -I\"#{i_erts}\" -Wall -shared -fPIC"
args = args <> if {:unix, :darwin}==:os.type, do: " -undefined dynamic_lookup -dynamiclib", else: ""
args = args <> if {:win32, :nt}==:os.type, do: " -liconv", else: ""
Mix.shell.info to_string :os.cmd('gcc #{args} -v -o #{lib_file} c_src/iconv_nif.c')
end
end
end
defmodule Mailibex.Mixfile do
use Mix.Project
def project do
[app: :mailibex,
version: "0.1.4",
elixir: "> 1.3.0",
description: description(),
package: package(),
compilers: [:iconv, :elixir, :app],
deps: deps()]
end
def application do
[applications: [:logger]]
end
defp package do
[ maintainers: ["Arnaud Wetzel","heri16"],
licenses: ["The MIT License (MIT)"],
links: %{ "GitHub"=>"https://github.com/awetzel/mailibex" } ]
end
defp description do
"""
Mailibex is an email library in Elixir : currently implements
DKIM, SPF, DMARC, MimeMail (using iconv nif for encoding),
MimeType (and file type detection), a simplified api to modify or create
mimemail as a keyword list.
"""
end
defp deps do
[
{:codepagex, "~> 0.1", optional: true},
{:ex_doc, ">= 0.0.0", only: :dev}
]
end
end