1
0
mirror of https://github.com/Optiboot/optiboot.git synced 2025-07-29 20:21:11 +03:00

Travis-CI: targets update, compilation matrix with sizes, documentation

This commit is contained in:
majekw
2018-08-17 02:22:32 +02:00
parent 862e9dd5e8
commit 66fdd11ebb
7 changed files with 401 additions and 87 deletions

View File

@ -1,14 +1,11 @@
#!/usr/bin/env bash
LOCAL_TOOLS_DIR=$HOME/avr-tools
MAKE_PACKAGE=make_4.1-6_amd64.deb
WGET_FLAGS="--retry-connrefused --tries=3 --timeout=60 --continue"
if [ -z "$TRAVIS_BUILD_DIR" ]; then
echo "This script should be run by Travis-CI environment"
echo "If you want to simulate Travis build, please set TRAVIS_BUILD_DIR"
echo "envirinment variable to directory where your code lives"
echo "environment variable to directory where your code lives"
exit 1
fi
@ -23,91 +20,32 @@ if [ -z "$2" ]; then
fi
# oownload and unpack package
function download_and_unpack()
{
cd $LOCAL_TOOLS_DIR
# Include functions to download stuff
. $TRAVIS_BUILD_DIR/scripts/travis-download.inc.sh
# check if tools are already in place
if [ -d arduino-$1/hardware/tools/avr ]; then
echo "Arduino version $1 already downloaded and extracted, skipping"
return
fi
echo "Downloading Arduino version $1"
# default package extension
local arduExt="tar.xz"
# for packages in version <1.6 extension is .tgz
local regex="1\.[05]"
if [[ "$1" =~ $regex ]]; then arduExt="tgz"; fi
# download package
wget $WGET_FLAGS "http://downloads.arduino.cc/arduino-$1-linux64.$arduExt"
if [ $? -ne 0 ]; then
echo "ERROR: Can't download Arduino"
rm arduino-$1-linux64.$arduExt*
exit 1
fi
# try to check md5sum, but Arduino provide only checksums for version 1.6 and greater
wget $WGET_FLAGS https://downloads.arduino.cc/arduino-$1.md5sum.txt
if [ $? -eq -0 ]; then
cat arduino-$1.md5sum.txt|grep "linux64"|md5sum -c
if [ $? -ne 0 ]; then
echo "ERROR: md5sum for downloaded Arduino doesn't match"
rm arduino-$1.md5sum.txt*
exit 1
fi
rm arduino-$1.md5sum.txt*
fi
# extract only avr-gcc
tar xf arduino-$1-linux64.$arduExt --wildcards '*/hardware/tools/avr/'
# clean up
rm arduino-$1-linux64.$arduExt*
}
function get_make4()
{
cd $LOCAL_TOOLS_DIR
# check for existence
if [ -x usr/bin/make ]; then
echo "Make already in place, skipping"
return
fi
# download
wget http://archive.ubuntu.com/ubuntu/pool/main/m/make-dfsg/$MAKE_PACKAGE
if [ $? -ne 0 ]; then
echo "ERROR: Can't download make4"
exit 1
fi
# unpack
dpkg-deb -x $MAKE_PACKAGE $LOCAL_TOOLS_DIR
# clean up
rm ${MAKE_PACKAGE}*
}
# make directory for tools
# Make directory for tools
mkdir -p $LOCAL_TOOLS_DIR
# get new make as Optiboot requires version >4.0
get_make4
download_make4
# download specific Arduino version
download_and_unpack $1
# download specific tools version
if [ "$1" = "microchip" ]; then
download_avr_toolchain
# set search path
PATH=$LOCAL_TOOLS_DIR/usr/bin:$PATH:$LOCAL_TOOLS_DIR/arduino-$1/hardware/tools/avr/bin
# set search path
PATH=$LOCAL_TOOLS_DIR/usr/bin:$PATH:$LOCAL_TOOLS_DIR/avr8-gnu-toolchain-linux_x86_64/bin
avr-gcc --version
else
download_arduino $1
# set search path
PATH=$LOCAL_TOOLS_DIR/usr/bin:$PATH:$LOCAL_TOOLS_DIR/arduino-$1/hardware/tools/avr/bin
fi
cd $TRAVIS_BUILD_DIR/optiboot/bootloaders/optiboot
make --version
make clean
make $2
shift
make $@

84
scripts/travis-check-sizes.sh Executable file
View File

