From a1dce43b50db383aa11458bdfc7aae68e8b00e7c Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Wed, 25 Jan 2017 18:14:09 +0100 Subject: [PATCH 1/7] Use host compiler to build emugen utility in cross-build environments --- cmake/LinuxCrossCompile.cmake | 3 +++ external/android-emugl/host/tools/emugen/CMakeLists.txt | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/cmake/LinuxCrossCompile.cmake b/cmake/LinuxCrossCompile.cmake index d279424..956249d 100644 --- a/cmake/LinuxCrossCompile.cmake +++ b/cmake/LinuxCrossCompile.cmake @@ -10,6 +10,9 @@ if (NOT DEFINED AC_GCC_VARIANT) set(AC_GCC_VARIANT $ENV{AC_GCC_VARIANT} CACHE STRING "gcc variant required") endif() +set(HOST_CMAKE_C_COMPILER /usr/bin/cc) +set(HOST_CMAKE_CXX_COMPILER /usr/bin/c++) + set(CMAKE_C_COMPILER /usr/bin/${AC_TARGET_MACHINE}-gcc${AC_GCC_VARIANT}) set(CMAKE_CXX_COMPILER /usr/bin/${AC_TARGET_MACHINE}-g++${AC_GCC_VARIANT}) diff --git a/external/android-emugl/host/tools/emugen/CMakeLists.txt b/external/android-emugl/host/tools/emugen/CMakeLists.txt index dbdca59..8285126 100644 --- a/external/android-emugl/host/tools/emugen/CMakeLists.txt +++ b/external/android-emugl/host/tools/emugen/CMakeLists.txt @@ -1,3 +1,7 @@ +if (NOT "${HOST_CMAKE_CXX_COMPILER}" STREQUAL "") + set (CMAKE_CXX_COMPILER "${HOST_CMAKE_CXX_COMPILER}") +endif() + set(SOURCES ApiGen.cpp EntryPoint.cpp From 9743c6d4f71849f40e5525820418034f958a90fd Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Wed, 25 Jan 2017 18:14:35 +0100 Subject: [PATCH 2/7] debian: specify all build dependencies --- debian/control | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/debian/control b/debian/control index 3604bf9..c754c38 100644 --- a/debian/control +++ b/debian/control @@ -14,6 +14,7 @@ Build-Depends: cmake, libboost-iostreams-dev, libboost-program-options-dev, libboost-system-dev, + libboost-test-dev, # boost log needs exactly one symbol from boost-thread for resolving # thread-specific storage locations. libboost-thread-dev, @@ -25,6 +26,8 @@ Build-Depends: cmake, libglib2.0-dev, libgtest-dev, libprotobuf-dev, + libsdl2-dev, + lxc-dev, pkg-config, protobuf-compiler Standards-Version: 3.9.4 @@ -37,13 +40,7 @@ Vcs-Browser: https://git.launchpad.net/anbox Package: anbox Architecture: i386 amd64 armhf arm64 Depends: ${misc:Depends}, - ${shlibs:Depends}, -# Provides newuidmap/newgidmap setuid helpers to initialize -# a user namespace. - uidmap, -# We depend on lxc-usernsexec as helper to spawn up the user -# namespace for our container. - lxc + ${shlibs:Depends} Description: Android in a Box Runtime for Android applications which runs a full Android system in a container using Linux namespaces (user, ipc, net, mount) to From 0aa311c69fc673518228ae0915906f421053554a Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Wed, 25 Jan 2017 18:16:43 +0100 Subject: [PATCH 3/7] Use provided linker flags from pkgconfig in our build --- src/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1c54501..461b906 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -196,8 +196,11 @@ add_library(anbox-core ${SOURCES}) target_link_libraries(anbox-core ${Boost_LDFLAGS} ${Boost_LIBRARIES} + ${DBUS_CPP_LDFLAGS} ${DBUS_CPP_LIBRARIES} + ${SDL2_LDFLAGS} ${SDL2_LIBRARIES} + ${LXC_LDFLAGS} ${LXC_LIBRARIES} pthread process-cpp From 423e3255274a5717b960a6ed4f64968a15df1fb4 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Wed, 25 Jan 2017 18:17:10 +0100 Subject: [PATCH 4/7] Fetch packages from updates and security pockets for cross-builds too --- scripts/setup-partial-armhf-chroot.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/setup-partial-armhf-chroot.sh b/scripts/setup-partial-armhf-chroot.sh index b298cf6..b4831a8 100755 --- a/scripts/setup-partial-armhf-chroot.sh +++ b/scripts/setup-partial-armhf-chroot.sh @@ -114,13 +114,25 @@ arch=${arch} directory=${directory} unpack=false noauth=true -bootstrap=Ubuntu ${sources} +bootstrap=Ubuntu UbuntuUpdates UbuntuSecurity ${sources} [Ubuntu] packages=${builddeps} source=${source_url} suite=${dist} components=main universe + +[UbuntuUpdates] +packages=${builddeps} +source=${source_url} +suite=${dist}-updates +components=main universe + +[UbuntuSecurity] +packages=${builddeps} +source=${source_url} +suite=${dist}-security +components=main universe " > mstrap.conf sourceid=0 From ffdc33ce8e011fdc05dcbfb8d39f17611362d0c3 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Wed, 25 Jan 2017 18:17:26 +0100 Subject: [PATCH 5/7] Report host compiler we're using on configuration --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb40de8..2f8de6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,3 +100,8 @@ add_subdirectory(external) add_subdirectory(src) add_subdirectory(tests) add_subdirectory(android) + +if (NOT "${HOST_CMAKE_C_COMPILER}" STREQUAL "") + message(STATUS "Host C compiler: ${HOST_CMAKE_C_COMPILER}") + message(STATUS "Host C compiler: ${HOST_CMAKE_CXX_COMPILER}") +endif() From 4219f40ac37f359203bd94b450847b198d74213c Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Fri, 27 Jan 2017 07:14:47 +0100 Subject: [PATCH 6/7] Add missing copyright header for the cross-build scripts --- cross-compile-chroot.sh | 17 ++++++++++++++++- scripts/setup-partial-armhf-chroot.sh | 15 ++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/cross-compile-chroot.sh b/cross-compile-chroot.sh index 2dc8790..38f1928 100755 --- a/cross-compile-chroot.sh +++ b/cross-compile-chroot.sh @@ -1,6 +1,21 @@ #!/bin/bash -# build script to compile anbox for armhf devices # +# Copyright © 2016 Canonical Ltd. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License version 3, +# as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . +# +# Taken from the Mir Project (https://launchpad.net/mir) + set -e usage() { diff --git a/scripts/setup-partial-armhf-chroot.sh b/scripts/setup-partial-armhf-chroot.sh index b4831a8..983a649 100755 --- a/scripts/setup-partial-armhf-chroot.sh +++ b/scripts/setup-partial-armhf-chroot.sh @@ -1,7 +1,20 @@ #!/bin/bash # -# TODO: Rename this file without "armhf" when it's safe to do so. +# Copyright © 2016 Canonical Ltd. # +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License version 3, +# as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . +# +# Taken from the Mir Project (https://launchpad.net/mir) set -e From e4682cab344ad44de6ab9673333f3ed3df237999 Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Fri, 27 Jan 2017 07:17:21 +0100 Subject: [PATCH 7/7] Drop armhf from the chroot setup script --- cross-compile-chroot.sh | 2 +- .../{setup-partial-armhf-chroot.sh => setup-partial-chroot.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename scripts/{setup-partial-armhf-chroot.sh => setup-partial-chroot.sh} (100%) diff --git a/cross-compile-chroot.sh b/cross-compile-chroot.sh index 38f1928..15f8e35 100755 --- a/cross-compile-chroot.sh +++ b/cross-compile-chroot.sh @@ -150,7 +150,7 @@ echo "Target machine: ${target_machine}" if [ ${_do_update_chroot} -eq 1 ] ; then pushd scripts > /dev/null - ./setup-partial-armhf-chroot.sh -d ${dist} -a ${target_arch} ${additional_repositories} ${AC_NDK_PATH} + ./setup-partial-chroot.sh -d ${dist} -a ${target_arch} ${additional_repositories} ${AC_NDK_PATH} popd > /dev/null # force a clean build after an update, since CMake cache maybe out of date clean_build_dir ${BUILD_DIR} diff --git a/scripts/setup-partial-armhf-chroot.sh b/scripts/setup-partial-chroot.sh similarity index 100% rename from scripts/setup-partial-armhf-chroot.sh rename to scripts/setup-partial-chroot.sh