blob: 08f4fbf574fd62be432f8e9c6d96158dd347b10e [file] [log] [blame]
Vishal Bhoj9a67d912016-06-09 10:02:07 +01001#!/bin/bash
2
3RESULT_BUF=`echo -e ------------------------------------------------------------`
4RESULT_PASS_COUNT=0
5RESULT_FAIL_COUNT=0
6
7TOOLS_DIR="`dirname $0`"
8
9function result_log
10{
11 if [ $1 -eq 0 ]; then
12 RESULT_BUF="`printf \"%s\n%55s\tpass\" \"$RESULT_BUF\" \"$2\"`"
13 RESULT_PASS_COUNT=$(($RESULT_PASS_COUNT + 1))
14 else
15 RESULT_BUF="`printf \"%s\n%55s\tfail\" \"$RESULT_BUF\" \"$2\"`"
16 RESULT_FAIL_COUNT=$(($RESULT_FAIL_COUNT + 1))
17 fi
18}
19
20function result_print
21{
22 printf "%s" "$RESULT_BUF"
23 echo -e "\n------------------------------------------------------------"
24 printf "pass\t$RESULT_PASS_COUNT\n"
25 printf "fail\t$RESULT_FAIL_COUNT\n"
26
27 exit $RESULT_FAIL_COUNT
28}
29
30function get_build_arch
31{
32 case `uname -m` in
33 arm*)
34 BUILD_ARCH=ARM;;
35 aarch64*)
36 BUILD_ARCH=AARCH64;;
37 *)
38 BUILD_ARCH=other;;
39 esac
40}
41
42function set_cross_compile
43{
44 get_build_arch
45
46 echo "Target: $PLATFORM_ARCH"
47 echo "Build: $BUILD_ARCH"
48 if [ "$PLATFORM_ARCH" = "$BUILD_ARCH" ]; then
49 TEMP_CROSS_COMPILE=
50 elif [ "$PLATFORM_ARCH" == "AARCH64" ]; then
51 if [ X"$CROSS_COMPILE_64" != X"" ]; then
52 TEMP_CROSS_COMPILE="$CROSS_COMPILE_64"
53 else
54 TEMP_CROSS_COMPILE=aarch64-linux-gnu-
55 fi
56 elif [ "$PLATFORM_ARCH" == "ARM" ]; then
57 if [ X"$CROSS_COMPILE_32" != X"" ]; then
58 TEMP_CROSS_COMPILE="$CROSS_COMPILE_32"
59 else
60 TEMP_CROSS_COMPILE=arm-linux-gnueabihf-
61 fi
62 else
63 echo "Unsupported target architecture '$PLATFORM_ARCH'!" >&2
64 fi
65}
66
67function get_gcc_version
68{
69 gcc_version=$($1 -dumpversion)
70 case $gcc_version in
71 4.6*|4.7*|4.8*|4.9*)
72 echo GCC$(echo ${gcc_version} | awk -F. '{print $1$2}')
73 ;;
74 *)
75 echo "Unknown toolchain version '$gcc_version'" >&2
76 echo "Attempting to build using GCC49 profile." >&2
77 echo GCC49
78 ;;
79 esac
80}
81
82function get_clang_version
83{
84 clang_version=`$1 --version | head -1 | sed 's/^.*version\s*\([0-9]*\).\([0-9]*\).*/\1\2/g'`
85 echo "CLANG$clang_version"
86}