aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2014-09-01 12:54:57 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-09-01 12:54:57 +0000
commit49ba77b278cf120573b13719db8d9bddfb2e3dc1 (patch)
treedb9e01853f34b16338c2809ef5827fa59aee7265
parent9b739ccc83aa7cd2190dd2bb66d86d459022bb41 (diff)
parent820b4f2e22b5441873bdbaa5f76bfc115687884a (diff)
downloadqemu-49ba77b278cf120573b13719db8d9bddfb2e3dc1.tar.gz
Merge "Ensure 'emulator' launcher is always built on Darwin."
-rw-r--r--Makefile.android39
-rw-r--r--Makefile.common3
-rwxr-xr-xandroid-rebuild.sh56
-rw-r--r--android/build/clear_vars.make1
4 files changed, 91 insertions, 8 deletions
diff --git a/Makefile.android b/Makefile.android
index a57c170092..275d595073 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -19,14 +19,27 @@ EMULATOR_BUILD_32BITS := $(strip $(filter windows linux,$(HOST_OS)))
# Windows, Linux and Darwin.
EMULATOR_BUILD_64BITS := $(strip $(filter linux darwin windows,$(HOST_OS)))
-# A function that includes a file only if 32-bit binaries are necessary.
-# This is always the case, but later used with include-if-bitness-64.
+# EMULATOR_PROGRAM_BITNESS is the bitness of the 'emulator' launcher program.
+# It will be 32 if we allow 32-bit binaries to be built, 64 otherwise.
+ifneq (,$(EMULATOR_BUILD_32BITS))
+ EMULATOR_PROGRAM_BITNESS := 32
+else
+ EMULATOR_PROGRAM_BITNESS := 64
+endif
+
+# A function that includes a file only if 32-bit binaries are necessary,
+# or if LOCAL_IGNORE_BITNESS is defined for the current module.
# $1: Build file to include.
-include-if-bitness-32 = $(if $(strip $(EMULATOR_BUILD_32BITS)),$(eval include $1))
+include-if-bitness-32 = \
+ $(if $(strip $(LOCAL_IGNORE_BITNESS)$(EMULATOR_BUILD_32BITS)),\
+ $(eval include $1))
# A function that includes a file only of EMULATOR_BUILD_64BITS is not empty.
+# or if LOCAL_IGNORE_BITNESS is defined for the current module.
# $1: Build file to include.
-include-if-bitness-64 = $(if $(strip $(EMULATOR_BUILD_64BITS)),$(eval include $1))
+include-if-bitness-64 = \
+ $(if $(strip $(LOCAL_IGNORE_BITNESS)$(EMULATOR_BUILD_64BITS)),\
+ $(eval include $1))
# determine the location of platform-specific directories
#
@@ -370,11 +383,23 @@ include $(LOCAL_PATH)/Makefile.qemu-launcher
###
### emulator: LAUNCHER FOR TARGET-SPECIFIC EMULATOR
###
-###
-$(call start-emulator-program, emulator)
+# NOTE: Build as 32-bit or 64-bit executable, depending on the value of
+# EMULATOR_PROGRAM_BITNESS.
+ifeq (32,$(EMULATOR_PROGRAM_BITNESS))
+$(call start-emulator-program, emulator)
+else
+$(call start-emulator64-program, emulator)
+endif
LOCAL_SRC_FILES := android/main-emulator.c
-LOCAL_STATIC_LIBRARIES := emulator-common
+
+ifeq (32,$(EMULATOR_PROGRAM_BITNESS))
+ LOCAL_STATIC_LIBRARIES := emulator-common
+ # Ensure this is always built, even if 32-bit binaries are disabled.
+ LOCAL_IGNORE_BITNESS := true
+else
+ LOCAL_STATIC_LIBRARIES := emulator64-common
+endif
ifeq ($(HOST_OS),windows)
$(eval $(call insert-windows-icon))
diff --git a/Makefile.common b/Makefile.common
index 81733721c4..0e51b0eb02 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -180,6 +180,9 @@ common_LOCAL_CFLAGS += -I$(LIBEXT4_UTILS_INCLUDES)
$(call start-emulator-library, emulator-common)
LOCAL_CFLAGS += $(common_LOCAL_CFLAGS)
LOCAL_SRC_FILES += $(common_LOCAL_SRC_FILES)
+ifeq (32,$(EMULATOR_PROGRAM_BITNESS))
+ LOCAL_IGNORE_BITNESS := true
+endif
$(call gen-hw-config-defs)
$(call end-emulator-library)
diff --git a/android-rebuild.sh b/android-rebuild.sh
index 99f9d09d83..20ee417abc 100755
--- a/android-rebuild.sh
+++ b/android-rebuild.sh
@@ -64,6 +64,42 @@ case $HOST_OS in
HOST_NUM_CPUS=1
esac
+
+# Return the type of a given file, using the /usr/bin/file command.
+# $1: executable path.
+# Out: file type string, or empty if the path is wrong.
+get_file_type () {
+ /usr/bin/file "$1" 2>/dev/null
+}
+
+# Return true iff the file type string |$1| contains the expected
+# substring |$2|.
+# $1: executable file type
+# $2: expected file type substring
+check_file_type_substring () {
+ printf "%s\n" "$1" | grep -q -F -e "$2"
+}
+
+# Define EXPECTED_32BIT_FILE_TYPE and EXPECTED_64BIT_FILE_TYPE depending
+# on the current target platform. Then EXPECTED_EMULATOR_BITNESS and
+# EXPECTED_EMULATOR_FILE_TYPE accordingly.
+if [ "$MINGW" ]; then
+ EXPECTED_32BIT_FILE_TYPE="PE32 executable (console) Intel 80386"
+ EXPECTED_64BIT_FILE_TYPE="PE32+ executable (console) x86-64"
+ EXPECTED_EMULATOR_BITNESS=32
+ EXPECTED_EMULATOR_FILE_TYPE=$EXPECTED_32BIT_FILE_TYPE
+elif [ "$HOST_OS" = "Darwin" ]; then
+ EXPECTED_32BIT_FILE_TYPE="Mach-O executable i386"
+ EXPECTED_64BIT_FILE_TYPE="Mach-O 64-bit executable x86_64"
+ EXPECTED_EMULATOR_BITNESS=64
+ EXPECTED_EMULATOR_FILE_TYPE=$EXPECTED_64BIT_FILE_TYPE
+else
+ EXPECTED_32BIT_FILE_TYPE="ELF 32-bit LSB executable, Intel 80386"
+ EXPECTED_64BIT_FILE_TYPE="ELF 32-bit LSB executable, x86-64"
+ EXPECTED_EMULATOR_BITNESS=32
+ EXPECTED_EMULATOR_FILE_TYPE=$EXPECTED_32BIT_FILE_TYPE
+fi
+
# Build the binaries from sources.
cd `dirname $0`
rm -rf objs
@@ -99,10 +135,28 @@ if [ "$HOST_OS" = "Linux" ]; then
RUN_32BIT_TESTS=true
fi
+
if [ -z "$NO_TESTS" ]; then
+ FAILURES=""
+
+ echo "Checking for 'emulator' launcher program."
+ EMULATOR=$OUT_DIR/emulator$EXE_SUFFIX
+ if [ ! -f "$EMULATOR" ]; then
+ echo " - FAIL: $EMULATOR is missing!"
+ FAILURES="$FAILURES emulator"
+ fi
+
+ echo "Checking that 'emulator' is a $EXPECTED_EMULATOR_BITNESS-bit program."
+ EMULATOR_FILE_TYPE=$(get_file_type "$EMULATOR")
+ if ! check_file_type_substring "$EMULATOR_FILE_TYPE" "$EXPECTED_EMULATOR_FILE_TYPE"; then
+ echo " - FAIL: $EMULATOR is not a 32-bit executable!"
+ echo " File type: $EMULATOR_FILE_TYPE"
+ echo " Expected : $EXPECTED_EMULATOR_FILE_TYPE"
+ FAILURES="$FAILURES emulator-bitness-check"
+ fi
+
if [ "$RUN_32BIT_TESTS" ]; then
echo "Running 32-bit unit test suite."
- FAILURES=""
for UNIT_TEST in emulator_unittests emugl_common_host_unittests; do
echo " - $UNIT_TEST"
run $TEST_SHELL $OUT_DIR/$UNIT_TEST$EXE_SUFFIX || FAILURES="$FAILURES $UNIT_TEST"
diff --git a/android/build/clear_vars.make b/android/build/clear_vars.make
index 6dfc7a30a1..c38aa4b0f9 100644
--- a/android/build/clear_vars.make
+++ b/android/build/clear_vars.make
@@ -23,6 +23,7 @@ LOCAL_ADDITIONAL_DEPENDENCIES :=
LOCAL_AR :=
LOCAL_CFLAGS :=
LOCAL_HOST_BUILD :=
+LOCAL_IGNORE_BITNESS :=
LOCAL_LDFLAGS :=
LOCAL_LDLIBS :=
LOCAL_SRC_FILES :=