Skip to content

Commit 324c41f

Browse files
committed
CI: print elf segment size info for example sketches
1 parent 5cec334 commit 324c41f

File tree

2 files changed

+44
-7
lines changed

2 files changed

+44
-7
lines changed

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@ script:
2626
- ln -s $TRAVIS_BUILD_DIR esp8266
2727
- cd esp8266/tools
2828
- python get.py
29-
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
30-
- sleep 3
31-
- export DISPLAY=:1.0
3229
- export PATH="$HOME/arduino_ide:$PATH"
3330
- which arduino
3431
- cd $TRAVIS_BUILD_DIR
3532
- source tests/common.sh
3633
- install_libraries
37-
- build_sketches $HOME/arduino_ide $TRAVIS_BUILD_DIR "python tools/build.py -l $HOME/Arduino/libraries -b generic -v"
34+
- build_sketches $HOME/arduino_ide $TRAVIS_BUILD_DIR "-l $HOME/Arduino/libraries"
3835

3936
after_success:
4037
- pushd $TRAVIS_BUILD_DIR/tests/host

tests/common.sh

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,49 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
2+
3+
function print_size_info()
4+
{
5+
elf_file=$1
6+
7+
if [ -z "$elf_file" ]; then
8+
printf "sketch data rodata bss text irom0.text dram flash\n"
9+
return 0
10+
fi
11+
12+
elf_name=$(basename $elf_file)
13+
sketch_name="${elf_name%.*}"
14+
# echo $sketch_name
15+
declare -A segments
16+
while read -a tokens; do
17+
seg=${tokens[0]}
18+
seg=${seg//./}
19+
size=${tokens[1]}
20+
addr=${tokens[2]}
21+
if [ "$addr" -eq "$addr" -a "$addr" -ne "0" ] 2>/dev/null; then
22+
segments[$seg]=$size
23+
fi
24+
25+
26+
done < <(xtensa-lx106-elf-size --format=sysv $elf_file)
27+
28+
total_ram=$((${segments[data]} + ${segments[rodata]} + ${segments[bss]}))
29+
total_flash=$((${segments[data]} + ${segments[rodata]} + ${segments[text]} + ${segments[irom0text]}))
30+
31+
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
32+
return 0
33+
}
234

335
function build_sketches()
436
{
537
set +e
638
local arduino=$1
739
local srcpath=$2
8-
local build_cmd=$3
9-
echo $build_cmd
40+
local build_arg=$3
41+
local build_dir=build.tmp
42+
mkdir -p $build_dir
43+
rm -rf $build_dir/*
44+
local build_cmd="python tools/build.py -b generic -v -k -p $PWD/$build_dir $build_arg "
1045
local sketches=$(find $srcpath -name *.ino)
46+
print_size_info >size.log
1147
export ARDUINO_IDE_PATH=$arduino
1248
for sketch in $sketches; do
1349
local sketchdir=$(dirname $sketch)
@@ -33,8 +69,12 @@ function build_sketches()
3369
return $result
3470
fi
3571
rm build.log
72+
print_size_info $build_dir/*.elf >>size.log
3673
done
3774
set -e
75+
echo -e "\n ------------ Size report ------------ \n"
76+
cat size.log
77+
echo -e "\n ------------------------------------- \n"
3878
}
3979

4080
function install_libraries()

0 commit comments

Comments
 (0)