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= |
David 'Digit' Turner | 9f86acc | 2014-05-13 11:22:12 +0200 | [diff] [blame] | 16 | NO_TESTS= |
David 'Digit' Turner | a96cc26 | 2014-05-12 21:28:34 +0200 | [diff] [blame] | 17 | OUT_DIR=objs |
| 18 | |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 19 | for OPT; do |
| 20 | case $OPT in |
| 21 | --mingw) |
| 22 | MINGW=true |
| 23 | ;; |
| 24 | --verbose) |
| 25 | VERBOSE=$(( $VERBOSE + 1 )) |
| 26 | ;; |
David 'Digit' Turner | 9f86acc | 2014-05-13 11:22:12 +0200 | [diff] [blame] | 27 | --no-tests) |
| 28 | NO_TESTS=true |
| 29 | ;; |
David 'Digit' Turner | a96cc26 | 2014-05-12 21:28:34 +0200 | [diff] [blame] | 30 | --out-dir=*) |
| 31 | OUT_DIR=${OPT##--out-dir=} |
| 32 | ;; |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 33 | --help|-?) |
| 34 | VERBOSE=2 |
| 35 | ;; |
| 36 | esac |
| 37 | done |
| 38 | |
David 'Digit' Turner | a10b316 | 2014-02-18 15:36:05 +0100 | [diff] [blame] | 39 | panic () { |
| 40 | echo "ERROR: $@" |
| 41 | exit 1 |
| 42 | } |
| 43 | |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 44 | run () { |
| 45 | if [ "$VERBOSE" -ge 1 ]; then |
| 46 | "$@" |
| 47 | else |
| 48 | "$@" >/dev/null 2>&1 |
| 49 | fi |
| 50 | } |
| 51 | |
| 52 | HOST_OS=$(uname -s) |
| 53 | case $HOST_OS in |
David 'Digit' Turner | c3b08a0 | 2011-05-10 12:58:05 +0200 | [diff] [blame] | 54 | Linux) |
| 55 | HOST_NUM_CPUS=`cat /proc/cpuinfo | grep processor | wc -l` |
| 56 | ;; |
| 57 | Darwin|FreeBsd) |
| 58 | HOST_NUM_CPUS=`sysctl -n hw.ncpu` |
| 59 | ;; |
| 60 | CYGWIN*|*_NT-*) |
| 61 | HOST_NUM_CPUS=$NUMBER_OF_PROCESSORS |
| 62 | ;; |
| 63 | *) # let's play safe here |
| 64 | HOST_NUM_CPUS=1 |
| 65 | esac |
| 66 | |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 67 | # Build the binaries from sources. |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 68 | cd `dirname $0` |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 69 | rm -rf objs |
| 70 | echo "Configuring build." |
David 'Digit' Turner | a96cc26 | 2014-05-12 21:28:34 +0200 | [diff] [blame] | 71 | run ./android-configure.sh --out-dir=$OUT_DIR "$@" || |
David 'Digit' Turner | a10b316 | 2014-02-18 15:36:05 +0100 | [diff] [blame] | 72 | panic "Configuration error, please run ./android-configure.sh to see why." |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 73 | |
| 74 | echo "Building sources." |
David 'Digit' Turner | a96cc26 | 2014-05-12 21:28:34 +0200 | [diff] [blame] | 75 | run make -j$HOST_NUM_CPUS OBJS_DIR="$OUT_DIR" || |
David 'Digit' Turner | a10b316 | 2014-02-18 15:36:05 +0100 | [diff] [blame] | 76 | panic "Could not build sources, please run 'make' to see why." |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 77 | |
| 78 | RUN_64BIT_TESTS=true |
| 79 | |
| 80 | TEST_SHELL= |
| 81 | EXE_SUFFIX= |
| 82 | if [ "$MINGW" ]; then |
David 'Digit' Turner | a10b316 | 2014-02-18 15:36:05 +0100 | [diff] [blame] | 83 | RUN_64BIT_TESTS= |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 84 | TEST_SHELL=wine |
| 85 | EXE_SUFFIX=.exe |
David 'Digit' Turner | 9f86acc | 2014-05-13 11:22:12 +0200 | [diff] [blame] | 86 | |
| 87 | # Check for Wine on this machine. |
| 88 | WINE_CMD=$(which $TEST_SHELL 2>/dev/null || true) |
| 89 | if [ -z "$NO_TESTS" -a -z "$WINE_CMD" ]; then |
| 90 | echo "WARNING: Wine is not installed on this machine!! Unit tests will be ignored!!" |
| 91 | NO_TESTS=true |
| 92 | fi |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 93 | fi |
| 94 | |
David 'Digit' Turner | 9f86acc | 2014-05-13 11:22:12 +0200 | [diff] [blame] | 95 | if [ -z "$NO_TESTS" ]; then |
| 96 | echo "Running 32-bit unit test suite." |
| 97 | FAILURES="" |
| 98 | for UNIT_TEST in emulator_unittests emugl_common_host_unittests; do |
| 99 | echo " - $UNIT_TEST" |
| 100 | run $TEST_SHELL $OUT_DIR/$UNIT_TEST$EXE_SUFFIX || FAILURES="$FAILURES $UNIT_TEST" |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 101 | done |
David 'Digit' Turner | 1af8215 | 2014-03-03 20:41:37 +0100 | [diff] [blame] | 102 | |
David 'Digit' Turner | 9f86acc | 2014-05-13 11:22:12 +0200 | [diff] [blame] | 103 | if [ "$RUN_64BIT_TESTS" ]; then |
| 104 | echo "Running 64-bit unit test suite." |
| 105 | for UNIT_TEST in emulator64_unittests emugl64_common_host_unittests; do |
| 106 | echo " - $UNIT_TEST" |
| 107 | run $TEST_SHELL $OUT_DIR/$UNIT_TEST$EXE_SUFFIX || FAILURES="$FAILURES $UNIT_TEST" |
| 108 | done |
| 109 | fi |
| 110 | |
| 111 | if [ "$FAILURES" ]; then |
| 112 | panic "Unit test failures: $FAILURES" |
| 113 | fi |
| 114 | else |
| 115 | echo "Ignoring unit tests suite." |
David 'Digit' Turner | cc80ebe | 2014-02-10 11:40:49 +0100 | [diff] [blame] | 116 | fi |
| 117 | |
The Android Open Source Project | 8b23a6c | 2009-03-03 19:30:32 -0800 | [diff] [blame] | 118 | echo "Done. !!" |