From d7405c44ca33997296350411b2c2a1c7f8c5627e Mon Sep 17 00:00:00 2001 From: Valeriy Koval Date: Mon, 9 Feb 2015 19:57:39 +0200 Subject: [PATCH] Output compiled size and static memory usage --- platformio/builder/scripts/atmelavr.py | 12 +++++++++++- platformio/builder/scripts/atmelsam.py | 12 +++++++++++- platformio/builder/scripts/stm32.py | 12 +++++++++++- platformio/builder/scripts/teensy.py | 19 ++++++++++++++++--- platformio/builder/scripts/timsp430.py | 12 +++++++++++- platformio/builder/scripts/titiva.py | 12 +++++++++++- 6 files changed, 71 insertions(+), 8 deletions(-) diff --git a/platformio/builder/scripts/atmelavr.py b/platformio/builder/scripts/atmelavr.py index 0c740e83..ed090862 100644 --- a/platformio/builder/scripts/atmelavr.py +++ b/platformio/builder/scripts/atmelavr.py @@ -22,6 +22,7 @@ env.Replace( CXX="avr-g++", OBJCOPY="avr-objcopy", RANLIB="avr-ranlib", + SIZETOOL="avr-size", ARFLAGS=["rcs"], @@ -58,6 +59,8 @@ env.Replace( "-Wl,--start-group" ], + SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES', + UPLOADER=join("$PIOPACKAGES_DIR", "tool-avrdude", "avrdude"), UPLOADERFLAGS=[ "-q", # suppress progress output @@ -159,6 +162,13 @@ if "uploadlazy" in COMMAND_LINE_TARGETS: else: target_hex = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf) +# +# Target: Print binary size +# + +target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") +AlwaysBuild(target_size) + # # Target: Upload by default .hex file # @@ -199,4 +209,4 @@ if is_uptarget: # Setup default targets # -Default(target_hex) +Default([target_hex, target_size]) diff --git a/platformio/builder/scripts/atmelsam.py b/platformio/builder/scripts/atmelsam.py index a8c98183..efe5e304 100644 --- a/platformio/builder/scripts/atmelsam.py +++ b/platformio/builder/scripts/atmelsam.py @@ -21,6 +21,7 @@ env.Replace( CXX="arm-none-eabi-g++", OBJCOPY="arm-none-eabi-objcopy", RANLIB="arm-none-eabi-ranlib", + SIZETOOL="arm-none-eabi-size", ARFLAGS=["rcs"], @@ -60,6 +61,8 @@ env.Replace( "-mthumb" ], + SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', + UPLOADER=join("$PIOPACKAGES_DIR", "$PIOPACKAGE_UPLOADER", "bossac"), UPLOADERFLAGS=[ "--info", @@ -104,6 +107,13 @@ if "uploadlazy" in COMMAND_LINE_TARGETS: else: target_bin = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) +# +# Target: Print binary size +# + +target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") +AlwaysBuild(target_size) + # # Target: Upload by default .bin file # @@ -134,4 +144,4 @@ if is_uptarget: # Setup default targets # -Default(target_bin) +Default([target_bin, target_size]) diff --git a/platformio/builder/scripts/stm32.py b/platformio/builder/scripts/stm32.py index 3793e7de..d5ed4d47 100644 --- a/platformio/builder/scripts/stm32.py +++ b/platformio/builder/scripts/stm32.py @@ -20,6 +20,7 @@ env.Replace( CXX="arm-none-eabi-g++", OBJCOPY="arm-none-eabi-objcopy", RANLIB="arm-none-eabi-ranlib", + SIZETOOL="arm-none-eabi-size", ARFLAGS=["rcs"], @@ -62,6 +63,8 @@ env.Replace( "-mcpu=${BOARD_OPTIONS['build']['mcu']}" ], + SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', + UPLOADER=join("$PIOPACKAGES_DIR", "tool-stlink", "st-flash"), UPLOADERFLAGS=[ "write", # write in flash @@ -122,6 +125,13 @@ if "uploadlazy" in COMMAND_LINE_TARGETS: else: target_bin = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) +# +# Target: Print binary size +# + +target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") +AlwaysBuild(target_size) + # # Target: Upload by default .bin file # @@ -133,4 +143,4 @@ AlwaysBuild(upload) # Target: Define targets # -Default(target_bin) +Default([target_bin, target_size]) diff --git a/platformio/builder/scripts/teensy.py b/platformio/builder/scripts/teensy.py index 11d391e5..1f23cf4b 100644 --- a/platformio/builder/scripts/teensy.py +++ b/platformio/builder/scripts/teensy.py @@ -22,6 +22,7 @@ if env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy": CXX="avr-g++", OBJCOPY="avr-objcopy", RANLIB="avr-ranlib", + SIZETOOL="avr-size", ARFLAGS=["rcs"], @@ -39,7 +40,9 @@ if env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy": LINKFLAGS=[ "-mmcu=$BOARD_MCU" - ] + ], + + SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES' ) elif env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy3": @@ -50,6 +53,7 @@ elif env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy3": CXX="arm-none-eabi-g++", OBJCOPY="arm-none-eabi-objcopy", RANLIB="arm-none-eabi-ranlib", + SIZETOOL="arm-none-eabi-size", ARFLAGS=["rcs"], @@ -82,7 +86,9 @@ elif env.get("BOARD_OPTIONS", {}).get("build", {}).get("core") == "teensy3": "-Wl,--gc-sections", # "-nostartfiles", # "-nostdlib", - ] + ], + + SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES' ) env.Append( @@ -175,6 +181,13 @@ if "uploadlazy" in COMMAND_LINE_TARGETS: else: target_hex = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf) +# +# Target: Print binary size +# + +target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") +AlwaysBuild(target_size) + # # Target: Upload by default .hex file # @@ -186,4 +199,4 @@ AlwaysBuild(upload) # Target: Define targets # -Default(target_hex) +Default([target_hex, target_size]) diff --git a/platformio/builder/scripts/timsp430.py b/platformio/builder/scripts/timsp430.py index 8899d474..b897d681 100644 --- a/platformio/builder/scripts/timsp430.py +++ b/platformio/builder/scripts/timsp430.py @@ -21,6 +21,7 @@ env.Replace( CXX="msp430-g++", OBJCOPY="msp430-objcopy", RANLIB="msp430-ranlib", + SIZETOOL="msp430-size", ARFLAGS=["rcs"], @@ -52,6 +53,8 @@ env.Replace( "-Wl,-gc-sections,-u,main" ], + SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', + UPLOADER=join("$PIOPACKAGES_DIR", "tool-mspdebug", "mspdebug"), UPLOADERFLAGS=[ "$UPLOAD_PROTOCOL" if system() != "Windows" else "tilib", @@ -93,6 +96,13 @@ if "uploadlazy" in COMMAND_LINE_TARGETS: else: target_hex = env.ElfToHex(join("$BUILD_DIR", "firmware"), target_elf) +# +# Target: Print binary size +# + +target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") +AlwaysBuild(target_size) + # # Target: Upload firmware # @@ -104,4 +114,4 @@ AlwaysBuild(upload) # Target: Define targets # -Default(target_hex) +Default([target_hex, target_size]) diff --git a/platformio/builder/scripts/titiva.py b/platformio/builder/scripts/titiva.py index 613e6aef..ffc81328 100644 --- a/platformio/builder/scripts/titiva.py +++ b/platformio/builder/scripts/titiva.py @@ -20,6 +20,7 @@ env.Replace( CXX="arm-none-eabi-g++", OBJCOPY="arm-none-eabi-objcopy", RANLIB="arm-none-eabi-ranlib", + SIZETOOL="arm-none-eabi-size", ARFLAGS=["rcs"], @@ -71,6 +72,8 @@ env.Replace( "-fsingle-precision-constant" ], + SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES', + UPLOADER=join("$PIOPACKAGES_DIR", "tool-lm4flash", "lm4flash"), UPLOADCMD="$UPLOADER $SOURCES" ) @@ -106,6 +109,13 @@ if "uploadlazy" in COMMAND_LINE_TARGETS: else: target_bin = env.ElfToBin(join("$BUILD_DIR", "firmware"), target_elf) +# +# Target: Print binary size +# + +target_size = env.Alias("size", target_elf, "$SIZEPRINTCMD") +AlwaysBuild(target_size) + # # Target: Upload firmware # @@ -117,4 +127,4 @@ AlwaysBuild(upload) # Target: Define targets # -Default(target_bin) +Default([target_bin, target_size])