Skip to content

Commit

Permalink
Exit explicitly if there is a memory overflow report from teensy_size
Browse files Browse the repository at this point in the history
Resolves #106
  • Loading branch information
valeros committed Sep 5, 2023
1 parent ed67298 commit b003257
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

import sys
from platform import system
from os import makedirs
from os import makedirs, environ
from os.path import isdir, isfile, join

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

from platformio.proc import exec_command

env = DefaultEnvironment()
platform = env.PioPlatform()
board_config = env.BoardConfig()
Expand Down Expand Up @@ -137,12 +139,23 @@

# Disable memory calculation and print output from custom "teensy_size" tool
if "arduino" in env.subst("$PIOFRAMEWORK") and build_core == "teensy4":
def teensy_check_upload_size(_, target, source, env):
print('Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"')
sysenv = environ.copy()
sysenv["PATH"] = str(env["ENV"]["PATH"])
result = exec_command(["teensy_size", str(source[0])], env=sysenv)
if result["returncode"] != 0:
sys.stderr.write(result["err"])
env.Exit(1)

env.AddMethod(teensy_check_upload_size, "CheckUploadSize")
env.Replace(
SIZETOOL=None,
SIZECHECKCMD=None,
SIZEPRINTCMD="teensy_size $SOURCES",
)


#
# Target: Build executable and linkable firmware
#
Expand Down

0 comments on commit b003257

Please sign in to comment.