-
Notifications
You must be signed in to change notification settings - Fork 13
/
mix.exs
148 lines (132 loc) · 3.47 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
defmodule Rclex.MixProject do
use Mix.Project
@description """
ROS 2 Client Library for Elixir.
"""
@app :rclex
@version "0.11.2"
@source_url "https://github.com/rclex/rclex"
def project do
[
app: @app,
version: @version,
elixir: "~> 1.14",
start_permanent: Mix.env() == :prod,
deps: deps(),
make_clean: ["clean"],
compilers: [:elixir_make] ++ Mix.compilers(),
aliases: [format: [&format_c/1, "format"], iwyu: [&iwyu/1]],
test_coverage: test_coverage(),
dialyzer: dialyzer(),
# for hex
description: @description,
package: package(),
# for ex_doc
name: "Rclex",
docs: docs()
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications:
[:logger] ++
case Mix.target() do
:host -> [:runtime_tools, :wx, :observer]
_ -> []
end,
mod: {Rclex.Application, []}
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:elixir_make, "~> 0.7", runtime: false},
{:credo, "~> 1.7", only: [:dev, :test], runtime: false},
{:dialyxir, "~> 1.3", only: [:dev], runtime: false},
{:benchee, "~> 1.0", only: :dev},
{:nimble_parsec, "~> 1.0"},
{:mix_test_watch, "~> 1.0", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.27", only: :dev, runtime: false}
]
end
defp package() do
%{
name: "#{@app}",
files: [
"lib",
"priv",
"src",
"mix.exs",
"README.md",
"README_ja.md",
"LICENSE",
"CHANGELOG.md",
"Makefile"
],
licenses: ["Apache-2.0"],
links: %{"Github" => @source_url}
}
end
defp docs() do
[
extras: ["README.md", "README_ja.md", "USE_ON_NERVES.md", "CHANGELOG.md"],
main: "readme",
source_ref: "v#{@version}",
source_url: @source_url
]
end
defp format_c(_args) do
file_names = File.ls!("src") |> Enum.filter(&String.ends_with?(&1, [".c", ".h"]))
[formatter | args] = ~w"clang-format -i --Werror" ++ file_names
case System.find_executable(formatter) do
nil ->
Mix.Shell.IO.info("Install C code formatter: #{formatter}.")
bin ->
System.cmd(bin, args, into: IO.stream(:stdio, :line), cd: "src")
end
end
defp iwyu(_args) do
script_path = Path.join(File.cwd!(), "scripts/iwyu.sh")
case System.find_executable("include-what-you-use") do
nil ->
Mix.Shell.IO.info("Install include-what-you-use.")
_ ->
Enum.each(
c_src_paths(),
fn file_path ->
case System.cmd(script_path, [file_path], stderr_to_stdout: true) do
{_, 2} -> nil
{return, _} -> Mix.Shell.IO.error("#{return}")
end
end
)
end
end
defp c_src_paths() do
File.ls!("src")
|> Enum.map(&Path.join("src", &1))
|> Enum.filter(&String.ends_with?(&1, ".c"))
end
defp dialyzer() do
[
plt_local_path: "priv/plts/rclex.plt",
plt_core_path: "priv/plts/core.plt",
plt_add_apps: [:mix, :eex]
]
end
defp test_coverage() do
[
summary: [
# Remove when https://github.com/rclex/rclex/issues/349 is resolved.
threshold: 80
],
ignore_modules: [
Rclex.Nif,
Rclex.Generators.MsgC.Acc,
~r/Rclex\.Pkgs.+/,
~r/Mix\.Tasks\.Rclex.+/
]
]
end
end