summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2016-09-13 12:35:58 -0400
committerAnas Nashif <nashif@linux.intel.com>2016-09-15 21:17:02 +0000
commit806ac751d48e1bfcdf8aa97d2aec08bdffdec2e3 (patch)
treec416e044d17014d031b5c368fece5759c8fbb71d /scripts
parent2aa754497dc9d09b95445719811939334f0cf66b (diff)
sdk: zephyr: check for minimum required version of SDK
Error out when old SDK versions are being used. Jira: ZEP-584 Change-Id: If3515f38cc75d8a378614ef77d8946ba2d9ab28d Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.toolchain.zephyr10
-rwxr-xr-xscripts/vercomp43
2 files changed, 53 insertions, 0 deletions
diff --git a/scripts/Makefile.toolchain.zephyr b/scripts/Makefile.toolchain.zephyr
index e2594d131..a64367279 100644
--- a/scripts/Makefile.toolchain.zephyr
+++ b/scripts/Makefile.toolchain.zephyr
@@ -12,8 +12,18 @@
#
#######################################################################
+REQUIRED_SDK_VER=0.8.2
+
ifndef ZEPHYR_SDK_INSTALL_DIR
+
$(error ZEPHYR_SDK_INSTALL_DIR is not set)
+else
+SDK_VERSION = $(shell cat ${ZEPHYR_SDK_INSTALL_DIR}/sdk_version)
+SDK_CHECK = $(shell vercomp $(REQUIRED_SDK_VER) $(SDK_VERSION) || echo $$?)
+
+ifeq ($(SDK_CHECK),1)
+$(error (The SDK version you are using is old, please update your SDK. You need at least SDK version $(REQUIRED_SDK_VER)))
+endif
endif
ifeq ($(HOST_OS),MINGW)
diff --git a/scripts/vercomp b/scripts/vercomp
new file mode 100755
index 000000000..1ca1fb614
--- /dev/null
+++ b/scripts/vercomp
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+# `vercomp()` is copied from: http://stackoverflow.com/a/4025065
+
+# Usage: vercomp <version 1> <version 2>
+# return codes:
+# 0: version 1 and version 2 are the same
+# 1: version 1 is higher
+# 2: version 2 is higher
+
+
+vercomp () {
+ if [[ $1 == $2 ]]
+ then
+ return 0
+ fi
+ local IFS=.
+ local i ver1=($1) ver2=($2)
+ # fill empty fields in ver1 with zeros
+ for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
+ do
+ ver1[i]=0
+ done
+ for ((i=0; i<${#ver1[@]}; i++))
+ do
+ if [[ -z ${ver2[i]} ]]
+ then
+ # fill empty fields in ver2 with zeros
+ ver2[i]=0
+ fi
+ if ((10#${ver1[i]} > 10#${ver2[i]}))
+ then
+ return 1
+ fi
+ if ((10#${ver1[i]} < 10#${ver2[i]}))
+ then
+ return 2
+ fi
+ done
+ return 0
+}
+
+vercomp $1 $2