Skip to content

Commit b003257

Browse files
committed
Exit explicitly if there is a memory overflow report from teensy_size
Resolves #106
1 parent ed67298 commit b003257

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

builder/main.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414

1515
import sys
1616
from platform import system
17-
from os import makedirs
17+
from os import makedirs, environ
1818
from os.path import isdir, isfile, join
1919

2020
from SCons.Script import (COMMAND_LINE_TARGETS, AlwaysBuild, Builder, Default,
2121
DefaultEnvironment)
2222

23+
from platformio.proc import exec_command
24+
2325
env = DefaultEnvironment()
2426
platform = env.PioPlatform()
2527
board_config = env.BoardConfig()
@@ -137,12 +139,23 @@
137139

138140
# Disable memory calculation and print output from custom "teensy_size" tool
139141
if "arduino" in env.subst("$PIOFRAMEWORK") and build_core == "teensy4":
142+
def teensy_check_upload_size(_, target, source, env):
143+
print('Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"')
144+
sysenv = environ.copy()
145+
sysenv["PATH"] = str(env["ENV"]["PATH"])
146+
result = exec_command(["teensy_size", str(source[0])], env=sysenv)
147+
if result["returncode"] != 0:
148+
sys.stderr.write(result["err"])
149+
env.Exit(1)
150+
151+
env.AddMethod(teensy_check_upload_size, "CheckUploadSize")
140152
env.Replace(
141153
SIZETOOL=None,
142154
SIZECHECKCMD=None,
143155
SIZEPRINTCMD="teensy_size $SOURCES",
144156
)
145157

158+
146159
#
147160
# Target: Build executable and linkable firmware
148161
#

0 commit comments

Comments
 (0)