-
Notifications
You must be signed in to change notification settings - Fork 3
/
SConstruct
176 lines (150 loc) · 4.82 KB
/
SConstruct
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
174
175
176
#
# Main plumCore build file
#
# Copyright (c) 2017, Marek Koza (qyx@krtko.org)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
import time
import yaml
import kconfiglib
# Create default environment and export it. It will be modified later
# by port-specific and other build scripts.
env = Environment()
env.Append(ENV = os.environ)
Export("env")
# Some helpers to make the build looks pretty
SConscript("pretty.SConscript")
objs = []
Export("objs")
conf = {}
Export("conf")
SConscript("kconfig.SConscript")
env.LoadKconfig("Kconfig", ".config")
# And generate the corresponding config.h file for inclusion in sources
env.Command(
target = "config.h",
source = ".config",
action = Action("genconfig", env["GENCONFIGCOMSTR"])
)
# Examine the Git repository and build the version string
SConscript("version.SConscript")
env["PORTFILE"] = "bin/%s" % conf["OUTPUT_FILE_PREFIX"];
if conf["OUTPUT_FILE_PORT_PREFIX"] == "y":
env["PORTFILE"] += "-" + conf["PORT_NAME"]
if conf["OUTPUT_FILE_VERSION_SUFFIX"] == "y":
env["PORTFILE"] += "-" + env["VERSION"]
# Must be included beforehand, it defines the toolchain used
SConscript("ports/SConscript")
SConscript("platforms/SConscript")
env["CC"] = "%s-gcc" % env["TOOLCHAIN"]
env["CXX"] = "%s-g++" % env["TOOLCHAIN"]
env["AR"] = "%s-ar" % env["TOOLCHAIN"]
env["AS"] = "%s-as" % env["TOOLCHAIN"]
env["LD"] = "%s-gcc" % env["TOOLCHAIN"]
env["NM"] = "%s-nm" % env["TOOLCHAIN"]
env["GDB"] = "gdb-multiarch"
env["OBJCOPY"] = "%s-objcopy" % env["TOOLCHAIN"]
env["OBJDUMP"] = "%s-objdump" % env["TOOLCHAIN"]
env["SIZE"] = "%s-size" % env["TOOLCHAIN"]
env["READELF"] = "%s-readelf" % env["TOOLCHAIN"]
env["STRIP"] = "%s-strip" % env["TOOLCHAIN"]
env["OOCD"] = "openocd"
env["CREATEFW"] = "tools/createfw.py"
# Add uMeshFw HAL
env.Append(CPPPATH = [
Dir("hal/common"),
Dir("hal/modules"),
Dir("hal/interfaces"),
])
objs.append(env.Object(source = [
File(Glob("hal/common/*.c")),
File(Glob("hal/modules/*.c")),
File(Glob("hal/interfaces/*.c")),
]))
SConscript("doc.SConscript")
SConscript("applications/SConscript")
SConscript("microkernel/freertos/SConscript")
objs.append(SConscript("uhal/SConscript"))
objs.append(SConscript("system/SConscript"))
SConscript("lib/SConscript")
SConscript("protocols/SConscript")
objs.append(SConscript("services/SConscript"))
objs.append(SConscript("applets/SConscript"))
# Required to allow including things like "services/cli.h"
env.Append(CPPPATH = [Dir(".")])
env.Append(LINKFLAGS = [
env["CFLAGS"],
"-Wl,-Map=%s.map" % env["PORTFILE"],
])
env["LOAD_ADDRESS"] = "0x0";
if conf["FW_IMAGE_ELF"] == "y":
env["LOAD_ADDRESS"] = conf["ELF_IMAGE_LOAD_ADDRESS"]
if conf["ELF_IMAGE_XIP"] == "y":
env["LOAD_ADDRESS"] = int(conf["ELF_IMAGE_LOAD_ADDRESS"], 0) + 0x100
env.Append(LINKFLAGS = [
"-Wl,--defsym=LOAD_ADDRESS=%s" % env["LOAD_ADDRESS"],
])
env.Append(CFLAGS = [
"-Os",
"-g3",
"-gdwarf-4",
"-fno-common",
"-fdiagnostics-color=always",
"-ffunction-sections",
"-fdata-sections",
"-fdiagnostics-color=always",
"--std=gnu2x",
"-Wall",
"-Wextra",
"-pedantic",
#~ "-Werror",
"-Winit-self",
"-Wreturn-local-addr",
"-Wswitch-default",
"-Wuninitialized",
"-Wundef",
#~ "-Wstack-usage=256",
"-Wshadow",
"-Wimplicit-function-declaration",
"-Wcast-qual",
# "-Wwrite-strings",
# "-Wconversion",
"-Wlogical-op",
"-Wmissing-declarations",
"-Wno-missing-field-initializers",
"-Wstack-protector",
"-Wredundant-decls",
"-Wmissing-prototypes",
"-Wstrict-prototypes",
"-Wno-expansion-to-defined",
"-Wno-unused-function",
])
env.Append(LIBS = [
env["LIBOCM3"],
"c",
"gcc",
"nosys",
"m",
])
SConscript("firmware.SConscript")
Default("firmware")