3 # Copyright © 2016 Canonical Ltd.
5 # This program is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License version 3,
7 # as published by the Free Software Foundation.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Taken from the Mir Project (https://launchpad.net/mir)
22 echo "usage: $(basename $0) [-a <arch>] [-c] [-h] [-d <dist>] [-u]"
23 echo " -a <arch> Specify target architecture (armhf/arm64/powerpc/ppc64el/amd64/i386/host)"
24 echo " -c Clean before building"
25 echo " -d <dist> Select the distribution to build for (vivid/wily/xenial)"
26 echo " -h This message"
27 echo " -u Update partial chroot directory"
35 # Default to a dist-agnostic directory name so as to not break Jenkins right now
36 BUILD_DIR=build-android-arm
37 # NUM_JOBS=$(( $(grep -c ^processor /proc/cpuinfo) + 1 ))
41 # Default to vivid as we don't seem to have any working wily devices right now
48 while getopts "a:cd:hu" OPTNAME
70 echo "Parameter -${OPTARG} needs an argument"
75 echo "invalid option specified"
82 shift $((${OPTIND}-1))
84 if [ "${target_arch}" = "host" ]; then
85 target_arch=`dpkg-architecture -qDEB_HOST_ARCH`
88 if [ ${clean} -ne 0 ]; then
89 clean_build_dir ${BUILD_DIR}
92 if [ ${update_build_dir} -eq 1 ]; then
93 BUILD_DIR=build-${target_arch}-${dist}
96 if [ "${AC_NDK_PATH}" = "" ]; then
97 export AC_NDK_PATH=~/.cache/anbox-${target_arch}-chroot-${dist}
100 if [ ! -d ${AC_NDK_PATH} ]; then
101 echo "no partial chroot dir detected. attempting to create one"
105 if [ ! -d ${BUILD_DIR} ]; then
109 echo "Building for distro: $dist"
110 echo "Using AC_NDK_PATH: ${AC_NDK_PATH}"
112 additional_repositories="-r http://ppa.launchpad.net/ci-train-ppa-service/stable-phone-overlay/ubuntu"
115 if [ "${dist}" = "vivid" ]; then
119 case ${target_arch} in
121 target_machine=arm-linux-gnueabihf
124 target_machine=x86_64-linux-gnu
127 target_machine=i386-linux-gnu
130 target_machine=aarch64-linux-gnu
133 target_machine=powerpc64le-linux-gnu
136 target_machine=powerpc-linux-gnu
139 # A good guess (assuming you have dpkg-architecture)
140 target_machine=`dpkg-architecture -A${target_arch} -qDEB_HOST_MULTIARCH` || {
141 echo "Unknown architecture ${target_arch}"
148 echo "Target architecture: ${target_arch}"
149 echo "Target machine: ${target_machine}"
151 if [ ${_do_update_chroot} -eq 1 ] ; then
152 pushd scripts > /dev/null
153 ./setup-partial-chroot.sh -d ${dist} -a ${target_arch} ${additional_repositories} ${AC_NDK_PATH}
155 # force a clean build after an update, since CMake cache maybe out of date
156 clean_build_dir ${BUILD_DIR}
159 pushd ${BUILD_DIR} > /dev/null
161 export PKG_CONFIG_PATH="${AC_NDK_PATH}/usr/lib/pkgconfig:${AC_NDK_PATH}/usr/lib/${target_machine}/pkgconfig"
162 export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1
163 export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1
164 export PKG_CONFIG_SYSROOT_DIR=$AC_NDK_PATH
165 export PKG_CONFIG_EXECUTABLE=`which pkg-config`
166 export AC_TARGET_MACHINE=${target_machine}
167 export AC_GCC_VARIANT=${gcc_variant}
168 export LDFLAGS=-Wl,-rpath-link,${AC_NDK_PATH}/usr/lib/${target_machine}/pulseaudio
169 echo "Using PKG_CONFIG_PATH: $PKG_CONFIG_PATH"
170 echo "Using PKG_CONFIG_EXECUTABLE: $PKG_CONFIG_EXECUTABLE"
171 cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/LinuxCrossCompile.cmake \
172 -DCMAKE_BUILD_TYPE=debug \
175 make -j${NUM_JOBS} $@