summaryrefslogtreecommitdiff
path: root/common-functions
blob: b9ac41753890442a18cae48862c2d27fcea3cf4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash

RESULT_BUF=`echo -e ------------------------------------------------------------`
RESULT_PASS_COUNT=0
RESULT_FAIL_COUNT=0

TOOLS_DIR="`dirname $0`"

function result_log
{
	if [ $1 -eq 0 ]; then
		RESULT_BUF="`printf \"%s\n%55s\tpass\" \"$RESULT_BUF\" \"$2\"`"
		RESULT_PASS_COUNT=$(($RESULT_PASS_COUNT + 1))
	else
		RESULT_BUF="`printf \"%s\n%55s\tfail\" \"$RESULT_BUF\" \"$2\"`"
		RESULT_FAIL_COUNT=$(($RESULT_FAIL_COUNT + 1))
	fi
}

function result_print
{
	printf "%s" "$RESULT_BUF"
	echo -e "\n------------------------------------------------------------"
	printf "pass\t$RESULT_PASS_COUNT\n"
	printf "fail\t$RESULT_FAIL_COUNT\n"

	exit $RESULT_FAIL_COUNT
}

function get_build_arch
{
	case `uname -m` in
	    arm*)
	        BUILD_ARCH=ARM;;
	    aarch64*)
	        BUILD_ARCH=AARCH64;;
	    *)
	        BUILD_ARCH=other;;
	esac
}

function set_cross_compile
{
	get_build_arch

	echo "Target: $PLATFORM_ARCH"
	echo "Build: $BUILD_ARCH"
 	if [ "$PLATFORM_ARCH" = "$BUILD_ARCH" ]; then
	    TEMP_CROSS_COMPILE=
	elif [ "$PLATFORM_ARCH" == "AARCH64" ]; then
	    if [ X"$CROSS_COMPILE_64" != X"" ]; then
	        TEMP_CROSS_COMPILE="$CROSS_COMPILE_64"
	    else
	        TEMP_CROSS_COMPILE=aarch64-linux-gnu-
	    fi
	elif [ "$PLATFORM_ARCH" == "ARM" ]; then
	    if [ X"$CROSS_COMPILE_32" != X"" ]; then
	        TEMP_CROSS_COMPILE="$CROSS_COMPILE_32"
	    else
	        TEMP_CROSS_COMPILE=arm-linux-gnueabihf-
	    fi
	else
	    echo "Unsupported target architecture '$PLATFORM_ARCH'!" >&2
	fi
}