@ -0,0 +1,84 @@
#!/usr/bin/env bash
LOCAL_TOOLS_DIR=$HOME/avr-tools
if [ -z "$TRAVIS_BUILD_DIR" ]; then
echo "This script should be run by Travis-CI environment"
echo "If you want to simulate Travis build, please set TRAVIS_BUILD_DIR"
echo "environment variable to directory where your code lives"
exit 1
fi
# download all compilers
$TRAVIS_BUILD_DIR/scripts/travis-fill-cache.sh
# prepare output dir
OUTPUT_DIR="$TRAVIS_BUILD_DIR/sizes-out"
mkdir -p "$OUTPUT_DIR"
OUTPUT_TABLE="$OUTPUT_DIR/sizes.txt"
OUTPUT_JSON="$OUTPUT_DIR/sizes.json"
# compiler list
COMPILERS=$(cat $TRAVIS_BUILD_DIR/docs/arduino-gcc-versions.md |grep -i "| yes |"|cut -f 2 -d '|')
COMPILERS="$COMPILERS microchip"
# table header
echo -n "| target \ compiler |" >"$OUTPUT_TABLE"
for compiler in $COMPILERS; do
echo -n " $compiler |" >>"$OUTPUT_TABLE"
done
echo >>"$OUTPUT_TABLE"
# table header separator
echo -n "|-|" >>"$OUTPUT_TABLE"
for compiler in $COMPILERS; do
echo -n "-|">>"$OUTPUT_TABLE"
done
echo >>"$OUTPUT_TABLE"
# get repo and commit info for json output
if [[ "$TRAVIS_PULL_REQUEST" = "false" ]]; then
REPO="$TRAVIS_REPO_SLUG"
BRANCH="$TRAVIS_BRANCH"
else
REPO="$TRAVIS_PULL_REQUEST_SLUG"
BRANCH="$TRAVIS_PULL_REQUEST_BRANCH"
fi
# start json
echo "{\"slug\":\"$REPO\",\"branch\":\"$BRANCH\",\"commit\":\"$TRAVIS_COMMIT\",\"emoji\":\"false\",\"builds\":[" >"$OUTPUT_JSON"
# build everything
cat $TRAVIS_BUILD_DIR/.travis.yml|grep " - OPTIBOOT_TARGET="|cut -f 2- -d '=' \
|tr -d '"'|sort|while read target; do
echo -n "| $target |" >>"$OUTPUT_TABLE"
echo "{\"t\":\"$target\",\"v\":[">>"$OUTPUT_JSON"
for compiler in $COMPILERS; do
echo "Checking size for $target @ $compiler"
size=$($TRAVIS_BUILD_DIR/scripts/travis-build.sh $compiler $target 2>/dev/null|grep -A 2 avr-size|tail -n1|awk '{ print $1;}')
if [[ -z "$size" ]]; then
size="x"
fi
echo -n " $size |" >>"$OUTPUT_TABLE"
echo "{\"c\":\"$compiler\",\"s\":\"$size\"}," >>"$OUTPUT_JSON"
done
echo >>"$OUTPUT_TABLE"
sed -i '$ s/.$//' "$OUTPUT_JSON"
echo "]}," >>"$OUTPUT_JSON"
done
sed -i '$ s/.$//' "$OUTPUT_JSON"
echo "]}">>"$OUTPUT_JSON"
echo "========= OUTPUT SIZES START ============="
cat "$OUTPUT_TABLE"
echo "========== OUTPUT SIZES END =============="
echo "Checking results against last commit"
echo "========= OUTPUT SIZES COMPARE START ============="
curl -H "Content-Type: application/json" --data @$OUTPUT_JSON https://api.travisjoin.w7i.pl/tj/compare/$REPO/$BRANCH/last
echo "========== OUTPUT SIZES COMPARE END =============="
echo "Uploading results to TravisJoin"
curl -H "Content-Type: application/json" --data @$OUTPUT_JSON https://api.travisjoin.w7i.pl/tj/add/$REPO/$BRANCH/$TRAVIS_COMMIT
exit 0

View File

