The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 1 | #!/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' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 9 | set -e |
| 10 | export LANG=C |
| 11 | export LC_ALL=C |
| 12 | |
| 13 | VERBOSE=0 |
| 14 | |
| 15 | MINGW= |
| 16 | for 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 |
| 28 | done |
| 29 | |
David 'Digit' Turner | a10b316 | 2014-02-18 15:36:05 +0100 | [diff] [blame] | 30 | panic () { |
| 31 | echo "ERROR: $@" |
| 32 | exit 1 |
| 33 | } |
| 34 | |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 35 | run () { |
| 36 | if [ "$VERBOSE" -ge 1 ]; then |
| 37 | "$@" |
| 38 | else |
| 39 | "$@" >/dev/null 2>&1 |
| 40 | fi |
| 41 | } |
| 42 | |
| 43 | HOST_OS=$(uname -s) |
| 44 | case $HOST_OS in |
David 'Digit' Turner | c3b08a0 | 2011-05-10 12:58:05 +0200 | [diff] [blame] | 45 | 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 |
| 56 | esac |
| 57 | |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 58 | # Build the binaries from sources. |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 59 | cd `dirname $0` |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 60 | rm -rf objs |
| 61 | echo "Configuring build." |
David 'Digit' Turner | a10b316 | 2014-02-18 15:36:05 +0100 | [diff] [blame] | 62 | run ./android-configure.sh "$@" || |
| 63 | panic "Configuration error, please run ./android-configure.sh to see why." |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 64 | |
| 65 | echo "Building sources." |
David 'Digit' Turner | a10b316 | 2014-02-18 15:36:05 +0100 | [diff] [blame] | 66 | run make -j$HOST_NUM_CPUS || |
| 67 | panic "Could not build sources, please run 'make' to see why." |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 68 | |
| 69 | RUN_64BIT_TESTS=true |
| 70 | |
| 71 | TEST_SHELL= |
| 72 | EXE_SUFFIX= |
| 73 | if [ "$MINGW" ]; then |
David 'Digit' Turner | a10b316 | 2014-02-18 15:36:05 +0100 | [diff] [blame] | 74 | RUN_64BIT_TESTS= |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 75 | TEST_SHELL=wine |
| 76 | EXE_SUFFIX=.exe |
| 77 | fi |
| 78 | |
| 79 | echo "Running 32-bit unit test suite." |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 80 | FAILURES="" |
| 81 | for 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" |
| 84 | done |
David 'Digit' Turner | a10b316 | 2014-02-18 15:36:05 +0100 | [diff] [blame] | 85 | |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 86 | if [ "$RUN_64BIT_TESTS" ]; then |
| 87 | echo "Running 64-bit unit test suite." |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 88 | 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 |
| 92 | fi |
| 93 | |
| 94 | if [ "$FAILURES" ]; then |
| 95 | panic "Unit test failures: $FAILURES" |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 96 | fi |
| 97 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 98 | echo "Done. !!" |