-
Notifications
You must be signed in to change notification settings - Fork 143
/
build_target.py.in
106 lines (89 loc) · 4.05 KB
/
build_target.py.in
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
# -*- coding: utf-8 -*-
#
# Copyright (c) 2018-2021, Niklas Hauser
# Copyright (c) 2019, Raphael Lehmann
#
# This file is part of the modm project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# -----------------------------------------------------------------------------
from os.path import join, abspath, relpath
def build_target(env, sources):
# Building application
program = env.Program(target=env["CONFIG_PROJECT_NAME"]+"{{ program_extension }}", source=sources)
chosen_program = env.ChooseFirmware(program)
# Clean additional artifacts
env.Clean(program, join(env["BUILDPATH"], env["CONFIG_PROJECT_NAME"]+".bin"))
env.Clean(program, join(env["BUILDPATH"], env["CONFIG_PROJECT_NAME"]+".hex"))
env.Clean(program, join(env["BUILDPATH"], env["CONFIG_PROJECT_NAME"]+".lss"))
env.Clean(program, join(env["BUILDPATH"], env["CONFIG_PROJECT_NAME"]+".uf2"))
%% if with_compilation_db
env.Command("compile_commands.json", sources,
"python3 modm/tools/builder_compilation_db.py --{} {}".format(
env["CONFIG_PROFILE"], " ".join(relpath(env.File(s).srcnode().abspath) for s in env.Flatten(sources))))
env.Alias("compilation_db", "compile_commands.json")
%% endif
env.Alias("qtcreator", env.QtCreatorProject(sources))
env.Alias("symbols", env.Symbols(chosen_program))
env.Alias("listing", env.Listing(chosen_program))
env.Alias("bin", env.Bin(chosen_program))
env.Alias("hex", env.Hex(chosen_program))
env.Alias("build", program)
%% if platform in ["hosted"]
env.Alias("run", env.Run(program))
env.Alias("all", ["build", "run"])
%% else
# The executable depends on the linkerscript
env.Depends(target=program, dependency="{{ linkerscript }}")
env.Alias("size", env.Size(chosen_program))
%% if core.startswith("cortex-m")
env.Alias("uf2", env.UF2(chosen_program))
env.Alias("log-itm", env.LogItmOpenOcd())
env.Alias("log-rtt", env.LogRttOpenOcd())
env.Alias("log-itm-jlink", env.LogItmJLink())
env.Alias("log-rtt-jlink", env.LogRttJLink())
env.Alias("artifact", env.CacheArtifact(program))
%% set artifact = ', "artifact"' if upload_with_artifact else ''
env.Alias("program-openocd", [env.ProgramOpenOcd(chosen_program){{ artifact }}])
env.Alias("program-remote", [env.ProgramGdbRemote(chosen_program){{ artifact }}])
env.Alias("program-bmp", [env.ProgramBMP(chosen_program){{ artifact }}])
env.Alias("program-jlink", [env.ProgramJLink(chosen_program){{ artifact }}])
env.Alias('program-dfu', [env.ProgramDFU(env.Bin(chosen_program)){{ artifact }}])
%% if platform in ["sam"]
env.Alias("program-bossac", [env.ProgramBossac(env.Bin(chosen_program)){{ artifact }}])
%% endif
env.Alias("debug-openocd", env.DebugOpenOcd(chosen_program))
env.Alias("debug-remote", env.DebugGdbRemote(chosen_program))
env.Alias("debug-bmp", env.DebugBMP(chosen_program))
env.Alias("debug-jlink", env.DebugJLink(chosen_program))
env.Alias("debug-coredump", env.DebugCoredump(chosen_program))
env.Alias("reset-openocd", env.ResetOpenOcd())
env.Alias("reset-bmp", env.ResetBMP())
env.Alias("reset-jlink", env.ResetJLink())
env.Alias("reset-remote", env.ResetGdbRemote())
# Start only OpenOCD to attach a external (remote) debugger
env.Alias("openocd", env.OpenOcd())
env.Alias("jlink", env.JLink())
env.Alias("coredump-openocd", env.CoredumpOpenOcd())
env.Alias("coredump-bmp", env.CoredumpBMP())
env.Alias("coredump-jlink", env.CoredumpJLink())
# Default to OpenOCD
env.Alias("program", "program-openocd")
env.Alias("reset", "reset-openocd")
env.Alias("debug", "debug-openocd")
env.Alias("coredump", "coredump-openocd")
%% elif core.startswith("avr")
env.Alias("program-avrdude", env.ProgramAvrdude(chosen_program))
env.Alias("program-fuses", env.ProgramAvrdudeFuses(chosen_program))
env.Alias("program", "program-avrdude")
%% endif
env.Alias("all", ["build", "size"])
%% endif
env.Default("all")
return program
def generate(env, **kw):
env.AddMethod(build_target, "BuildTarget")
def exists(env):
return True