forked from anbox/anbox
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3222551
Showing
374 changed files
with
40,290 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
project(anbox C CXX) | ||
cmake_minimum_required(VERSION 2.8.2) | ||
|
||
include(CTest) | ||
|
||
if (NOT CMAKE_BUILD_TYPE) | ||
message(STATUS "No build type selected, default to release") | ||
set(CMAKE_BUILD_TYPE "release") | ||
endif() | ||
|
||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) | ||
|
||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wno-variadic-macros -Wextra -fPIC") | ||
|
||
# By default, all symbols are visible in the library. We strip out things we don't | ||
# want at link time, by running a version script (see unity-scopes.map and the | ||
# setting of LINK_FLAGS below). | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default") | ||
|
||
set(C_AND_CXX_WARNINGS "-pedantic -Wall -Wextra") | ||
|
||
# Some additional warnings not included by the general flags set above. | ||
set(EXTRA_C_WARNINGS "-Wcast-align -Wcast-qual -Wformat -Wredundant-decls -Wswitch-default") | ||
set(EXTRA_CXX_WARNINGS "-Wnon-virtual-dtor -Wctor-dtor-privacy -Wold-style-cast") | ||
|
||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_AND_CXX_WARNINGS}") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_WARNINGS}") | ||
|
||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ${C_AND_CXX_WARNINGS}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_C_WARNINGS}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_WARNINGS}") | ||
|
||
# -fno-permissive causes warnings with clang, so we only enable it for gcc | ||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-permissive") | ||
endif() | ||
|
||
string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower) | ||
|
||
if ("${cmake_build_type_lower}" STREQUAL "release" OR "${cmake_build_type_lower}" STREQUAL "relwithdebinfo") | ||
option(Werror "Treat warnings as errors" ON) | ||
else() | ||
option(Werror "Treat warnings as errors" OFF) | ||
endif() | ||
|
||
if (${Werror}) | ||
message(STATUS "Treat warnings as errors") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") | ||
if ("${cmake_build_type_lower}" STREQUAL "release" OR "${cmake_build_type_lower}" STREQUAL "relwithdebinfo") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=deprecated-declarations") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations") | ||
endif() | ||
endif() | ||
|
||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
|
||
find_package(Boost COMPONENTS filesystem log serialization system thread program_options) | ||
find_package(PkgConfig) | ||
find_package(Threads) | ||
find_package(EGL REQUIRED) | ||
find_package(GLESv2 REQUIRED) | ||
|
||
pkg_check_modules(MIRCLIENT REQUIRED mirclient) | ||
|
||
##################################################################### | ||
# Enable code coverage calculation with gcov/gcovr/lcov | ||
# Usage: | ||
# * Switch build type to coverage (use ccmake or cmake-gui) | ||
# * Invoke make, make test, make coverage | ||
# * Find html report in subdir coveragereport | ||
# * Find xml report feasible for jenkins in coverage.xml | ||
##################################################################### | ||
IF(CMAKE_BUILD_TYPE MATCHES [cC][oO][vV][eE][rR][aA][gG][eE]) | ||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftest-coverage -fprofile-arcs" ) | ||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftest-coverage -fprofile-arcs" ) | ||
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -ftest-coverage -fprofile-arcs" ) | ||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ftest-coverage -fprofile-arcs" ) | ||
ENDIF(CMAKE_BUILD_TYPE MATCHES [cC][oO][vV][eE][rR][aA][gG][eE]) | ||
|
||
# Build with system gmock and embedded gtest | ||
set (GMOCK_INCLUDE_DIR "/usr/include/gmock/include" CACHE PATH "gmock source include directory") | ||
set (GMOCK_SOURCE_DIR "/usr/src/gmock" CACHE PATH "gmock source directory") | ||
set (GTEST_INCLUDE_DIR "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory") | ||
|
||
add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock") | ||
|
||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC") | ||
|
||
add_subdirectory(external) | ||
add_subdirectory(src) | ||
add_subdirectory(tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# - Try to find EGL | ||
# Once done this will define | ||
# EGL_FOUND - System has EGL | ||
# EGL_INCLUDE_DIRS - The EGL include directories | ||
# EGL_LIBRARIES - The libraries needed to use EGL | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(PC_EGL QUIET egl) | ||
|
||
find_path(EGL_INCLUDE_DIR EGL/egl.h | ||
HINTS ${PC_EGL_INCLUDEDIR} ${PC_EGL_INCLUDE_DIRS}) | ||
|
||
find_library(EGL_LIBRARY EGL | ||
HINTS ${PC_EGL_LIBDIR} ${PC_EGL_LIBRARY_DIRS}) | ||
|
||
set(EGL_LIBRARIES ${EGL_LIBRARY}) | ||
set(EGL_INCLUDE_DIRS ${EGL_INCLUDE_DIR}) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
# handle the QUIETLY and REQUIRED arguments and set EGL_FOUND to TRUE | ||
# if all listed variables are TRUE | ||
find_package_handle_standard_args(EGL DEFAULT_MSG | ||
EGL_LIBRARY EGL_INCLUDE_DIR) | ||
|
||
mark_as_advanced(EGL_INCLUDE_DIR EGL_LIBRARY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# - Try to find GLESv2 | ||
# Once done this will define | ||
# GLESv2_FOUND - System has GLESv2 | ||
# GLESv2_INCLUDE_DIRS - The GLESv2 include directories | ||
# GLESv2_LIBRARIES - The libraries needed to use GLESv2 | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(PC_GLESv2 QUIET glesv2) | ||
|
||
find_path(GLESv2_INCLUDE_DIR GLES2/gl2.h | ||
HINTS ${PC_GLESv2_INCLUDEDIR} ${PC_GLESv2_INCLUDE_DIRS}) | ||
|
||
find_library(GLESv2_LIBRARY GLESv2 | ||
HINTS ${PC_GLESv2_LIBDIR} ${PC_GLESv2_LIBRARY_DIRS}) | ||
|
||
set(GLESv2_LIBRARIES ${GLESv2_LIBRARY}) | ||
set(GLESv2_INCLUDE_DIRS ${GLESv2_INCLUDE_DIR}) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
# handle the QUIETLY and REQUIRED arguments and set GLESv2_FOUND to TRUE | ||
# if all listed variables are TRUE | ||
find_package_handle_standard_args(GLESv2 DEFAULT_MSG | ||
GLESv2_LIBRARY GLESv2_INCLUDE_DIR) | ||
|
||
mark_as_advanced(GLESv2_INCLUDE_DIR GLESv2_LIBRARY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
set(CMAKE_SYSTEM_NAME Linux) | ||
set(CMAKE_SYSTEM_VERSION 1) | ||
|
||
set(AC_NDK_PATH $ENV{AC_NDK_PATH} CACHE STRING "path of mir android bundle") | ||
|
||
if (NOT DEFINED AC_TARGET_MACHINE) | ||
set(AC_TARGET_MACHINE $ENV{AC_TARGET_MACHINE} CACHE STRING "target machine") | ||
endif() | ||
if (NOT DEFINED AC_GCC_VARIANT) | ||
set(AC_GCC_VARIANT $ENV{AC_GCC_VARIANT} CACHE STRING "gcc variant required") | ||
endif() | ||
|
||
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}) | ||
|
||
# where to look to find dependencies in the target environment | ||
set(CMAKE_FIND_ROOT_PATH "${AC_NDK_PATH}") | ||
|
||
#treat the chroot's includes as system includes | ||
include_directories(SYSTEM "${AC_NDK_PATH}/usr/include" "${AC_NDK_PATH}/usr/include/${AC_TARGET_MACHINE}") | ||
list(APPEND CMAKE_SYSTEM_INCLUDE_PATH "${AC_NDK_PATH}/usr/include" "${AC_NDK_PATH}/usr/include/${AC_TARGET_MACHINE}" ) | ||
|
||
# Add the chroot libraries as system libraries | ||
list(APPEND CMAKE_SYSTEM_LIBRARY_PATH | ||
"${AC_NDK_PATH}/lib" | ||
"${AC_NDK_PATH}/lib/${AC_TARGET_MACHINE}" | ||
"${AC_NDK_PATH}/usr/lib" | ||
"${AC_NDK_PATH}/usr/lib/${AC_TARGET_MACHINE}" | ||
) | ||
|
||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) | ||
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) | ||
set(CMAKE_EXECUTABLE_RUNTIME_C_FLAG "-Wl,-rpath-link,") | ||
set(CMAKE_EXECUTABLE_RUNTIME_CXX_FLAG "-Wl,-rpath-link,") | ||
set(CMAKE_INSTALL_RPATH "${AC_NDK_PATH}/lib:${AC_NDK_PATH}/lib/${AC_TARGET_MACHINE}:${AC_NDK_PATH}/usr/lib:${AC_NDK_PATH}/usr/lib/${AC_TARGET_MACHINE}") | ||
|
||
set(ENV{PKG_CONFIG_PATH} "${AC_NDK_PATH}/usr/lib/pkgconfig:${AC_NDK_PATH}/usr/lib/${AC_TARGET_MACHINE}/pkgconfig") | ||
set(ENV{PKG_CONFIG_SYSROOT_DIR} "${AC_NDK_PATH}") | ||
|
||
#use only the cross compile system | ||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
#!/bin/bash | ||
# build script to compile anbox for armhf devices | ||
# | ||
set -e | ||
|
||
usage() { | ||
echo "usage: $(basename $0) [-a <arch>] [-c] [-h] [-d <dist>] [-u]" | ||
echo " -a <arch> Specify target architecture (armhf/arm64/powerpc/ppc64el/amd64/i386/host)" | ||
echo " -c Clean before building" | ||
echo " -d <dist> Select the distribution to build for (vivid/wily/xenial)" | ||
echo " -h This message" | ||
echo " -u Update partial chroot directory" | ||
} | ||
|
||
clean_build_dir() { | ||
rm -rf ${1} | ||
mkdir ${1} | ||
} | ||
|
||
# Default to a dist-agnostic directory name so as to not break Jenkins right now | ||
BUILD_DIR=build-android-arm | ||
# NUM_JOBS=$(( $(grep -c ^processor /proc/cpuinfo) + 1 )) | ||
NUM_JOBS=5 | ||
_do_update_chroot=0 | ||
|
||
# Default to vivid as we don't seem to have any working wily devices right now | ||
dist=vivid | ||
clean=0 | ||
update_build_dir=0 | ||
|
||
target_arch=armhf | ||
|
||
while getopts "a:cd:hu" OPTNAME | ||
do | ||
case $OPTNAME in | ||
a ) | ||
target_arch=${OPTARG} | ||
update_build_dir=1 | ||
;; | ||
c ) | ||
clean=1 | ||
;; | ||
d ) | ||
dist=${OPTARG} | ||
update_build_dir=1 | ||
;; | ||
u ) | ||
_do_update_chroot=1 | ||
;; | ||
h ) | ||
usage | ||
exit 0 | ||
;; | ||
: ) | ||
echo "Parameter -${OPTARG} needs an argument" | ||
usage | ||
exit 1; | ||
;; | ||
* ) | ||
echo "invalid option specified" | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
shift $((${OPTIND}-1)) | ||
|
||
if [ "${target_arch}" = "host" ]; then | ||
target_arch=`dpkg-architecture -qDEB_HOST_ARCH` | ||
fi | ||
|
||
if [ ${clean} -ne 0 ]; then | ||
clean_build_dir ${BUILD_DIR} | ||
fi | ||
|
||
if [ ${update_build_dir} -eq 1 ]; then | ||
BUILD_DIR=build-${target_arch}-${dist} | ||
fi | ||
|
||
if [ "${AC_NDK_PATH}" = "" ]; then | ||
export AC_NDK_PATH=~/.cache/anbox-${target_arch}-chroot-${dist} | ||
fi | ||
|
||
if [ ! -d ${AC_NDK_PATH} ]; then | ||
echo "no partial chroot dir detected. attempting to create one" | ||
_do_update_chroot=1 | ||
fi | ||
|
||
if [ ! -d ${BUILD_DIR} ]; then | ||
mkdir ${BUILD_DIR} | ||
fi | ||
|
||
echo "Building for distro: $dist" | ||
echo "Using AC_NDK_PATH: ${AC_NDK_PATH}" | ||
|
||
additional_repositories="-r http://ppa.launchpad.net/ci-train-ppa-service/stable-phone-overlay/ubuntu" | ||
|
||
gcc_variant= | ||
if [ "${dist}" = "vivid" ]; then | ||
gcc_variant=-4.9 | ||
fi | ||
|
||
case ${target_arch} in | ||
armhf ) | ||
target_machine=arm-linux-gnueabihf | ||
;; | ||
amd64 ) | ||
target_machine=x86_64-linux-gnu | ||
;; | ||
i386 ) | ||
target_machine=i386-linux-gnu | ||
;; | ||
arm64 ) | ||
target_machine=aarch64-linux-gnu | ||
;; | ||
ppc64el ) | ||
target_machine=powerpc64le-linux-gnu | ||
;; | ||
powerpc ) | ||
target_machine=powerpc-linux-gnu | ||
;; | ||
* ) | ||
# A good guess (assuming you have dpkg-architecture) | ||
target_machine=`dpkg-architecture -A${target_arch} -qDEB_HOST_MULTIARCH` || { | ||
echo "Unknown architecture ${target_arch}" | ||
usage | ||
exit 1 | ||
} | ||
;; | ||
esac | ||
|
||
echo "Target architecture: ${target_arch}" | ||
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} | ||
popd > /dev/null | ||
# force a clean build after an update, since CMake cache maybe out of date | ||
clean_build_dir ${BUILD_DIR} | ||
fi | ||
|
||
pushd ${BUILD_DIR} > /dev/null | ||
|
||
export PKG_CONFIG_PATH="${AC_NDK_PATH}/usr/lib/pkgconfig:${AC_NDK_PATH}/usr/lib/${target_machine}/pkgconfig" | ||
export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 | ||
export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 | ||
export PKG_CONFIG_SYSROOT_DIR=$AC_NDK_PATH | ||
export PKG_CONFIG_EXECUTABLE=`which pkg-config` | ||
export AC_TARGET_MACHINE=${target_machine} | ||
export AC_GCC_VARIANT=${gcc_variant} | ||
export LDFLAGS=-Wl,-rpath-link,${AC_NDK_PATH}/usr/lib/${target_machine}/pulseaudio | ||
echo "Using PKG_CONFIG_PATH: $PKG_CONFIG_PATH" | ||
echo "Using PKG_CONFIG_EXECUTABLE: $PKG_CONFIG_EXECUTABLE" | ||
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/LinuxCrossCompile.cmake \ | ||
-DCMAKE_BUILD_TYPE=debug \ | ||
.. | ||
|
||
make -j${NUM_JOBS} $@ | ||
|
||
popd > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
add_subdirectory(bubblewrap) | ||
add_subdirectory(process-cpp-minimal) | ||
add_subdirectory(android-emugl) |
Oops, something went wrong.