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
1=== added file 'cmake/LinuxCrossCompile.cmake'
2--- cmake/LinuxCrossCompile.cmake 1970-01-01 00:00:00 +0000
3+++ cmake/LinuxCrossCompile.cmake 2016-02-29 08:26:24 +0000
4@@ -0,0 +1,43 @@
5+set(CMAKE_SYSTEM_NAME Linux)
6+set(CMAKE_SYSTEM_VERSION 1)
7+
8+set(AC_NDK_PATH $ENV{AC_NDK_PATH} CACHE STRING "path of mir android bundle")
9+
10+if (NOT DEFINED AC_TARGET_MACHINE)
11+ set(AC_TARGET_MACHINE $ENV{AC_TARGET_MACHINE} CACHE STRING "target machine")
12+endif()
13+if (NOT DEFINED AC_GCC_VARIANT)
14+ set(AC_GCC_VARIANT $ENV{AC_GCC_VARIANT} CACHE STRING "gcc variant required")
15+endif()
16+
17+set(CMAKE_C_COMPILER /usr/bin/${AC_TARGET_MACHINE}-gcc${AC_GCC_VARIANT})
18+set(CMAKE_CXX_COMPILER /usr/bin/${AC_TARGET_MACHINE}-g++${AC_GCC_VARIANT})
19+
20+# where to look to find dependencies in the target environment
21+set(CMAKE_FIND_ROOT_PATH "${AC_NDK_PATH}")
22+
23+#treat the chroot's includes as system includes
24+include_directories(SYSTEM "${AC_NDK_PATH}/usr/include" "${AC_NDK_PATH}/usr/include/${AC_TARGET_MACHINE}")
25+list(APPEND CMAKE_SYSTEM_INCLUDE_PATH "${AC_NDK_PATH}/usr/include" "${AC_NDK_PATH}/usr/include/${AC_TARGET_MACHINE}" )
26+
27+# Add the chroot libraries as system libraries
28+list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
29+ "${AC_NDK_PATH}/lib"
30+ "${AC_NDK_PATH}/lib/${AC_TARGET_MACHINE}"
31+ "${AC_NDK_PATH}/usr/lib"
32+ "${AC_NDK_PATH}/usr/lib/${AC_TARGET_MACHINE}"
33+)
34+
35+set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
36+set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
37+set(CMAKE_EXECUTABLE_RUNTIME_C_FLAG "-Wl,-rpath-link,")
38+set(CMAKE_EXECUTABLE_RUNTIME_CXX_FLAG "-Wl,-rpath-link,")
39+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}")
40+
41+set(ENV{PKG_CONFIG_PATH} "${AC_NDK_PATH}/usr/lib/pkgconfig:${AC_NDK_PATH}/usr/lib/${AC_TARGET_MACHINE}/pkgconfig")
42+set(ENV{PKG_CONFIG_SYSROOT_DIR} "${AC_NDK_PATH}")
43+
44+#use only the cross compile system
45+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
46+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
47+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
48
49=== added file 'cross-compile-chroot.sh'
50--- cross-compile-chroot.sh 1970-01-01 00:00:00 +0000
51+++ cross-compile-chroot.sh 2016-02-29 08:26:24 +0000
52@@ -0,0 +1,162 @@
53+#!/bin/bash
54+# build script to compile Aethercast for armhf devices
55+#
56+set -e
57+
58+usage() {
59+ echo "usage: $(basename $0) [-a <arch>] [-c] [-h] [-d <dist>] [-u]"
60+ echo " -a <arch> Specify target architecture (armhf/arm64/powerpc/ppc64el/amd64/i386/host)"
61+ echo " -c Clean before building"
62+ echo " -d <dist> Select the distribution to build for (vivid/wily/xenial)"
63+ echo " -h This message"
64+ echo " -u Update partial chroot directory"
65+}
66+
67+clean_build_dir() {
68+ rm -rf ${1}
69+ mkdir ${1}
70+}
71+
72+# Default to a dist-agnostic directory name so as to not break Jenkins right now
73+BUILD_DIR=build-android-arm
74+NUM_JOBS=$(( $(grep -c ^processor /proc/cpuinfo) + 1 ))
75+_do_update_chroot=0
76+
77+# Default to vivid as we don't seem to have any working wily devices right now
78+dist=vivid
79+clean=0
80+update_build_dir=0
81+
82+target_arch=armhf
83+
84+while getopts "a:cd:hu" OPTNAME
85+do
86+ case $OPTNAME in
87+ a )
88+ target_arch=${OPTARG}
89+ update_build_dir=1
90+ ;;
91+ c )
92+ clean=1
93+ ;;
94+ d )
95+ dist=${OPTARG}
96+ update_build_dir=1
97+ ;;
98+ u )
99+ _do_update_chroot=1
100+ ;;
101+ h )
102+ usage
103+ exit 0
104+ ;;
105+ : )
106+ echo "Parameter -${OPTARG} needs an argument"
107+ usage
108+ exit 1;
109+ ;;
110+ * )
111+ echo "invalid option specified"
112+ usage
113+ exit 1
114+ ;;
115+ esac
116+done
117+
118+shift $((${OPTIND}-1))
119+
120+if [ "${target_arch}" = "host" ]; then
121+ target_arch=`dpkg-architecture -qDEB_HOST_ARCH`
122+fi
123+
124+if [ ${clean} -ne 0 ]; then
125+ clean_build_dir ${BUILD_DIR}
126+fi
127+
128+if [ ${update_build_dir} -eq 1 ]; then
129+ BUILD_DIR=build-${target_arch}-${dist}
130+fi
131+
132+if [ "${AC_NDK_PATH}" = "" ]; then
133+ export AC_NDK_PATH=~/.cache/aethercast-${target_arch}-chroot-${dist}
134+fi
135+
136+if [ ! -d ${AC_NDK_PATH} ]; then
137+ echo "no partial chroot dir detected. attempting to create one"
138+ _do_update_chroot=1
139+fi
140+
141+if [ ! -d ${BUILD_DIR} ]; then
142+ mkdir ${BUILD_DIR}
143+fi
144+
145+echo "Building for distro: $dist"
146+echo "Using AC_NDK_PATH: ${AC_NDK_PATH}"
147+
148+additional_repositories=
149+if [ ${dist} == "vivid" ] ; then
150+ 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"
151+fi
152+
153+gcc_variant=
154+if [ "${dist}" = "vivid" ]; then
155+ gcc_variant=-4.9
156+fi
157+
158+case ${target_arch} in
159+ armhf )
160+ target_machine=arm-linux-gnueabihf
161+ ;;
162+ amd64 )
163+ target_machine=x86_64-linux-gnu
164+ ;;
165+ i386 )
166+ target_machine=i386-linux-gnu
167+ ;;
168+ arm64 )
169+ target_machine=aarch64-linux-gnu
170+ ;;
171+ ppc64el )
172+ target_machine=powerpc64le-linux-gnu
173+ ;;
174+ powerpc )
175+ target_machine=powerpc-linux-gnu
176+ ;;
177+ * )
178+ # A good guess (assuming you have dpkg-architecture)
179+ target_machine=`dpkg-architecture -A${target_arch} -qDEB_HOST_MULTIARCH` || {
180+ echo "Unknown architecture ${target_arch}"
181+ usage
182+ exit 1
183+ }
184+ ;;
185+esac
186+
187+echo "Target architecture: ${target_arch}"
188+echo "Target machine: ${target_machine}"
189+
190+if [ ${_do_update_chroot} -eq 1 ] ; then
191+ pushd scripts > /dev/null
192+ ./setup-partial-armhf-chroot.sh -d ${dist} -a ${target_arch} ${additional_repositories} ${AC_NDK_PATH}
193+ popd > /dev/null
194+ # force a clean build after an update, since CMake cache maybe out of date
195+ clean_build_dir ${BUILD_DIR}
196+fi
197+
198+pushd ${BUILD_DIR} > /dev/null
199+
200+ export PKG_CONFIG_PATH="${AC_NDK_PATH}/usr/lib/pkgconfig:${AC_NDK_PATH}/usr/lib/${target_machine}/pkgconfig"
201+ export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1
202+ export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1
203+ export PKG_CONFIG_SYSROOT_DIR=$AC_NDK_PATH
204+ export PKG_CONFIG_EXECUTABLE=`which pkg-config`
205+ export AC_TARGET_MACHINE=${target_machine}
206+ export AC_GCC_VARIANT=${gcc_variant}
207+ echo "Using PKG_CONFIG_PATH: $PKG_CONFIG_PATH"
208+ echo "Using PKG_CONFIG_EXECUTABLE: $PKG_CONFIG_EXECUTABLE"
209+ cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/LinuxCrossCompile.cmake \
210+ ..
211+
212+ make -j${NUM_JOBS} $@
213+
214+popd > /dev/null
215
216=== modified file 'debian/control'
217--- debian/control 2016-01-21 11:13:32 +0000
218+++ debian/control 2016-02-29 08:26:24 +0000
219@@ -20,7 +20,8 @@
220 libgtest-dev,
221 libreadline-dev,
222 libreadline6-dev,
223- libwds-dev
224+ libwds-dev,
225+ pkg-config
226 Standards-Version: 3.9.4
227 Homepage: http://launchpad.net/aethercast
228 # If you aren't a member of ~phablet-team but need to upload packaging changes,
229
230=== added directory 'scripts'
231=== added file 'scripts/setup-partial-armhf-chroot.sh'
232--- scripts/setup-partial-armhf-chroot.sh 1970-01-01 00:00:00 +0000
233+++ scripts/setup-partial-armhf-chroot.sh 2016-02-29 08:26:24 +0000
234@@ -0,0 +1,155 @@
235+#!/bin/bash
236+#
237+# TODO: Rename this file without "armhf" when it's safe to do so.
238+#
239+
240+set -e
241+
242+name=${0}
243+
244+usage() {
245+ echo "Usage: ${name} [options] mychroot-dir"
246+ echo "options:"
247+ echo " -a arch Select architecture, i.e. armhf, arm64, ppc... Default is armhf"
248+ echo " -d dist Select distribution, i.e. vivid, wily. Default is vivid"
249+ echo " -r rep Select an additional repository for bootstrap. Default is none"
250+ echo
251+ echo "please supply at least a directory to create partial chroot in. (eg, ./setup-partial-armhf-chroot.sh mychroot-dir)"
252+}
253+
254+# Default to vivid as we don't seem to have any working wily devices right now.
255+# Also Jenkins expects this script to default to vivid (TODO: update CI?)
256+arch=armhf
257+dist=vivid
258+sourceid=0
259+repositories=
260+sources=
261+
262+while getopts a:d:r:h opt; do
263+ case $opt in
264+ a)
265+ arch=$OPTARG
266+ ;;
267+ d)
268+ dist=$OPTARG
269+ ;;
270+ r)
271+ repositories="$repositories $OPTARG"
272+ ((++sourceid))
273+ sources="$sources source$sourceid"
274+ ;;
275+ :)
276+ echo "Option -$OPTARG requires an argument"
277+ usage
278+ exit 1
279+ ;;
280+ h)
281+ usage
282+ exit 0
283+ ;;
284+ \?)
285+ echo "Invalid option: -$OPTARG"
286+ usage
287+ exit 1
288+ ;;
289+ esac
290+done
291+
292+shift $((OPTIND-1))
293+
294+if [ -z ${1} ]; then
295+ usage
296+ exit 1
297+fi
298+
299+directory=${1}
300+echo "creating phablet-compatible $arch partial chroot for aethercast compilation in directory ${directory}"
301+
302+if [ ! -d ${directory} ]; then
303+ mkdir -p ${directory}
304+fi
305+
306+DEBCONTROL=$(pwd)/../debian/control
307+
308+pushd ${directory} > /dev/null
309+
310+# Empty dpkg status file, so that ALL dependencies are listed with dpkg-checkbuilddeps
311+echo "" > status
312+
313+# Manual error code checking is needed for dpkg-checkbuilddeps
314+set +e
315+
316+# Parse dependencies from debian/control
317+# dpkg-checkbuilddeps returns non-zero when dependencies are not met and the list is sent to stderr
318+builddeps=$(dpkg-checkbuilddeps -a ${arch} --admindir=. ${DEBCONTROL} 2>&1 )
319+if [ $? -eq 0 ] ; then
320+ exit 0
321+fi
322+echo "${builddeps}"
323+
324+# now turn exit on error option
325+set -e
326+
327+# Sanitize dependencies list for submission to multistrap
328+# build-essential is not needed as we are cross-compiling
329+builddeps=$(echo ${builddeps} | sed -e 's/dpkg-checkbuilddeps://g' \
330+ -e 's/error://g' \
331+ -e 's/Unmet build dependencies://g' \
332+ -e 's/build-essential:native//g')
333+builddeps=$(echo ${builddeps} | sed 's/([^)]*)//g')
334+builddeps=$(echo ${builddeps} | sed -e 's/abi-compliance-checker//g')
335+builddeps=$(echo ${builddeps} | sed -e 's/multistrap//g')
336+
337+case ${arch} in
338+ amd64 | i386 )
339+ source_url=http://archive.ubuntu.com/ubuntu
340+ ;;
341+ * )
342+ source_url=http://ports.ubuntu.com/ubuntu-ports
343+ ;;
344+esac
345+
346+echo "[General]
347+arch=${arch}
348+directory=${directory}
349+unpack=false
350+noauth=true
351+bootstrap=Ubuntu ${sources}
352+
353+[Ubuntu]
354+packages=${builddeps}
355+source=${source_url}
356+suite=${dist}
357+" > mstrap.conf
358+
359+sourceid=0
360+for x in ${repositories};
361+do
362+ ((++sourceid))
363+ echo "[source${sourceid}]
364+source=${x}
365+suite=${dist}
366+" >> mstrap.conf
367+done
368+
369+multistrap -f mstrap.conf
370+
371+rm -f var/cache/apt/archives/lock
372+
373+# Remove libc libraries that confuse the cross-compiler
374+rm -f var/cache/apt/archives/libc-dev*.deb
375+rm -f var/cache/apt/archives/libc6*.deb
376+
377+for deb in var/cache/apt/archives/* ; do
378+ if [ ! -d ${deb} ] ; then
379+ echo "unpacking: ${deb}"
380+ dpkg -x ${deb} .
381+ fi
382+done
383+
384+# Fix up symlinks which asssumed the usual root path
385+for broken_symlink in $(find . -name \*.so -type l -xtype l) ; do
386+ ln -sf $(pwd)$(readlink ${broken_symlink}) ${broken_symlink}
387+done
388+
389+popd > /dev/null
390
391=== modified file 'src/CMakeLists.txt'
392--- src/CMakeLists.txt 2016-01-21 13:25:31 +0000
393+++ src/CMakeLists.txt 2016-02-29 08:26:24 +0000
394@@ -27,15 +27,15 @@
395 configure_file(w11tng/config.h.in w11tng/config.h @ONLY)
396
397 set(HEADERS
398- mcs/ip_v4_address.h
399- mcs/keep_alive.h
400- mcs/mac_address.h
401- mcs/types.h
402- mcs/shared_gobject.h
403- mcs/keep_alive.h
404+ mcs/ip_v4_address.h
405+ mcs/keep_alive.h
406+ mcs/mac_address.h
407+ mcs/types.h
408+ mcs/shared_gobject.h
409+ mcs/keep_alive.h
410+ mcs/config.h
411
412- mcs/config.h
413- w11tng/config.h
414+ w11tng/config.h
415 )
416
417 set(SOURCES
418@@ -83,13 +83,6 @@
419 w11tng/hostname1stub.cpp
420 )
421
422-link_directories(
423- ${GLIB_LIBRARY_DIRS}
424- ${GIO_LIBRARY_DIRS}
425- ${GIO-UNIX_LIBRARY_DIRS}
426- ${WDS_LIBRARY_DIRS}
427-)
428-
429 include_directories(
430 ${Boost_INCLUDE_DIRS}
431 ${GLIB_INCLUDE_DIRS}
432@@ -106,12 +99,18 @@
433 add_executable(aethercast mcs/main.cpp)
434
435 target_link_libraries(aethercast-core
436+ ${Boost_LDFLAGS}
437 ${Boost_LIBRARIES}
438+ ${GLIB_LDFLAGS}
439 ${GLIB_LIBRARIES}
440+ ${GIO_LDFLAGS}
441 ${GIO_LIBRARIES}
442+ ${GIO-UNIX_LDFLAGS}
443 ${GIO-UNIX_LIBRARIES}
444+ ${GST_LDFLAGS}
445 ${GST_LIBRARIES}
446 ${CMAKE_THREAD_LIBS_INIT}
447+ ${WDS_LDFLAGS}
448 ${WDS_LIBRARIES}
449 -ldl
450 )
451
452=== modified file 'src/mcs/basesourcemediamanager.cpp'
453--- src/mcs/basesourcemediamanager.cpp 2015-12-07 16:02:43 +0000
454+++ src/mcs/basesourcemediamanager.cpp 2016-02-29 08:26:24 +0000
455@@ -20,7 +20,15 @@
456 #include "basesourcemediamanager.h"
457 #include "logger.h"
458
459+namespace {
460+static unsigned int next_session_id = 0;
461+}
462+
463 namespace mcs {
464+BaseSourceMediaManager::BaseSourceMediaManager() :
465+ session_id_(++next_session_id) {
466+}
467+
468 wds::SessionType BaseSourceMediaManager::GetSessionType() const {
469 return wds::VideoSession;
470 }
471@@ -102,4 +110,8 @@
472 void BaseSourceMediaManager::SendIDRPicture() {
473 WARNING("Unimplemented IDR picture request");
474 }
475+
476+std::string BaseSourceMediaManager::GetSessionId() const {
477+ return mcs::Utils::Sprintf("%d", session_id_);
478+}
479 } // namespace mcs
480
481=== modified file 'src/mcs/basesourcemediamanager.h'
482--- src/mcs/basesourcemediamanager.h 2015-11-26 16:48:53 +0000
483+++ src/mcs/basesourcemediamanager.h 2016-02-29 08:26:24 +0000
484@@ -24,6 +24,8 @@
485 class BaseSourceMediaManager : public wds::SourceMediaManager
486 {
487 public:
488+ explicit BaseSourceMediaManager();
489+
490 void SetSinkRtpPorts(int port1, int port2) override;
491 std::pair<int,int> GetSinkRtpPorts() const override;
492 int GetLocalRtpPort() const override;
493@@ -35,6 +37,7 @@
494 bool InitOptimalAudioFormat(const std::vector<wds::AudioCodec>& sink_supported_codecs) override;
495 wds::AudioCodec GetOptimalAudioFormat() const override;
496 void SendIDRPicture() override;
497+ std::string GetSessionId() const override;
498
499 protected:
500 virtual void Configure() = 0;
501@@ -43,6 +46,7 @@
502 int sink_port1_;
503 int sink_port2_;
504 wds::H264VideoFormat format_;
505+ unsigned int session_id_;
506 };
507 } // namespace mcs
508 #endif
509
510=== modified file 'src/mcs/miracastsourceclient.cpp'
511--- src/mcs/miracastsourceclient.cpp 2015-12-09 16:07:13 +0000
512+++ src/mcs/miracastsourceclient.cpp 2016-02-29 08:26:24 +0000
513@@ -85,6 +85,14 @@
514 return local_address_;
515 }
516
517+int MiracastSourceClient::GetNextCSeq(int *initial_peer_cseq) const {
518+ static int send_cseq = 0;
519+ ++send_cseq;
520+ if (initial_peer_cseq && send_cseq == *initial_peer_cseq)
521+ send_cseq *= 2;
522+ return send_cseq;
523+}
524+
525 class TimerCallbackData {
526 public:
527 TimerCallbackData(MiracastSourceClient *delegate) :
528
529=== modified file 'src/mcs/miracastsourceclient.h'
530--- src/mcs/miracastsourceclient.h 2015-12-07 09:07:50 +0000
531+++ src/mcs/miracastsourceclient.h 2016-02-29 08:26:24 +0000
532@@ -57,6 +57,7 @@
533 std::string GetLocalIPAddress() const override;
534 uint CreateTimer(int seconds) override;
535 void ReleaseTimer(uint timerId) override;
536+ int GetNextCSeq(int* initial_peer_cseq = nullptr) const override;
537
538 public:
539 static gboolean OnTimeout(gpointer user_data);

Subscribers

People subscribed via source and target branches

to all changes: