forked from kbrw/mailibex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mix.exs
109 lines (95 loc) · 3.04 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
defmodule Mix.Tasks.Compile.Iconv do
@shortdoc "Compiles Iconv"
use Mix.Task
@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}\" -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
:ok
end
end
defmodule Mailibex.Mixfile do
use Mix.Project
def app, do: :mailibex
def version, do: "0.2.1"
def source_url, do: "https://github.com/kbrw/#{app()}"
def project do
[app: app(),
version: version(),
elixir: "~> 1.12",
description: description(),
package: package(),
compilers: [:iconv, :elixir, :app],
deps: deps(),
docs: docs(),
elixirc_options: [warnings_as_errors: true],
]
end
def application do
[
extra_applications: [
:crypto,
:erl_interface,
:inets,
:logger,
:public_key,
:ssl,
],
]
end
defp package do
[ maintainers: ["Arnaud Wetzel","heri16"],
licenses: ["The MIT License (MIT)"],
links: %{
"Changelog" => "https://hexdocs.pm/#{app()}/changelog.html",
"GitHub" => source_url()
},
]
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.31", only: :dev, runtime: false}
]
end
defp docs do
[
extras: [
"CHANGELOG.md": [title: "Changelog"],
"README.md": [title: "Overview"]
],
main: "readme",
source_url: source_url(),
# We need to git tag with the corresponding format.
source_ref: "v#{version()}",
]
end
end