-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmix.exs
95 lines (84 loc) · 2.45 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 ImgDecode.MixProject do
use Mix.Project
@version "0.3.1"
@github_url "https://github.com/cocoa-xu/image_rs"
@dev? String.ends_with?(@version, "-dev")
@force_build? System.get_env("IMAGE_RS_BUILD") in ["1", "true"]
@nerves_rust_target_triple_mapping %{
"armv6-nerves-linux-gnueabihf": "arm-unknown-linux-gnueabihf",
"armv7-nerves-linux-gnueabihf": "armv7-unknown-linux-gnueabihf",
"aarch64-nerves-linux-gnu": "aarch64-unknown-linux-gnu"
}
def project do
if is_binary(System.get_env("NERVES_SDK_SYSROOT")) do
components =
System.get_env("CC")
|> tap(&System.put_env("RUSTFLAGS", "-C linker=#{&1}"))
|> Path.basename()
|> String.split("-")
target_triple =
components
|> Enum.slice(0, Enum.count(components) - 1)
|> Enum.join("-")
mapping = Map.get(@nerves_rust_target_triple_mapping, String.to_atom(target_triple))
if is_binary(mapping) do
System.put_env("RUSTLER_TARGET", mapping)
end
end
[
app: :image_rs,
version: @version,
elixir: "~> 1.12",
start_permanent: Mix.env() == :prod,
description: description(),
package: package(),
deps: deps(),
source_url: @github_url,
aliases: [
"rust.lint": ["cmd cargo clippy --manifest-path=native/image_rs/Cargo.toml -- -Dwarnings"],
"rust.fmt": ["cmd cargo fmt --manifest-path=native/image_rs/Cargo.toml --all"],
ci: ["format", "rust.fmt", "rust.lint", "test"]
]
]
end
def application do
[
env: [
kino_render_encoding: :png,
kino_render_max_size: {8192, 8192},
kino_render_tab_order: [:image, :raw]
],
extra_applications: [:logger]
]
end
defp description() do
"A tiny Elixir library for image decoding task with image_rs as the backend."
end
defp deps do
[
# compilation
{:castore, "~> 1.0 or ~> 0.1"},
{:rustler, "~> 0.30.0", optional: not (@dev? or @force_build?)},
{:rustler_precompiled, "~> 0.7"},
# optional
{:nx, "~> 0.4", optional: true},
{:kino, "~> 0.7", optional: true},
# docs
{:ex_doc, "~> 0.29", only: :docs, runtime: false}
]
end
defp package() do
[
name: "image_rs",
files: ~w(
lib
native
checksum-*.exs
mix.exs
README.md
LICENSE),
licenses: ["Apache-2.0"],
links: %{"GitHub" => @github_url}
]
end
end