25
25
26
26
from SCons .Script import DefaultEnvironment
27
27
28
+ from platformio import fs
29
+
28
30
env = DefaultEnvironment ()
29
31
platform = env .PioPlatform ()
30
32
board = env .BoardConfig ()
@@ -56,7 +58,7 @@ def load_flags(filename):
56
58
ccflags = cflags .intersection (cxxflags )
57
59
58
60
env .Append (
59
- ASFLAGS = [f for f in ccflags if isinstance (f , str ) and f .startswith ("-m" )],
61
+ ASFLAGS = [f for f in sorted ( ccflags ) if isinstance (f , str ) and f .startswith ("-m" )],
60
62
61
63
ASPPFLAGS = ["-x" , "assembler-with-cpp" ],
62
64
@@ -77,7 +79,10 @@ def load_flags(filename):
77
79
"-mcpu=%s" % board .get ("build.cpu" ),
78
80
"-mthumb" ,
79
81
"-Wl,--gc-sections" ,
80
- "--specs=nosys.specs"
82
+ "--specs=nano.specs" ,
83
+ "--specs=nosys.specs" ,
84
+ "-nostdlib" ,
85
+ '-Wl,-Map="%s"' % os .path .join ("${BUILD_DIR}" , "${PROGNAME}.map" )
81
86
],
82
87
83
88
LIBSOURCE_DIRS = [os .path .join (FRAMEWORK_DIR , "libraries" )],
@@ -86,12 +91,26 @@ def load_flags(filename):
86
91
)
87
92
88
93
env .Append (
94
+ ASFLAGS = [
95
+ "-Os" ,
96
+ "-fsigned-char" ,
97
+ "-ffunction-sections" ,
98
+ "-fdata-sections"
99
+ ],
100
+
101
+ CFLAGS = [
102
+ "-std=gnu11"
103
+ ],
104
+
89
105
# Due to long path names "-iprefix" hook is required to avoid toolchain crashes
90
106
CCFLAGS = [
91
- "-iprefix" + FRAMEWORK_DIR ,
92
- "@%s" % os .path .join (FRAMEWORK_DIR , "variants" , board .get (
93
- "build.variant" ), "includes.txt" ),
94
- "-w"
107
+ "-Os" ,
108
+ # Remove the 'to_unix_path' call when PIO Core v6.1.10 is released
109
+ "-iprefix" + fs .to_unix_path (FRAMEWORK_DIR ),
110
+ "@%s" % fs .to_unix_path (os .path .join (FRAMEWORK_DIR , "variants" , board .get (
111
+ "build.variant" ), "includes.txt" )),
112
+ "-w" ,
113
+ "-fno-builtin"
95
114
],
96
115
97
116
CPPDEFINES = [
@@ -102,6 +121,13 @@ def load_flags(filename):
102
121
("F_CPU" , "$BOARD_F_CPU" )
103
122
],
104
123
124
+ CXXFLAGS = [
125
+ "-std=gnu++17" ,
126
+ "-fno-rtti" ,
127
+ "-fno-exceptions" ,
128
+ "-fno-use-cxa-atexit"
129
+ ],
130
+
105
131
CPPPATH = [
106
132
os .path .join (FRAMEWORK_DIR , "cores" , board .get ("build.core" ), "tinyusb" ),
107
133
os .path .join (FRAMEWORK_DIR , "cores" , board .get ("build.core" )),
@@ -121,14 +147,6 @@ def load_flags(filename):
121
147
fpv_version = "5"
122
148
123
149
env .Append (
124
- ASFLAGS = [
125
- "-mfloat-abi=hard" ,
126
- "-mfpu=fpv%s-d16" % fpv_version
127
- ],
128
- CCFLAGS = [
129
- "-mfloat-abi=hard" ,
130
- "-mfpu=fpv%s-d16" % fpv_version
131
- ],
132
150
LINKFLAGS = [
133
151
"-mfloat-abi=hard" ,
134
152
"-mfpu=fpv%s-d16" % fpv_version
0 commit comments