blob: 875afb05d62712bddc7a0e1e6bfa9287ef7ff302 [file] [log] [blame]
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001#!/bin/bash
2#
3# this script is used to rebuild all QEMU binaries for the host
4# platforms.
5#
6# assume that the device tree is in TOP
7#
8
David 'Digit' Turnercc80ebe2014-02-10 11:40:49 +01009set -e
10export LANG=C
11export LC_ALL=C
12
13VERBOSE=0
14
15MINGW=
16for OPT; do
17 case $OPT in
18 --mingw)
19 MINGW=true
20 ;;
21 --verbose)
22 VERBOSE=$(( $VERBOSE + 1 ))
23 ;;
24 --help|-?)
25 VERBOSE=2
26 ;;
27 esac
28done
29
David 'Digit' Turnera10b3162014-02-18 15:36:05 +010030panic () {
31 echo "ERROR: $@"
32 exit 1
33}
34
David 'Digit' Turnercc80ebe2014-02-10 11:40:49 +010035run () {
36 if [ "$VERBOSE" -ge 1 ]; then
37 "$@"
38 else
39 "$@" >/dev/null 2>&1
40 fi
41}
42
43HOST_OS=$(uname -s)
44case $HOST_OS in
David 'Digit' Turnerc3b08a02011-05-10 12:58:05 +020045 Linux)
46 HOST_NUM_CPUS=`cat /proc/cpuinfo | grep processor | wc -l`
47 ;;
48 Darwin|FreeBsd)
49 HOST_NUM_CPUS=`sysctl -n hw.ncpu`
50 ;;
51 CYGWIN*|*_NT-*)
52 HOST_NUM_CPUS=$NUMBER_OF_PROCESSORS
53 ;;
54 *) # let's play safe here
55 HOST_NUM_CPUS=1
56esac
57
David 'Digit' Turnercc80ebe2014-02-10 11:40:49 +010058# Build the binaries from sources.
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080059cd `dirname $0`
David 'Digit' Turnercc80ebe2014-02-10 11:40:49 +010060rm -rf objs
61echo "Configuring build."
David 'Digit' Turnera10b3162014-02-18 15:36:05 +010062run ./android-configure.sh "$@" ||
63 panic "Configuration error, please run ./android-configure.sh to see why."
David 'Digit' Turnercc80ebe2014-02-10 11:40:49 +010064
65echo "Building sources."
David 'Digit' Turnera10b3162014-02-18 15:36:05 +010066run make -j$HOST_NUM_CPUS ||
67 panic "Could not build sources, please run 'make' to see why."
David 'Digit' Turnercc80ebe2014-02-10 11:40:49 +010068
69RUN_64BIT_TESTS=true
70
71TEST_SHELL=
72EXE_SUFFIX=
73if [ "$MINGW" ]; then
David 'Digit' Turnera10b3162014-02-18 15:36:05 +010074 RUN_64BIT_TESTS=
David 'Digit' Turnercc80ebe2014-02-10 11:40:49 +010075 TEST_SHELL=wine
76 EXE_SUFFIX=.exe
77fi
78
79echo "Running 32-bit unit test suite."
David 'Digit' Turner1af82152014-03-03 20:41:37 +010080FAILURES=""
81for UNIT_TEST in emulator_unittests emugl_common_host_unittests; do
82 echo " - $UNIT_TEST"
83 run $TEST_SHELL objs/$UNIT_TEST$EXE_SUFFIX || FAILURES="$FAILURES $UNIT_TEST"
84done
David 'Digit' Turnera10b3162014-02-18 15:36:05 +010085
David 'Digit' Turnercc80ebe2014-02-10 11:40:49 +010086if [ "$RUN_64BIT_TESTS" ]; then
87 echo "Running 64-bit unit test suite."
David 'Digit' Turner1af82152014-03-03 20:41:37 +010088 for UNIT_TEST in emulator64_unittests emugl64_common_host_unittests; do
89 echo " - $UNIT_TEST"
90 run $TEST_SHELL objs/$UNIT_TEST$EXE_SUFFIX || FAILURES="$FAILURES $UNIT_TEST"
91 done
92fi
93
94if [ "$FAILURES" ]; then
95 panic "Unit test failures: $FAILURES"
David 'Digit' Turnercc80ebe2014-02-10 11:40:49 +010096fi
97
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080098echo "Done. !!"