• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
9set -e
10export LANG=C
11export LC_ALL=C
12
13VERBOSE=0
14
15MINGW=
16NO_TESTS=
17OUT_DIR=objs
18
19for OPT; do
20    case $OPT in
21        --mingw)
22            MINGW=true
23            ;;
24        --verbose)
25            VERBOSE=$(( $VERBOSE + 1 ))
26            ;;
27        --no-tests)
28            NO_TESTS=true
29            ;;
30        --out-dir=*)
31            OUT_DIR=${OPT##--out-dir=}
32            ;;
33        --help|-?)
34            VERBOSE=2
35            ;;
36    esac
37done
38
39panic () {
40    echo "ERROR: $@"
41    exit 1
42}
43
44run () {
45  if [ "$VERBOSE" -ge 1 ]; then
46    "$@"
47  else
48    "$@" >/dev/null 2>&1
49  fi
50}
51
52HOST_OS=$(uname -s)
53case $HOST_OS in
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
65esac
66
67# Build the binaries from sources.
68cd `dirname $0`
69rm -rf objs
70echo "Configuring build."
71run ./android-configure.sh --out-dir=$OUT_DIR "$@" ||
72    panic "Configuration error, please run ./android-configure.sh to see why."
73
74echo "Building sources."
75run make -j$HOST_NUM_CPUS OBJS_DIR="$OUT_DIR" ||
76    panic "Could not build sources, please run 'make' to see why."
77
78RUN_64BIT_TESTS=true
79
80TEST_SHELL=
81EXE_SUFFIX=
82if [ "$MINGW" ]; then
83  RUN_64BIT_TESTS=
84  TEST_SHELL=wine
85  EXE_SUFFIX=.exe
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
93fi
94
95if [ -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"
101    done
102
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
114else
115    echo "Ignoring unit tests suite."
116fi
117
118echo "Done. !!"
119