summaryrefslogtreecommitdiff
path: root/TestScripts/cryptest-android.sh
blob: b7440f516b78d7d0a0f7dd7bfc59213ae60a264d (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
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash

# ====================================================================
# Tests Android cross-compiles
#
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
# licensed under the Boost Software License 1.0, while the individual files
# in the compilation are all public domain.
#
# See http://www.cryptopp.com/wiki/Android_(Command_Line) for more details
# ====================================================================
set +e

if [ -z $(command -v ./setenv-android-gcc.sh) ]; then
	echo "Failed to locate setenv-android-gcc.sh"
	ls -Al *.sh
	[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi

if [ -z "${PLATFORM-}" ]; then
	PLATFORMS=(armeabi armeabi-v7a armv7a-neon aarch64 mipsel mipsel64 x86 x86_64)
else
	PLATFORMS=(${PLATFORM})
fi
RUNTIMES=(gnu-static gnu-shared stlport-static stlport-shared) #llvm-static llvm-shared

for platform in ${PLATFORMS[@]}
do
	for runtime in ${RUNTIMES[@]}
	do
		make -f GNUmakefile-cross distclean > /dev/null 2>&1

		echo
		echo "===================================================================="
		echo "Testing for Android support of $platform using $runtime"

		# Test if we can set the environment for the platform
		./setenv-android-gcc.sh "$platform" "$runtime"

		if [ "$?" -ne "0" ];
		then
			echo
			echo "There were problems testing $platform with $runtime"
			echo "$platform:$runtime ==> FAILURE" >> /tmp/build.log

			touch /tmp/build.failed
			continue
		fi

		echo
		echo "Building for $platform using $runtime..."
		echo

		# run in subshell to not keep any env vars
		(
			source ./setenv-android-gcc.sh "$platform" "$runtime" > /dev/null 2>&1
			make -f GNUmakefile-cross static dynamic cryptest.exe
			if [ "$?" -eq "0" ]; then
				echo "$platform:$runtime ==> SUCCESS" >> /tmp/build.log
			else
				echo "$platform:$runtime ==> FAILURE" >> /tmp/build.log
				touch /tmp/build.failed
			fi
		)
	done
done

cat /tmp/build.log

# let the script fail if any of the builds failed
if [ -f /tmp/build.failed ]; then
	[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 1 || return 1
fi

[[ "$0" = "${BASH_SOURCE[0]}" ]] && exit 0 || return 0