From 324c41fd7fa9eb88b3a8d5552f3d3f1d54a8cf1c Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Sun, 13 Mar 2016 01:44:33 +0300 Subject: [PATCH] CI: print elf segment size info for example sketches --- .travis.yml | 5 +---- tests/common.sh | 46 +++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index b15bc89e5..f95a50062 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,15 +26,12 @@ script: - ln -s $TRAVIS_BUILD_DIR esp8266 - cd esp8266/tools - python get.py - - /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16 - - sleep 3 - - export DISPLAY=:1.0 - export PATH="$HOME/arduino_ide:$PATH" - which arduino - cd $TRAVIS_BUILD_DIR - source tests/common.sh - install_libraries - - build_sketches $HOME/arduino_ide $TRAVIS_BUILD_DIR "python tools/build.py -l $HOME/Arduino/libraries -b generic -v" + - build_sketches $HOME/arduino_ide $TRAVIS_BUILD_DIR "-l $HOME/Arduino/libraries" after_success: - pushd $TRAVIS_BUILD_DIR/tests/host diff --git a/tests/common.sh b/tests/common.sh index 8f3f083b0..8c4f65d26 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -1,13 +1,49 @@ -#!/bin/bash +#!/usr/bin/env bash + +function print_size_info() +{ + elf_file=$1 + + if [ -z "$elf_file" ]; then + printf "sketch data rodata bss text irom0.text dram flash\n" + return 0 + fi + + elf_name=$(basename $elf_file) + sketch_name="${elf_name%.*}" + # echo $sketch_name + declare -A segments + while read -a tokens; do + seg=${tokens[0]} + seg=${seg//./} + size=${tokens[1]} + addr=${tokens[2]} + if [ "$addr" -eq "$addr" -a "$addr" -ne "0" ] 2>/dev/null; then + segments[$seg]=$size + fi + + + done < <(xtensa-lx106-elf-size --format=sysv $elf_file) + + total_ram=$((${segments[data]} + ${segments[rodata]} + ${segments[bss]})) + total_flash=$((${segments[data]} + ${segments[rodata]} + ${segments[text]} + ${segments[irom0text]})) + + printf "%-28s %-8d %-8d %-8d %-8d %-8d %-8d %-8d\n" $sketch_name ${segments[data]} ${segments[rodata]} ${segments[bss]} ${segments[text]} ${segments[irom0text]} $total_ram $total_flash + return 0 +} function build_sketches() { set +e local arduino=$1 local srcpath=$2 - local build_cmd=$3 - echo $build_cmd + local build_arg=$3 + local build_dir=build.tmp + mkdir -p $build_dir + rm -rf $build_dir/* + local build_cmd="python tools/build.py -b generic -v -k -p $PWD/$build_dir $build_arg " local sketches=$(find $srcpath -name *.ino) + print_size_info >size.log export ARDUINO_IDE_PATH=$arduino for sketch in $sketches; do local sketchdir=$(dirname $sketch) @@ -33,8 +69,12 @@ function build_sketches() return $result fi rm build.log + print_size_info $build_dir/*.elf >>size.log done set -e + echo -e "\n ------------ Size report ------------ \n" + cat size.log + echo -e "\n ------------------------------------- \n" } function install_libraries()