-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmix.exs
More file actions
173 lines (154 loc) · 4.07 KB
/
Copy pathmix.exs
File metadata and controls
173 lines (154 loc) · 4.07 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
is_nerves_sg2002_emmc =
System.get_env("NERVES_STORAGE") == "emmc" or
String.ends_with?(__DIR__, "nerves_system_sg2002_emmc")
nerves_sg2002_module =
if is_nerves_sg2002_emmc,
do: NervesSystemSG2002EMMC.MixProject,
else: NervesSystemSG2002.MixProject
defmodule nerves_sg2002_module do
use Mix.Project
@github_organization "fermuch"
@base_app :nerves_system_sg2002
@source_url "https://github.com/#{@github_organization}/#{@base_app}"
@version Path.join(__DIR__, "VERSION")
|> File.read!()
|> String.trim()
@is_emmc is_nerves_sg2002_emmc
def project do
[
app: app(),
version: @version,
elixir: "~> 1.18.4",
compilers: Mix.compilers() ++ [:nerves_package],
nerves_package: nerves_package(),
description: description(),
package: package(),
deps: deps(),
aliases: [loadconfig: [&bootstrap/1]],
docs: docs()
]
end
def application do
[]
end
defp bootstrap(args) do
set_target()
Application.start(:nerves_bootstrap)
Mix.Task.run("loadconfig", args)
end
def cli do
[preferred_envs: %{docs: :docs, "hex.build": :docs, "hex.publish": :docs}]
end
defp emmc? do
@is_emmc
end
defp app do
if emmc?(), do: :nerves_system_sg2002_emmc, else: @base_app
end
defp nerves_package do
defconfig = if emmc?(), do: "nerves_defconfig_emmc", else: "nerves_defconfig"
[
type: :system,
artifact_sites: [
{:github_releases, "#{@github_organization}/#{@base_app}"}
],
build_runner: Nerves.Artifact.BuildRunners.Docker,
build_runner_config: [
docker: {"Dockerfile", "fermuch/recamera-builder:latest"}
],
build_runner_opts: build_runner_opts(),
platform: Nerves.System.BR,
platform_config: [
defconfig: defconfig
],
# # baseline_rv64 enables the a, c, d, and m extensions in zig
env: [
{"TARGET_ARCH", "riscv64"},
{"TARGET_CPU", "baseline_rv64"},
{"TARGET_OS", "linux"},
{"TARGET_ABI", "musl"}
],
checksum: package_files()
]
end
defp deps do
[
{:nerves, "~> 1.13.1", runtime: false},
{:nerves_system_br, "~> 1.33.2", runtime: false},
{:nerves_toolchain_riscv64_nerves_linux_musl, "~> 14.2.0", runtime: false},
{:nerves_system_linter, "~> 0.4.1", only: [:dev, :test], runtime: false},
{:ex_doc, "~> 0.40.1", only: :docs, runtime: false}
]
end
defp description do
"Nerves System - SG2002"
end
defp docs do
[
extras: ["README.md", "CHANGELOG.md"],
main: "readme",
assets: %{"assets" => "./assets"},
source_ref: "v#{@version}",
source_url: @source_url,
skip_undefined_reference_warnings_on: ["CHANGELOG.md"]
]
end
defp package do
[
files: package_files(),
licenses: ["GPL-2.0-only", "GPL-2.0-or-later"],
links: %{
"GitHub" => @source_url
}
]
end
defp package_files do
[
"board",
"boot",
"package",
"patches",
"fwup_include",
"rootfs_overlay",
"rootfs_overlay_sd",
"rootfs_overlay_emmc",
"uboot-config",
"external.mk",
"Config.in",
"CHANGELOG.md",
"fwup-ops.conf",
"fwup-ops-emmc.conf",
"fwup.conf",
"fwup-emmc.conf",
"mix.exs",
"nerves_defconfig",
"nerves_defconfig_emmc",
"post-build.sh",
"post-build-emmc.sh",
"post-createfs.sh",
"post-createfs-emmc.sh",
"README.md",
"VERSION"
]
end
defp build_runner_opts() do
# Download source files first to get download errors right away.
[
make_args:
primary_site() ++ ["source", "cvitekconfig", "cvitekfsbl", "sg2002-nerves-fixes", "all"]
]
end
defp primary_site() do
case System.get_env("BR2_PRIMARY_SITE") do
nil -> []
primary_site -> ["BR2_PRIMARY_SITE=#{primary_site}"]
end
end
defp set_target() do
if function_exported?(Mix, :target, 1) do
apply(Mix, :target, [:target])
else
System.put_env("MIX_TARGET", "target")
end
end
end