Merge lp:~morphis/aethercast/support-cross-compile into lp:aethercast

Proposed by Simon Fels
Status: Superseded
Proposed branch: lp:~morphis/aethercast/support-cross-compile
Merge into: lp:aethercast
Diff against target: 539 lines (+401/-16)
9 files modified
cmake/LinuxCrossCompile.cmake (+43/-0)
cross-compile-chroot.sh (+162/-0)
debian/control (+2/-1)
scripts/setup-partial-armhf-chroot.sh (+155/-0)
src/CMakeLists.txt (+14/-15)
src/mcs/basesourcemediamanager.cpp (+12/-0)
src/mcs/basesourcemediamanager.h (+4/-0)
src/mcs/miracastsourceclient.cpp (+8/-0)
src/mcs/miracastsourceclient.h (+1/-0)
To merge this branch: bzr merge lp:~morphis/aethercast/support-cross-compile
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+287441@code.launchpad.net

This proposal has been superseded by a proposal from 2016-02-29.

Commit message

Add cross-compilation support

Description of the change

Add cross-compilation support

To post a comment you must log in.
187. By Simon Fels

Merge trunk

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'cmake/LinuxCrossCompile.cmake'
--- cmake/LinuxCrossCompile.cmake 1970-01-01 00:00:00 +0000
+++ cmake/LinuxCrossCompile.cmake 2016-02-29 08:26:24 +0000
@@ -0,0 +1,43 @@
1set(CMAKE_SYSTEM_NAME Linux)
2set(CMAKE_SYSTEM_VERSION 1)
3
4set(AC_NDK_PATH $ENV{AC_NDK_PATH} CACHE STRING "path of mir android bundle")
5
6if (NOT DEFINED AC_TARGET_MACHINE)
7 set(AC_TARGET_MACHINE $ENV{AC_TARGET_MACHINE} CACHE STRING "target machine")
8endif()
9if (NOT DEFINED AC_GCC_VARIANT)
10 set(AC_GCC_VARIANT $ENV{AC_GCC_VARIANT} CACHE STRING "gcc variant required")
11endif()
12
13set(CMAKE_C_COMPILER /usr/bin/${AC_TARGET_MACHINE}-gcc${AC_GCC_VARIANT})
14set(CMAKE_CXX_COMPILER /usr/bin/${AC_TARGET_MACHINE}-g++${AC_GCC_VARIANT})
15
16# where to look to find dependencies in the target environment
17set(CMAKE_FIND_ROOT_PATH "${AC_NDK_PATH}")
18
19#treat the chroot's includes as system includes
20include_directories(SYSTEM "${AC_NDK_PATH}/usr/include" "${AC_NDK_PATH}/usr/include/${AC_TARGET_MACHINE}")
21list(APPEND CMAKE_SYSTEM_INCLUDE_PATH "${AC_NDK_PATH}/usr/include" "${AC_NDK_PATH}/usr/include/${AC_TARGET_MACHINE}" )
22
23# Add the chroot libraries as system libraries
24list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
25 "${AC_NDK_PATH}/lib"
26 "${AC_NDK_PATH}/lib/${AC_TARGET_MACHINE}"
27 "${AC_NDK_PATH}/usr/lib"
28 "${AC_NDK_PATH}/usr/lib/${AC_TARGET_MACHINE}"
29)
30
31set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
32set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
33set(CMAKE_EXECUTABLE_RUNTIME_C_FLAG "-Wl,-rpath-link,")
34set(CMAKE_EXECUTABLE_RUNTIME_CXX_FLAG "-Wl,-rpath-link,")
35set(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}")
36
37set(ENV{PKG_CONFIG_PATH} "${AC_NDK_PATH}/usr/lib/pkgconfig:${AC_NDK_PATH}/usr/lib/${AC_TARGET_MACHINE}/pkgconfig")
38set(ENV{PKG_CONFIG_SYSROOT_DIR} "${AC_NDK_PATH}")
39
40#use only the cross compile system
41set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
42set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
43set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
044
=== added file 'cross-compile-chroot.sh'
--- cross-compile-chroot.sh 1970-01-01 00:00:00 +0000
+++ cross-compile-chroot.sh 2016-02-29 08:26:24 +0000
@@ -0,0 +1,162 @@
1#!/bin/bash
2# build script to compile Aethercast for armhf devices
3#
4set -e
5
6usage() {
7 echo "usage: $(basename $0) [-a <arch>] [-c] [-h] [-d <dist>] [-u]"
8 echo " -a <arch> Specify target architecture (armhf/arm64/powerpc/ppc64el/amd64/i386/host)"
9 echo " -c Clean before building"
10 echo " -d <dist> Select the distribution to build for (vivid/wily/xenial)"
11 echo " -h This message"
12 echo " -u Update partial chroot directory"
13}
14
15clean_build_dir() {
16 rm -rf ${1}
17 mkdir ${1}
18}
19
20# Default to a dist-agnostic directory name so as to not break Jenkins right now
21BUILD_DIR=build-android-arm
22NUM_JOBS=$(( $(grep -c ^processor /proc/cpuinfo) + 1 ))
23_do_update_chroot=0
24
25# Default to vivid as we don't seem to have any working wily devices right now
26dist=vivid
27clean=0
28update_build_dir=0
29
30target_arch=armhf
31
32while getopts "a:cd:hu" OPTNAME
33do
34 case $OPTNAME in
35 a )
36 target_arch=${OPTARG}
37 update_build_dir=1
38 ;;
39 c )
40 clean=1
41 ;;
42 d )
43 dist=${OPTARG}
44 update_build_dir=1
45 ;;
46 u )
47 _do_update_chroot=1
48 ;;
49 h )
50 usage
51 exit 0
52 ;;
53 : )
54 echo "Parameter -${OPTARG} needs an argument"
55 usage
56 exit 1;
57 ;;
58 * )
59 echo "invalid option specified"
60 usage
61 exit 1
62 ;;
63 esac
64done
65
66shift $((${OPTIND}-1))
67
68if [ "${target_arch}" = "host" ]; then
69 target_arch=`dpkg-architecture -qDEB_HOST_ARCH`
70fi
71
72if [ ${clean} -ne 0 ]; then
73 clean_build_dir ${BUILD_DIR}
74fi
75
76if [ ${update_build_dir} -eq 1 ]; then
77 BUILD_DIR=build-${target_arch}-${dist}
78fi
79
80if [ "${AC_NDK_PATH}" = "" ]; then
81 export AC_NDK_PATH=~/.cache/aethercast-${target_arch}-chroot-${dist}
82fi
83
84if [ ! -d ${AC_NDK_PATH} ]; then
85 echo "no partial chroot dir detected. attempting to create one"
86 _do_update_chroot=1
87fi
88
89if [ ! -d ${BUILD_DIR} ]; then
90 mkdir ${BUILD_DIR}
91fi
92
93echo "Building for distro: $dist"
94echo "Using AC_NDK_PATH: ${AC_NDK_PATH}"
95
96additional_repositories=
97if [ ${dist} == "vivid" ] ; then
98 additional_repositories="-r http://ppa.launchpad.net/ci-train-ppa-service/stable-phone-overlay/ubuntu -r http://ppa.launchpad.net/ci-train-ppa-service/landing-000/ubuntu"
99fi
100
101gcc_variant=
102if [ "${dist}" = "vivid" ]; then
103 gcc_variant=-4.9
104fi
105
106case ${target_arch} in
107 armhf )
108 target_machine=arm-linux-gnueabihf
109 ;;
110 amd64 )
111 target_machine=x86_64-linux-gnu
112 ;;
113 i386 )
114 target_machine=i386-linux-gnu
115 ;;
116 arm64 )
117 target_machine=aarch64-linux-gnu
118 ;;
119 ppc64el )
120 target_machine=powerpc64le-linux-gnu
121 ;;
122 powerpc )
123 target_machine=powerpc-linux-gnu
124 ;;
125 * )
126 # A good guess (assuming you have dpkg-architecture)
127 target_machine=`dpkg-architecture -A${target_arch} -qDEB_HOST_MULTIARCH` || {
128 echo "Unknown architecture ${target_arch}"
129 usage
130 exit 1
131 }
132 ;;
133esac
134
135echo "Target architecture: ${target_arch}"
136echo "Target machine: ${target_machine}"
137
138if [ ${_do_update_chroot} -eq 1 ] ; then
139 pushd scripts > /dev/null
140 ./setup-partial-armhf-chroot.sh -d ${dist} -a ${target_arch} ${additional_repositories} ${AC_NDK_PATH}
141 popd > /dev/null
142 # force a clean build after an update, since CMake cache maybe out of date
143 clean_build_dir ${BUILD_DIR}
144fi
145
146pushd ${BUILD_DIR} > /dev/null
147
148 export PKG_CONFIG_PATH="${AC_NDK_PATH}/usr/lib/pkgconfig:${AC_NDK_PATH}/usr/lib/${target_machine}/pkgconfig"
149 export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1
150 export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1
151 export PKG_CONFIG_SYSROOT_DIR=$AC_NDK_PATH
152 export PKG_CONFIG_EXECUTABLE=`which pkg-config`
153 export AC_TARGET_MACHINE=${target_machine}
154 export AC_GCC_VARIANT=${gcc_variant}
155 echo "Using PKG_CONFIG_PATH: $PKG_CONFIG_PATH"
156 echo "Using PKG_CONFIG_EXECUTABLE: $PKG_CONFIG_EXECUTABLE"
157 cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/LinuxCrossCompile.cmake \
158 ..
159
160 make -j${NUM_JOBS} $@
161
162popd > /dev/null
0163
=== modified file 'debian/control'
--- debian/control 2016-01-21 11:13:32 +0000
+++ debian/control 2016-02-29 08:26:24 +0000
@@ -20,7 +20,8 @@
20 libgtest-dev,20 libgtest-dev,
21 libreadline-dev,21 libreadline-dev,
22 libreadline6-dev,22 libreadline6-dev,
23 libwds-dev23 libwds-dev,
24 pkg-config
24Standards-Version: 3.9.425Standards-Version: 3.9.4
25Homepage: http://launchpad.net/aethercast26Homepage: http://launchpad.net/aethercast
26# If you aren't a member of ~phablet-team but need to upload packaging changes,27# If you aren't a member of ~phablet-team but need to upload packaging changes,
2728
=== added directory 'scripts'
=== added file 'scripts/setup-partial-armhf-chroot.sh'
--- scripts/setup-partial-armhf-chroot.sh 1970-01-01 00:00:00 +0000
+++ scripts/setup-partial-armhf-chroot.sh 2016-02-29 08:26:24 +0000
@@ -0,0 +1,155 @@
1#!/bin/bash
2#
3# TODO: Rename this file without "armhf" when it's safe to do so.
4#
5
6set -e
7
8name=${0}
9
10usage() {
11 echo "Usage: ${name} [options] mychroot-dir"
12 echo "options:"
13 echo " -a arch Select architecture, i.e. armhf, arm64, ppc... Default is armhf"
14 echo " -d dist Select distribution, i.e. vivid, wily. Default is vivid"
15 echo " -r rep Select an additional repository for bootstrap. Default is none"
16 echo
17 echo "please supply at least a directory to create partial chroot in. (eg, ./setup-partial-armhf-chroot.sh mychroot-dir)"
18}
19
20# Default to vivid as we don't seem to have any working wily devices right now.
21# Also Jenkins expects this script to default to vivid (TODO: update CI?)
22arch=armhf
23dist=vivid
24sourceid=0
25repositories=
26sources=
27
28while getopts a:d:r:h opt; do
29 case $opt in
30 a)
31 arch=$OPTARG
32 ;;
33 d)
34 dist=$OPTARG
35 ;;
36 r)
37 repositories="$repositories $OPTARG"
38 ((++sourceid))
39 sources="$sources source$sourceid"
40 ;;
41 :)
42 echo "Option -$OPTARG requires an argument"
43 usage
44 exit 1
45 ;;
46 h)
47 usage
48 exit 0
49 ;;
50 \?)
51 echo "Invalid option: -$OPTARG"
52 usage
53 exit 1
54 ;;
55 esac
56done
57
58shift $((OPTIND-1))
59
60if [ -z ${1} ]; then
61 usage
62 exit 1
63fi
64
65directory=${1}
66echo "creating phablet-compatible $arch partial chroot for aethercast compilation in directory ${directory}"
67
68if [ ! -d ${directory} ]; then
69 mkdir -p ${directory}
70fi
71
72DEBCONTROL=$(pwd)/../debian/control
73
74pushd ${directory} > /dev/null
75
76# Empty dpkg status file, so that ALL dependencies are listed with dpkg-checkbuilddeps
77echo "" > status
78
79# Manual error code checking is needed for dpkg-checkbuilddeps
80set +e
81
82# Parse dependencies from debian/control
83# dpkg-checkbuilddeps returns non-zero when dependencies are not met and the list is sent to stderr
84builddeps=$(dpkg-checkbuilddeps -a ${arch} --admindir=. ${DEBCONTROL} 2>&1 )
85if [ $? -eq 0 ] ; then
86 exit 0
87fi
88echo "${builddeps}"
89
90# now turn exit on error option
91set -e
92
93# Sanitize dependencies list for submission to multistrap
94# build-essential is not needed as we are cross-compiling
95builddeps=$(echo ${builddeps} | sed -e 's/dpkg-checkbuilddeps://g' \
96 -e 's/error://g' \
97 -e 's/Unmet build dependencies://g' \
98 -e 's/build-essential:native//g')
99builddeps=$(echo ${builddeps} | sed 's/([^)]*)//g')
100builddeps=$(echo ${builddeps} | sed -e 's/abi-compliance-checker//g')
101builddeps=$(echo ${builddeps} | sed -e 's/multistrap//g')
102
103case ${arch} in
104 amd64 | i386 )
105 source_url=http://archive.ubuntu.com/ubuntu
106 ;;
107 * )
108 source_url=http://ports.ubuntu.com/ubuntu-ports
109 ;;
110esac
111
112echo "[General]
113arch=${arch}
114directory=${directory}
115unpack=false
116noauth=true
117bootstrap=Ubuntu ${sources}
118
119[Ubuntu]
120packages=${builddeps}
121source=${source_url}
122suite=${dist}
123" > mstrap.conf
124
125sourceid=0
126for x in ${repositories};
127do
128 ((++sourceid))
129 echo "[source${sourceid}]
130source=${x}
131suite=${dist}
132" >> mstrap.conf
133done
134
135multistrap -f mstrap.conf
136
137rm -f var/cache/apt/archives/lock
138
139# Remove libc libraries that confuse the cross-compiler
140rm -f var/cache/apt/archives/libc-dev*.deb
141rm -f var/cache/apt/archives/libc6*.deb
142
143for deb in var/cache/apt/archives/* ; do
144 if [ ! -d ${deb} ] ; then
145 echo "unpacking: ${deb}"
146 dpkg -x ${deb} .
147 fi
148done
149
150# Fix up symlinks which asssumed the usual root path
151for broken_symlink in $(find . -name \*.so -type l -xtype l) ; do
152 ln -sf $(pwd)$(readlink ${broken_symlink}) ${broken_symlink}
153done
154
155popd > /dev/null
0156
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2016-01-21 13:25:31 +0000
+++ src/CMakeLists.txt 2016-02-29 08:26:24 +0000
@@ -27,15 +27,15 @@
27configure_file(w11tng/config.h.in w11tng/config.h @ONLY)27configure_file(w11tng/config.h.in w11tng/config.h @ONLY)
2828
29set(HEADERS29set(HEADERS
30 mcs/ip_v4_address.h30 mcs/ip_v4_address.h
31 mcs/keep_alive.h31 mcs/keep_alive.h
32 mcs/mac_address.h32 mcs/mac_address.h
33 mcs/types.h33 mcs/types.h
34 mcs/shared_gobject.h34 mcs/shared_gobject.h
35 mcs/keep_alive.h35 mcs/keep_alive.h
36 mcs/config.h
3637
37 mcs/config.h38 w11tng/config.h
38 w11tng/config.h
39)39)
4040
41set(SOURCES41set(SOURCES
@@ -83,13 +83,6 @@
83 w11tng/hostname1stub.cpp83 w11tng/hostname1stub.cpp
84)84)
8585
86link_directories(
87 ${GLIB_LIBRARY_DIRS}
88 ${GIO_LIBRARY_DIRS}
89 ${GIO-UNIX_LIBRARY_DIRS}
90 ${WDS_LIBRARY_DIRS}
91)
92
93include_directories(86include_directories(
94 ${Boost_INCLUDE_DIRS}87 ${Boost_INCLUDE_DIRS}
95 ${GLIB_INCLUDE_DIRS}88 ${GLIB_INCLUDE_DIRS}
@@ -106,12 +99,18 @@
106add_executable(aethercast mcs/main.cpp)99add_executable(aethercast mcs/main.cpp)
107100
108target_link_libraries(aethercast-core101target_link_libraries(aethercast-core
102 ${Boost_LDFLAGS}
109 ${Boost_LIBRARIES}103 ${Boost_LIBRARIES}
104 ${GLIB_LDFLAGS}
110 ${GLIB_LIBRARIES}105 ${GLIB_LIBRARIES}
106 ${GIO_LDFLAGS}
111 ${GIO_LIBRARIES}107 ${GIO_LIBRARIES}
108 ${GIO-UNIX_LDFLAGS}
112 ${GIO-UNIX_LIBRARIES}109 ${GIO-UNIX_LIBRARIES}
110 ${GST_LDFLAGS}
113 ${GST_LIBRARIES}111 ${GST_LIBRARIES}
114 ${CMAKE_THREAD_LIBS_INIT}112 ${CMAKE_THREAD_LIBS_INIT}
113 ${WDS_LDFLAGS}
115 ${WDS_LIBRARIES}114 ${WDS_LIBRARIES}
116 -ldl115 -ldl
117)116)
118117
=== modified file 'src/mcs/basesourcemediamanager.cpp'
--- src/mcs/basesourcemediamanager.cpp 2015-12-07 16:02:43 +0000
+++ src/mcs/basesourcemediamanager.cpp 2016-02-29 08:26:24 +0000
@@ -20,7 +20,15 @@
20#include "basesourcemediamanager.h"20#include "basesourcemediamanager.h"
21#include "logger.h"21#include "logger.h"
2222
23namespace {
24static unsigned int next_session_id = 0;
25}
26
23namespace mcs {27namespace mcs {
28BaseSourceMediaManager::BaseSourceMediaManager() :
29 session_id_(++next_session_id) {
30}
31
24wds::SessionType BaseSourceMediaManager::GetSessionType() const {32wds::SessionType BaseSourceMediaManager::GetSessionType() const {
25 return wds::VideoSession;33 return wds::VideoSession;
26}34}
@@ -102,4 +110,8 @@
102void BaseSourceMediaManager::SendIDRPicture() {110void BaseSourceMediaManager::SendIDRPicture() {
103 WARNING("Unimplemented IDR picture request");111 WARNING("Unimplemented IDR picture request");
104}112}
113
114std::string BaseSourceMediaManager::GetSessionId() const {
115 return mcs::Utils::Sprintf("%d", session_id_);
116}
105} // namespace mcs117} // namespace mcs
106118
=== modified file 'src/mcs/basesourcemediamanager.h'
--- src/mcs/basesourcemediamanager.h 2015-11-26 16:48:53 +0000
+++ src/mcs/basesourcemediamanager.h 2016-02-29 08:26:24 +0000
@@ -24,6 +24,8 @@
24class BaseSourceMediaManager : public wds::SourceMediaManager24class BaseSourceMediaManager : public wds::SourceMediaManager
25{25{
26public:26public:
27 explicit BaseSourceMediaManager();
28
27 void SetSinkRtpPorts(int port1, int port2) override;29 void SetSinkRtpPorts(int port1, int port2) override;
28 std::pair<int,int> GetSinkRtpPorts() const override;30 std::pair<int,int> GetSinkRtpPorts() const override;
29 int GetLocalRtpPort() const override;31 int GetLocalRtpPort() const override;
@@ -35,6 +37,7 @@
35 bool InitOptimalAudioFormat(const std::vector<wds::AudioCodec>& sink_supported_codecs) override;37 bool InitOptimalAudioFormat(const std::vector<wds::AudioCodec>& sink_supported_codecs) override;
36 wds::AudioCodec GetOptimalAudioFormat() const override;38 wds::AudioCodec GetOptimalAudioFormat() const override;
37 void SendIDRPicture() override;39 void SendIDRPicture() override;
40 std::string GetSessionId() const override;
3841
39protected:42protected:
40 virtual void Configure() = 0;43 virtual void Configure() = 0;
@@ -43,6 +46,7 @@
43 int sink_port1_;46 int sink_port1_;
44 int sink_port2_;47 int sink_port2_;
45 wds::H264VideoFormat format_;48 wds::H264VideoFormat format_;
49 unsigned int session_id_;
46};50};
47} // namespace mcs51} // namespace mcs
48#endif52#endif
4953
=== modified file 'src/mcs/miracastsourceclient.cpp'
--- src/mcs/miracastsourceclient.cpp 2015-12-09 16:07:13 +0000
+++ src/mcs/miracastsourceclient.cpp 2016-02-29 08:26:24 +0000
@@ -85,6 +85,14 @@
85 return local_address_;85 return local_address_;
86}86}
8787
88int MiracastSourceClient::GetNextCSeq(int *initial_peer_cseq) const {
89 static int send_cseq = 0;
90 ++send_cseq;
91 if (initial_peer_cseq && send_cseq == *initial_peer_cseq)
92 send_cseq *= 2;
93 return send_cseq;
94}
95
88class TimerCallbackData {96class TimerCallbackData {
89public:97public:
90 TimerCallbackData(MiracastSourceClient *delegate) :98 TimerCallbackData(MiracastSourceClient *delegate) :
9199
=== modified file 'src/mcs/miracastsourceclient.h'
--- src/mcs/miracastsourceclient.h 2015-12-07 09:07:50 +0000
+++ src/mcs/miracastsourceclient.h 2016-02-29 08:26:24 +0000
@@ -57,6 +57,7 @@
57 std::string GetLocalIPAddress() const override;57 std::string GetLocalIPAddress() const override;
58 uint CreateTimer(int seconds) override;58 uint CreateTimer(int seconds) override;
59 void ReleaseTimer(uint timerId) override;59 void ReleaseTimer(uint timerId) override;
60 int GetNextCSeq(int* initial_peer_cseq = nullptr) const override;
6061
61public:62public:
62 static gboolean OnTimeout(gpointer user_data);63 static gboolean OnTimeout(gpointer user_data);

Subscribers

People subscribed via source and target branches

to all changes: