Skip to content

Commit

Permalink
ci,build: add check to ensure that ADI defconfigs are up-to-date
Browse files Browse the repository at this point in the history
We want to check/make-sure that savedefconfig has been run. This a
minimal/trivial check.

But more importantly, we want to make sure that all defconfigs are correct
for each Vivado version we want to support.

Signed-off-by: Alexandru Ardelean <[email protected]>
  • Loading branch information
commodo committed Mar 20, 2020
1 parent cfc2536 commit 0487c39
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: c

branches:
except:
- adi-2019.02.2 # current rebased versions of master; change this when updating kernel ver

os: linux

notifications:
email:
on_success: change
on_failure: always

matrix:
include:
- env: BUILD_TYPE=ensure_defconfigs_uptodate
VIVADO_DEFCONFIGS="microblaze_adi microblaze_adi_rootfs
zynq_m2k zynq_pluto zynq_sidekiqz2"
VIVADO_VERSIONS="2018_3 2019_1"

script:
- ./ci/run-build.sh
1 change: 1 addition & 0 deletions ci/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cache/*
43 changes: 43 additions & 0 deletions ci/lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/sh -e

TRAVIS_BUILD_DIR=${TRAVIS_BUILD_DIR:-'./'}

command_exists() {
local cmd=$1
[ -n "$cmd" ] || return 1
type "$cmd" >/dev/null 2>&1
}

ensure_command_exists() {
local cmd="$1"
local package="$2"
[ -n "$cmd" ] || return 1
[ -n "$package" ] || package="$cmd"
! command_exists "$cmd" || return 0
# go through known package managers
for pacman in apt-get brew yum ; do
command_exists $pacman || continue
$pacman install -y $package || {
# Try an update if install doesn't work the first time
$pacman -y update && \
$pacman install -y $package
}
return $?
done
return 1
}

ensure_command_exists wget
ensure_command_exists sudo

LOCAL_BUILD_DIR="ci/cache"
FULL_BUILD_DIR="${TRAVIS_BUILD_DIR}/${LOCAL_BUILD_DIR}"

# Get the common stuff from libiio
[ -f "${FULL_BUILD_DIR}/lib.sh" ] || {
mkdir -p "${FULL_BUILD_DIR}"
wget https://raw.githubusercontent.com/analogdevicesinc/libiio/master/CI/travis/lib.sh \
-O "${FULL_BUILD_DIR}/lib.sh"
}

. "${FULL_BUILD_DIR}/lib.sh"
117 changes: 117 additions & 0 deletions ci/run-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/bin/bash
set -e

. ./ci/lib.sh

tolower() {
echo "$1" | tr A-Z a-z
}

_check_defconfig() {
local defconfig="$1"

if [ ! -f "configs/$defconfig" ] ; then
echo_red "File does not exist 'configs/${defconfig}'"
return 1
fi

make ${defconfig}
make savedefconfig

git diff --exit-code || {
echo_red "Defconfig file should be updated: 'configs/${defconfig}"
echo_red "Run 'make savedefconfig', overwrite it and commit it"
git checkout .
return 1
}

return 0
}

_check_gcc_and_kernel_defconfig() {
local defconfig="$1"
local ker_ver="$2"
local gcc_ver="$3"
local atleast_one_failure=0

if ! grep -q "BR2_TOOLCHAIN_EXTERNAL_GCC_${gcc_ver}=y" "configs/$defconfig" ; then
echo_red "Did not find symbol 'BR2_TOOLCHAIN_EXTERNAL_GCC_${gcc_ver}=y' in configs/$defconfig"
atleast_one_failure=1
fi

if ! grep -q "BR2_TOOLCHAIN_EXTERNAL_HEADERS_${ker_ver}=y" "configs/$defconfig" ; then
echo_red "Did not find symbol 'BR2_TOOLCHAIN_EXTERNAL_HEADERS_${ker_ver}=y' in configs/$defconfig"
atleast_one_failure=1
fi

return $atleast_one_failure
}

_check_defconfig_vivado() {
local defconfig="$1"
local vivado_ver="$2"
local atleast_one_failure=0

local ker_ver gcc_ver

if [ "$vivado_ver" = "2019_1" ] ; then
gcc_ver=8
ker_ver=4_19
elif [ "$vivado_ver" = "2018_3" ] ; then
gcc_ver=7
ker_ver=4_14
else
echo_red "Unsupported version '$vivado_ver'"
return 1
fi

_check_gcc_and_kernel_defconfig "$defconfig" "$ker_ver" "$gcc_ver" || atleast_one_failure=1

_check_defconfig "$defconfig" || atleast_one_failure=1

return $atleast_one_failure
}

_ensure_defconfigs_uptodate() {
local toolprefix="$1"
local atleast_one_failure=0
local deconfigs versions defconfig

eval defconfigs=\$${toolprefix}_DEFCONFIGS

[ -n "$defconfigs" ] || {
echo_red "No ${toolprefix}_DEFCONFIGS list provided"
return 1
}

eval versions=\$${toolprefix}_VERSIONS

[ -n "$versions" ] || {
echo_red "No ${toolprefix}_VERSIONS list provided"
return 1
}

local toolprefix_lower=$(tolower $toolprefix)
for config in $defconfigs ; do
for version in $versions ; do
defconfig=${config}_${toolprefix_lower}_${version}_defconfig
if _check_defconfig_${toolprefix_lower} "$defconfig" "$version" ; then
echo_green "'configs/${defconfig} looks good"
echo
else
atleast_one_failure=1
fi
done
done

return $atleast_one_failure
}

build_ensure_defconfigs_uptodate() {
_ensure_defconfigs_uptodate VIVADO
}

BUILD_TYPE=${BUILD_TYPE:-${1}}
BUILD_TYPE=${BUILD_TYPE:-default}

build_${BUILD_TYPE}

0 comments on commit 0487c39

Please sign in to comment.