Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new target option to print/show the build size. #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions utils/cmake/buildtools/codal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ if(${device.generate_hex})
include(${TOOLCHAIN_FOLDER}/hex-generator.cmake)
endif()

# import toolchain show build size command
if(${device.show_size})
include(${TOOLCHAIN_FOLDER}/size-info.cmake)
endif()

# post process command hook, depends on the hex file generated by the build system.
if("${device.post_process.command}" STRGREATER "" OR "${device.post_process}" STRGREATER "")

Expand Down
4 changes: 4 additions & 0 deletions utils/cmake/toolchains/ARM_GCC/compiler-flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ set(CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> -cr <LINK_FLAGS> <TARGET> <OBJEC

set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> -Wl,-Map,<TARGET>.map -Wl,--start-group <OBJECTS> <LINK_LIBRARIES> -lnosys -lstdc++ -lsupc++ -lm -lc -lgcc -lstdc++ -lsupc++ -lm -lc -lgcc -Wl,--end-group --specs=nano.specs -o <TARGET>")

if(${device.show_size})
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -Wl,--print-memory-usage")
endif()

set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g -gdwarf-3")
set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE_INIT "-Os -DNDEBUG")
Expand Down
6 changes: 6 additions & 0 deletions utils/cmake/toolchains/ARM_GCC/size-info.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
add_custom_command(
TARGET ${device.device}
COMMAND "${ARM_NONE_EABI_SIZE}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${device.device}"
DEPENDS ${device.device}
COMMENT "Print total size info:"
)
3 changes: 2 additions & 1 deletion utils/cmake/toolchains/ARM_GCC/toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ find_program(ARM_NONE_EABI_AR arm-none-eabi-ar)
find_program(ARM_NONE_EABI_GCC arm-none-eabi-gcc)
find_program(ARM_NONE_EABI_GPP arm-none-eabi-g++)
find_program(ARM_NONE_EABI_OBJCOPY arm-none-eabi-objcopy)
find_program(ARM_NONE_EABI_SIZE arm-none-eabi-size)

set(CMAKE_OSX_SYSROOT "/")
set(CMAKE_OSX_DEPLOYMENT_TARGET "")
Expand All @@ -19,7 +20,7 @@ if(CMAKE_VERSION VERSION_LESS "3.5.0")
else()
# from 3.5 the force_compiler macro is deprecated: CMake can detect
# arm-none-eabi-gcc as being a GNU compiler automatically
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(CMAKE_C_COMPILER "${ARM_NONE_EABI_GCC}")
set(CMAKE_CXX_COMPILER "${ARM_NONE_EABI_GPP}")
endif()
Expand Down
1 change: 1 addition & 0 deletions utils/cmake/toolchains/AVR_GCC/size-info.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
message(WARNING "The 'show size' CODAL target option hasn't been implemented for AVR_GCC.")
1 change: 1 addition & 0 deletions utils/cmake/toolchains/XTENSA_GCC/size-info.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
message(WARNING "The 'show size' CODAL target option hasn't been implemented for XTENSA_GCC.")