@ -0,0 +1,104 @@
# common functions to get avr-gcc tools
#
MAKE_PACKAGE=make_4.1-6_amd64.deb
WGET_FLAGS="--retry-connrefused --tries=3 --timeout=60 --continue"
# download and unpack package
function download_arduino()
{
cd $LOCAL_TOOLS_DIR
# check if tools are already in place
if [ -d arduino-$1/hardware/tools/avr ]; then
echo "Arduino version $1 already downloaded and extracted, skipping"
return
fi
echo "Downloading Arduino version $1"
# default package extension
local arduExt="tar.xz"
# for packages in version <1.6 extension is .tgz
local regex="1\.[05]"
if [[ "$1" =~ $regex ]]; then arduExt="tgz"; fi
# download package
wget $WGET_FLAGS "http://downloads.arduino.cc/arduino-$1-linux64.$arduExt"
if [ $? -ne 0 ]; then
echo "ERROR: Can't download Arduino"
rm arduino-$1-linux64.$arduExt*
exit 1
fi
# try to check md5sum, but Arduino provide only checksums for version 1.6 and greater
wget $WGET_FLAGS https://downloads.arduino.cc/arduino-$1.md5sum.txt
if [ $? -eq -0 ]; then
cat arduino-$1.md5sum.txt|grep "linux64"|md5sum -c
if [ $? -ne 0 ]; then
echo "ERROR: md5sum for downloaded Arduino doesn't match"
rm arduino-$1.md5sum.txt*
exit 1
fi
rm arduino-$1.md5sum.txt*
fi
# extract only avr-gcc
tar xf arduino-$1-linux64.$arduExt --wildcards '*/hardware/tools/avr/'
# clean up
rm arduino-$1-linux64.$arduExt*
}
function download_make4()
{
cd $LOCAL_TOOLS_DIR
# check for existence
if [ -x usr/bin/make ]; then
echo "Make already in place, skipping"
return
fi
# download
wget http://archive.ubuntu.com/ubuntu/pool/main/m/make-dfsg/$MAKE_PACKAGE
if [ $? -ne 0 ]; then
echo "ERROR: Can't download make4"
exit 1
fi
# unpack
dpkg-deb -x $MAKE_PACKAGE $LOCAL_TOOLS_DIR
# clean up
rm ${MAKE_PACKAGE}*
}
function download_avr_toolchain()
{
cd $LOCAL_TOOLS_DIR
# check if tools are already in place
if [ -d avr8-gnu-toolchain-linux_x86_64 ]; then
echo "AVR 8-bit Toolchain already downloaded and extracted, skipping"
return
fi
echo "Downloading AVR 8-bit Toolchain"
# download package
wget $WGET_FLAGS --content-disposition "https://www.microchip.com/mymicrochip/filehandler.aspx?ddocname=en605750"
if [ $? -ne 0 ]; then
echo "ERROR: Can't download AVR 8-bit Toolchain"
rm avr8-gnu-toolchain-*-linux.any.x86_64.tar.gz*
exit 1
fi
# unpack
tar xf avr8-gnu-toolchain-*-linux.any.x86_64.tar.gz
# clean up
rm avr8-gnu-toolchain-*-linux.any.x86_64.tar.gz*
}

26
scripts/travis-env.inc.sh Normal file
View File

@ -0,0 +1,26 @@
# source it from parent directory to mimic Travis-CI
# environmental variables needed in scripts
if [[ -d .git ]]; then
export TRAVIS_BUILD_DIR=`pwd`
else
echo "ERROR: include it from repository parent directory!!!"
return
fi
export TRAVIS_COMMIT="THIS_IS_FAKE_COMMIT_HASH_FOR_TESTS_ONLY1"
export TRAVIS_COMMIT_MESSAGE="Example commit message"
export TRAVIS_EVENT_TYPE="push"
export TRAVIS_OS_NAME="linux"
export TRAVIS_PULL_REQUEST="false"
export TRAVIS_PULL_REQUEST_BRANCH=""
export TRAVIS_PULL_REQUEST_SHA=""
export TRAVIS_PULL_REQUEST_SLUG=""
export TRAVIS_REPO_SLUG=$(git config --get travis.slug)
if [[ -z "$TRAVIS_REPO_SLUG" ]]; then
export TRAVIS_REPO_SLUG=$(git config --get remote.origin.url|sed 's/.*github\.com.//'|sed 's/\.git$//')
fi
export TRAVIS_SUDO="false"
export TRAVIS_BRANCH=$(git rev-parse --abbrev-ref HEAD)

34
scripts/travis-fill-cache.sh Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env bash
#
# Download avr-gcc from Arduino and Microchip
# Get also make 4 required to compile Optiboot
#
# path where tools are extracted
LOCAL_TOOLS_DIR=$HOME/avr-tools
# check if we are running by Travis-CI
if [ -z "$TRAVIS_BUILD_DIR" ]; then
echo "This script should be run by Travis-CI environment"
echo "If you want to simulate Travis build, please set TRAVIS_BUILD_DIR"
echo "environment variable to directory where your code lives"
exit 1
fi
# include functions to download stuff
. $TRAVIS_BUILD_DIR/scripts/travis-download.inc.sh
# make directory for tools
mkdir -p $LOCAL_TOOLS_DIR
# get new make as Optiboot requires version >4.0
download_make4
# download Arduino versions
for version in $(cat $TRAVIS_BUILD_DIR/docs/arduino-gcc-versions.md |grep -i "| yes |"|cut -f 2 -d '|'); do
download_arduino $version
done
# download Microchip's AVR8 Toolchain
download_avr_toolchain