Skip to content

Commit

Permalink
Fail explicitly if the program space exceeded (#21)
Browse files Browse the repository at this point in the history
If a program that exeeded the maximum size is uploaded, it will be
difficult to diagnose and this change prevents such a scenario.
This change fixes the issue #20.
  • Loading branch information
a9183756-gh authored May 1, 2020
1 parent 8d6fb6c commit c8244dc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Arduino/Templates/Scripts/SizeScript.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ set (size_match_idx_list "@SIZE_MATCH_IDX_LIST@")

# For each of the elements whose size is to be printed
math(EXPR _last_index "@SIZE_REGEX_COUNT@ - 1")
set(is_size_exeeded FALSE)
foreach(idx RANGE "${_last_index}")

list(GET size_regex_list ${idx} size_regex)
Expand All @@ -59,6 +60,9 @@ foreach(idx RANGE "${_last_index}")

# Print total size of the element
if (maximum_size GREATER 0)
if (tot_size GREATER maximum_size)
set(is_size_exeeded TRUE)
endif()
math(EXPR tot_size_percent "${tot_size} * 100 / ${maximum_size}")
message("${size_name} Size: ${tot_size} of ${maximum_size} bytes "
"(${tot_size_percent}%)")
Expand All @@ -69,3 +73,8 @@ foreach(idx RANGE "${_last_index}")
endforeach()

message("##################################################")

if (is_size_exeeded)
message(FATAL_ERROR "Program exceeded the maximum size!!!")
endif()

0 comments on commit c8244dc

Please sign in to comment.