From d9ed7046b0aaa82406ff9ff83c61ed6c7408542a Mon Sep 17 00:00:00 2001 From: Balazs Kelemen Date: Wed, 10 Sep 2014 11:49:34 -0400 Subject: [PATCH] Add support for cross-compilation crosscompile is useful for development purposes. I do not intend to replace gbs with this, just to help developers (including myself) doing their job quicker. The idea is that once you built with gbs you can use it's build root together with the tizen sdk to crosscompile for mobile. Co-authored by Balazs Kelemen and Tomasz Olszak. Bug: http://107.108.218.239/bugzilla/show_bug.cgi?id=6110 Reviewed by: Balazs Kelemen, Piotr Tworek, SeungSeop Park Reviewed by: Antonio Gomes, SeungSeop Park Change-Id: Iff75f7e0917aa7141fb075d46a3734c94cbf5a8b Signed-off-by: Balazs Kelemen Signed-off-by: Tomasz Olszak Signed-off-by: Piotr Tworek --- tizen_src/README.md | 85 +++++++++++++++ tizen_src/build/build_desktop.sh | 93 ++-------------- tizen_src/build/build_mobile.sh | 16 +-- tizen_src/build/build_tv.sh | 15 +-- tizen_src/build/ccache_env.sh | 4 +- tizen_src/build/common.sh | 107 +++++++++++++++++- tizen_src/build/cross-shim/arm-linux-gnueabihf-g++ | 5 + tizen_src/build/cross-shim/arm-linux-gnueabihf-gcc | 5 + tizen_src/build/cross_build_mobile.sh | 72 +++++++++++++ tizen_src/build/cross_build_tv.sh | 72 +++++++++++++ tizen_src/build/gyp_chromiumefl.sh | 120 ++++++++++++++------- tizen_src/impl/chromium-efl-deps.gyp | 2 +- tizen_src/packaging/chromium-efl.spec | 1 + tizen_src/scripts/deploy2device.sh | 2 +- 14 files changed, 449 insertions(+), 150 deletions(-) create mode 100755 tizen_src/build/cross-shim/arm-linux-gnueabihf-g++ create mode 100755 tizen_src/build/cross-shim/arm-linux-gnueabihf-gcc create mode 100755 tizen_src/build/cross_build_mobile.sh create mode 100755 tizen_src/build/cross_build_tv.sh diff --git a/tizen_src/README.md b/tizen_src/README.md index c65e8f0..8f83e13 100755 --- a/tizen_src/README.md +++ b/tizen_src/README.md @@ -130,3 +130,88 @@ mode on Ubuntu. Some other useful switches include: --debug Run tests on debug build of chromium --nocheck-sys-deps Do not check if necessary dependencies have been installed on target system. Useful when not using supported ubuntu version --help Display full list of supported command line options + +### Crosscompile mobile build +This is a build mode only for development purposes. It doesn't produce an installable +rpm package. It might break any time. I warned you! The advantage is that everything +is built directly on the host and the overhead of gbs is eliminated. Ergo it is fast. + +The setup is a bit involved. Let's see. Note that it is quite likely that it will not +work out-of-box and you have to tailor it to your system. + +First you need to have your gbs root directory set up which effectively means you +should do a gbs mobile build. + +Now you need to have corresponding cross compiler. We have sources of cross compiler +used in gbs so why don't use it? Let's clone tizenbuildtools repo first: + + git clone -b master http://gitorious.org/tizenbuildtools/tizenbuildtools.git + cd tizenbuildtools/tools + +Now build binutils and cross compiler. + ./create_cross_compiler_from_gbs_sysroot \ + -p ~/toolchains/gcc-4.8-mobile/ \ + -s ~/GBS-ROOT-2.3-DEV/local/BUILD-ROOTS/scratch.armv7l.0 \ + -r http://10.251.52.177/tizenrepo/tv_repo/tizen-2.2.1-vd-4.8_20140822.1/repos/base/source +First parameter (-p) is toolchain prefix. There will land binutils and gcc. Second one is gbs sysroot +needed to cross compilation. It needs to be prepared (gbs build performed). Third parameter is source +rpm repository corresponding to binary repository used by gbs(almost always this repository is +ancestor of repository used by gbs and placed in gbs.conf) + +It's recommended to use gold linker. Replace the ld binary in the compiler with gold. + + cd ~/toolchains/gcc-4.8-mobile/bin + cp armv7l-tizen-linux-gnueabi-ld armv7l-tizen-linux-gnueabi-ld.normal + ln -sf armv7l-tizen-linux-gnueabi-ld.gold armv7l-tizen-linux-gnueabi-ld + +Build + export GBS_ROOT_PATH=~/GBS-ROOT-2.3-DEV + export PATH=~/toolchains/gcc-4.8-mobile/bin:$PATH + export CROSS_COMPILE=armv7l-tizen-linux-gnueabi- + ./build/cross_build_mobile.sh + +Before first deployment of cross compiled binaries ensure that you installed rpm on device. +Rpm will create necessary, initial configuration e.g. smack permissions. + +Deploy: + scripts/deploy2device.sh release -o /home/tolszak/workspace/CT/chromium-efl/out.cross.arm + +[Optional] Icecc +You can use ccache and/or icecc by setting up the cc variables and symlinks appropriately. +This is more or less what I have done before running build_dekstop.sh to set up both: + + cd ~/bin + TARBALL=$(/usr/lib/icecc/icecc-create-env --gcc /usr/bin/arm-linux-gnueabi-gcc-4.6 /usr/bin/arm-linux-gnueabi-g++-4.6 | tail -n 1) + mv $TARBALL arm-linux-gnueabi-gcc-4.6.3.tar.gz + export ICECC_VERSION="$HOME/bin/arm-linux-gnueabi-gcc-4.6.3.tar.gz=arm-linux-gnueabi,$ICECC_VERSION" + ln -s /usr/bin/arm-linux-gnueabi-gcc-4.6 arm-linux-gnueabi-gcc + ln -s /usr/bin/arm-linux-gnueabi-gcc-4.6 arm-linux-gnueabi-g++ + export PATH=~/bin:$PATH + + cd /usr/lib/ccache + ln -s ../../bin/ccache arm-linux-gnueabi-gcc + ln -s ../../bin/ccache arm-linux-gnueabi-g++ + cd /usr/lib/icecc/bin + ln -s ../../bin/icecc arm-linux-gnueabi-gcc + ln -s ../../bin/icecc arm-linux-gnueabi-g++ + cd ~/bin + + export CC_target=arm-linux-gnueabi-gcc + export CXX_target=arm-linux-gnueabi-g++ + export CC_host=gcc + export CXX_host=g++ +[Optional] ccache + # make symbolic links to your cross compiler + ln -s ~/toolchains/gcc-4.8-mobile/bin/armv7l-tizen-linux-gnueabi-gcc armv7l-tizen-linux-gnueabi-gcc + ln -s ~/toolchains/gcc-4.8-mobile/bin/armv7l-tizen-linux-gnueabi-g++ armv7l-tizen-linux-gnueabi-g++ + # add invoke build script with with --ccache parameter + cd chromium-efl + ./build/cross_build_mobile.sh --ccache + +Now let's set up the phone to be able to run it. We need the nss libraries from +chromium-ewk/thirdparty to be on the phone under /lib. This might not be very safe +(break other apps) so be sure you make a backup. +gconf-2 has to be installed as well. Download the rpm from the tizen repositories +(that gbs is using also) and install. + +It is recommended to use scripts/deploy2device.sh to install binaries on device. diff --git a/tizen_src/build/build_desktop.sh b/tizen_src/build/build_desktop.sh index 28af5af..5dfa313 100755 --- a/tizen_src/build/build_desktop.sh +++ b/tizen_src/build/build_desktop.sh @@ -4,63 +4,15 @@ SCRIPTDIR=$( cd $(dirname $0) ; pwd -P ) TOPDIR=$( cd ${SCRIPTDIR}/.. ; pwd -P ) source ${SCRIPTDIR}/common.sh +trap 'error_report $0 $LINENO' ERR SIGINT SIGTERM SIGQUIT host_arch=$(getHostArch) -export GYP_GENERATOR_OUTPUT=${TOPDIR}/"out.${host_arch}" - -usage() { -cat << EOF -usage: $0 [OPTIONS] - -Build desktop version of chromium-efl - -OPTIONS: - -h, --help Show this message - --skip-gyp Skip restore_gyp, jhbuild and gyp_chromium steps - --ccache configure ccache installed in your system - --skip-ninja Skip ninja step - --build-ewk-unittests build ewk unittests - --debug build debug version of chromium-efl (in $GYP_GENERATOR_OUTPUT/Debug instead of default $GYP_GENERATOR_OUTPUT/Release) - -jN set number of jobs, just like with make or ninja - -examples: -$0 --skip-gyp -$0 --skip-gyp --ccache -$0 --skip-ninja -EOF - exit -} - -SKIP_GYP=0 -USE_CCACHE=0 -SKIP_NINJA=0 - -BUILD_SUBDIRECTORY=Release - -if echo "$@" | grep -cq '\(\(\-\-help\)\|\(\-h\)\)'; then - usage -fi - -if echo "$@" | grep -cq '\-\-skip-gyp'; then - SKIP_GYP=1 +if [ -z "$GYP_GENERATOR_OUTPUT" ]; then + export GYP_GENERATOR_OUTPUT=${TOPDIR}/"out.${host_arch}" fi -if echo "$@" | grep -cq '\-\-skip-ninja'; then - SKIP_NINJA=1 -fi - -if echo "$@" | grep -cq '\-\-ccache'; then - USE_CCACHE=1 -fi - -if echo "$@" | grep -cq '\-\-build-ewk-unittests'; then - BUILD_EWK_UNITTESTS=1 -fi - -if echo "$@" | grep -cq '\-\-content_shell'; then - BUILD_CONTENT_SHELL=1 -fi +parseHostBuildScriptParams desktop $@ JHBUILD_STAMPFILE="${GYP_GENERATOR_OUTPUT}/Dependencies/Root/jhbuild.stamp" @@ -83,16 +35,6 @@ if [ "$(shouldForceJHBuild $@)" == "1" ]; then rm -f $JHBUILD_STAMPFILE fi -if echo "$@" | grep -cq '\-\-debug'; then - BUILD_SUBDIRECTORY=Debug -fi - -# Will be empty string if -j not specified or ill-formatted, otherwise -j and the number argument together. -# \grep because folks often alias grep but we want the vanilla behavior. -JOBS=$(echo "$@" | \grep -Eo '\-j\s*[1-9]([0-9]*)') - -set -e - JHBUILD_DEPS="${GYP_GENERATOR_OUTPUT}/Dependencies/Root" if [ "${host_arch}" == "x64" ]; then _LIBDIR=lib64 @@ -109,28 +51,11 @@ if [ ! -f "$JHBUILD_STAMPFILE" ]; then fi fi -if [ "$SKIP_GYP" == "0" ]; then - ${TOPDIR}/build/gyp_chromiumefl.sh -fi +export __GYP_CHROMIUMEFL_TARGET=desktop -if [ "$SKIP_NINJA" == "0" ]; then - if [ "$USE_CCACHE" == "1" ]; then - echo using ccache - set +e - source $TOPDIR/build/ccache_env.sh desktop - set -e - fi - export LD_LIBRARY_PATH="${JHBUILD_DEPS}/${_LIBDIR}:$LD_LIBRARY_PATH" - export PATH="${JHBUILD_DEPS}/bin:$PATH" +hostGypChromiumEfl - TARGETS="chromium-efl efl_webprocess chromium-ewk efl_webview_app" - if [ "$BUILD_EWK_UNITTESTS" == "1" ]; then - TARGETS="$TARGETS ewk_unittests" - fi +export LD_LIBRARY_PATH="${JHBUILD_DEPS}/${_LIBDIR}:$LD_LIBRARY_PATH" +export PATH="${JHBUILD_DEPS}/bin:$PATH" - if [ "$BUILD_CONTENT_SHELL" == "1" ]; then - TARGETS="$TARGETS content_shell_efl" - fi - - ninja -C ${GYP_GENERATOR_OUTPUT}/${BUILD_SUBDIRECTORY} ${JOBS} ${TARGETS} -fi +hostNinja desktop diff --git a/tizen_src/build/build_mobile.sh b/tizen_src/build/build_mobile.sh index 5d4807a..8b889fd 100755 --- a/tizen_src/build/build_mobile.sh +++ b/tizen_src/build/build_mobile.sh @@ -1,12 +1,11 @@ #!/bin/bash -export ICECC=no -SCRIPTDIR=$(cd $(dirname $0); pwd -P) - # source common functions and vars -. `dirname ${BASH_SOURCE[0]}`/common.sh +. `dirname $0`/common.sh +trap '${SCRIPTDIR}/apply_patches.sh -r ${SCRIPTDIR}/patches;\ + error_report $0 $LINENO' ERR SIGINT SIGTERM SIGQUIT -${SCRIPTDIR}/apply_patches.sh +${SCRIPTDIR}/apply_patches.sh ${SCRIPTDIR}/patches # "|| :" means "or always succeeding built-in command" PROFILE_NAME=$(echo "$@" | grep -Po "(?<=\-P\s)[^\s]*" || :) @@ -27,11 +26,6 @@ CUSTOM_LIBC_DIR="custom_libc_dir /opt/usr/eglibc-2.18/lib" gbs $CONF_FLAG build $PROFILE_FLAG -A armv7l --incremental \ --define "${CUSTOM_LIBC_DIR}" \ --define "${TIZEN_VERSION}" "$@" -GBS_RET=$? -${SCRIPTDIR}/apply_patches.sh -r -APPLY_PATCHES_RET=$? +${SCRIPTDIR}/apply_patches.sh -r ${SCRIPTDIR}/patches -[ "$GBS_RET" != "0" ] && exit $GBS_RET -[ "$APPLY_PATCHES_RET" != "0" ] && exit $APPLY_PATCHES_RET -exit 0 diff --git a/tizen_src/build/build_tv.sh b/tizen_src/build/build_tv.sh index 9546a60..eea0338 100755 --- a/tizen_src/build/build_tv.sh +++ b/tizen_src/build/build_tv.sh @@ -1,11 +1,11 @@ #!/bin/bash -SCRIPTDIR=$(cd $(dirname $0); pwd -P) - # source common functions and vars -. `dirname ${BASH_SOURCE[0]}`/common.sh +. `dirname $0`/common.sh +trap '${SCRIPTDIR}/apply_patches.sh -r ${SCRIPTDIR}/patches;\ + error_report $0 $LINENO' ERR SIGINT SIGTERM SIGQUIT -${SCRIPTDIR}/apply_patches.sh +${SCRIPTDIR}/apply_patches.sh ${SCRIPTDIR}/patches # "|| :" means "or always succeeding built-in command" PROFILE_NAME=$(echo "$@" | grep -Po "(?<=\-P\s)[^\s]*" || :) @@ -24,11 +24,6 @@ fi gbs $CONF_FLAG build $PROFILE_FLAG -A armv7l --incremental \ --extra-packs python-base-x86-arm,python-x86-arm,python-xml-x86-arm \ --define "${TIZEN_VERSION}" "$@" -GBS_RET=$? -${SCRIPTDIR}/apply_patches.sh -r -APPLY_PATCHES_RET=$? +${SCRIPTDIR}/apply_patches.sh -r ${SCRIPTDIR}/patches -[ "$GBS_RET" != "0" ] && exit $GBS_RET -[ "$APPLY_PATCHES_RET" != "0" ] && exit $APPLY_PATCHES_RET -exit 0 diff --git a/tizen_src/build/ccache_env.sh b/tizen_src/build/ccache_env.sh index 196bdf8..64e61c3 100644 --- a/tizen_src/build/ccache_env.sh +++ b/tizen_src/build/ccache_env.sh @@ -13,7 +13,7 @@ if ! type ccache &> /dev/null; then return 0 fi -if [ "$1" == "desktop" -o "$1" == "mobile" -o "$1" == "tv" ]; then +if [ "$1" == "desktop" -o "$1" == "mobile" -o "$1" == "tv" -o "$1" == "crosscompile" ]; then OUTPUT_BASE_FOLDER=out.${1}.$(getHostArch) export CCACHE_CPP2=yes export CCACHE_SLOPPINESS=time_macros @@ -33,7 +33,7 @@ if [ "$1" == "desktop" -o "$1" == "mobile" -o "$1" == "tv" ]; then ccache -M 10 fi - if [ "$1" == "desktop" ]; then + if [ "$1" == "desktop" -o "$1" == "crosscompile" ]; then ccacheInPath=$(echo $PATH | grep -c /usr/lib/ccache) if [ "$ccacheInPath" == "0" ]; then export PATH=/usr/lib/ccache:$PATH diff --git a/tizen_src/build/common.sh b/tizen_src/build/common.sh index 6ae5a8e..121d60c 100644 --- a/tizen_src/build/common.sh +++ b/tizen_src/build/common.sh @@ -1,10 +1,10 @@ #!/bin/bash -pushd `dirname ${BASH_SOURCE[0]}` > /dev/null -SCRIPTDIR=`pwd -L` +pushd `dirname $0` > /dev/null +export SCRIPTDIR=`pwd -L` popd > /dev/null -export TOPDIR="${SCRIPTDIR}/.." +export TOPDIR=$(readlink -f "${SCRIPTDIR}/..") if [[ -z "${CHROME_SRC}" ]]; then # If $CHROME_SRC was not set, assume src subfolder in project directory is CHROME_SRC. export CHROME_SRC="${TOPDIR}/src" @@ -33,3 +33,104 @@ function getHostArch() { function getPythonVersion() { echo $(python --version 2>&1 | sed -e 's/Python \([0-9]\+\.[0-9]\+\)\.[0-9]\+/\1/') } + +function setIfUndef() { + eval original=\$$1 + new=$2 + if [ -n "$original" ]; then + echo $original + else + echo $new + fi +} + + +function hostBuldScriptUsage() { +cat << EOF +usage: $1 [OPTIONS] + +Build non gbs version of chromium-efl + +OPTIONS: + -h, --help Show this message + --skip-gyp Skip restore_gyp, jhbuild and gyp_chromium steps + --ccache configure ccache installed in your system + --content-shell Build content_shell application + --skip-ninja Skip ninja step + --build-ewk-unittests build ewk unittests + --debug build debug version of chromium-efl (in $GYP_GENERATOR_OUTPUT/Debug instead of default $GYP_GENERATOR_OUTPUT/Release) + -jN set number of jobs, just like with make or ninja + +examples: +$0 --skip-gyp +$0 --skip-gyp --ccache +$0 --skip-ninja +EOF + exit +} + +function parseHostBuildScriptParams() { + + export SKIP_GYP=0 + export USE_CCACHE=0 + export SKIP_NINJA=0 + export BUILD_SUBDIRECTORY=Release + + if echo "$@" | grep -cq '\(\(\-\-help\)\|\(\-h\)\)'; then + hostBuldScriptUsage ${0} + fi + + if echo "$@" | grep -cq '\-\-skip-gyp'; then + export SKIP_GYP=1 + fi + + if echo "$@" | grep -cq '\-\-skip-ninja'; then + export SKIP_NINJA=1 + fi + + if echo "$@" | grep -cq '\-\-content_shell'; then + export BUILD_CONTENT_SHELL=1 + fi + + if echo "$@" | grep -cq '\-\-ccache'; then + export USE_CCACHE=1 + echo using ccache + source $TOPDIR/build/ccache_env.sh ${1} + fi + + if echo "$@" | grep -cq '\-\-build-ewk-unittests'; then + export BUILD_EWK_UNITTESTS=1 + fi + if echo "$@" | grep -cq '\-\-debug'; then + export BUILD_SUBDIRECTORY=Debug + fi + # Will be empty string if -j not specified or ill-formatted, otherwise -j and the number argument together. + # \grep because folks often alias grep but we want the vanilla behavior. + export JOBS=$(echo "$@" | \grep -Eo '\-j\s*[1-9]([0-9]*)') + +} + +function hostGypChromiumEfl() { + if [ "$SKIP_GYP" == "0" ]; then + ${TOPDIR}/build/gyp_chromiumefl.sh $@ + fi +} + +function hostNinja() { + if [ "$SKIP_NINJA" == "0" ]; then + TARGETS="chromium-efl efl_webprocess chromium-ewk efl_webview_app" + if [ "$BUILD_EWK_UNITTESTS" == "1" ]; then + TARGETS="$TARGETS ewk_unittests" + fi + if [ "$BUILD_CONTENT_SHELL" == "1" ]; then + TARGETS="$TARGETS content_shell_efl" + fi + BUILDDIR=${GYP_GENERATOR_OUTPUT}/${BUILD_SUBDIRECTORY} + ninja -C $BUILDDIR ${JOBS} ${TARGETS} + fi +} + +function error_report() { + echo "Error: File:$1 Line:$2" + exit 1 +} diff --git a/tizen_src/build/cross-shim/arm-linux-gnueabihf-g++ b/tizen_src/build/cross-shim/arm-linux-gnueabihf-g++ new file mode 100755 index 0000000..6c508a2 --- /dev/null +++ b/tizen_src/build/cross-shim/arm-linux-gnueabihf-g++ @@ -0,0 +1,5 @@ +#! /bin/bash + +# common.gypi wants arm-linux-gnueabihf-gcc to set default settings. +# Tizen doesn't support hard floating point so we redirect it. +${CROSS_COMPILE}g++ $@ diff --git a/tizen_src/build/cross-shim/arm-linux-gnueabihf-gcc b/tizen_src/build/cross-shim/arm-linux-gnueabihf-gcc new file mode 100755 index 0000000..bb8844d --- /dev/null +++ b/tizen_src/build/cross-shim/arm-linux-gnueabihf-gcc @@ -0,0 +1,5 @@ +#! /bin/bash + +# common.gypi wants arm-linux-gnueabihf-gcc to set default settings. +# Tizen doesn't support hard floating point so we redirect it. +${CROSS_COMPILE}gcc $@ diff --git a/tizen_src/build/cross_build_mobile.sh b/tizen_src/build/cross_build_mobile.sh new file mode 100755 index 0000000..e462808 --- /dev/null +++ b/tizen_src/build/cross_build_mobile.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +SCRIPTDIR=$( cd $(dirname $0) ; pwd -P ) +TOPDIR=$( cd ${SCRIPTDIR}/.. ; pwd -P ) + +source ${SCRIPTDIR}/common.sh +trap 'postBuild ${SYSROOTDIR};\ + error_report $0 $LINENO' ERR SIGINT SIGTERM SIGQUIT + +host_arch=$(getHostArch) + + +__SUFFIX=crosscompile.orig + +function adaptGbsSysrootToCrossCompilation() { + echo "cd /etc/; [ -e ld.so.conf.d ] && mv ld.so.conf.d ld.so.conf.d.$__SUFFIX;" | gbs chroot --root ${1} +} +function rollbackGbsSysrootChanges() { + echo "cd /etc/; [ -e ld.so.conf.d.$__SUFFIX ] && mv ld.so.conf.d.$__SUFFIX ld.so.conf.d;" | gbs chroot --root ${1} +} + +function preBuild() { + adaptGbsSysrootToCrossCompilation $1 + ${SCRIPTDIR}/apply_patches.sh ${SCRIPTDIR}/patches +} + +function postBuild() { + rollbackGbsSysrootChanges $1 + ${SCRIPTDIR}/apply_patches.sh -r ${SCRIPTDIR}/patches +} + +if [ -z "$GYP_GENERATOR_OUTPUT" ]; then + export GYP_GENERATOR_OUTPUT=${TOPDIR}/"out.cross.arm" +fi + +parseHostBuildScriptParams crosscompile $@ + +if [ -z "$GBS_ROOT_PATH" ]; then + echo "Set GBS_ROOT_PATH for cross compilation" + exit 1 +fi + +if [ -z "$CROSS_COMPILE" ]; then + echo "Set CROSS_COMPILE for cross compilation like: /home/user/toolchains/bin/armv7l-tizen-linux-gnueabi-" + exit 1 +fi + +# Only override if not set to enable customization for distributed compiling. +export CC_target=$(setIfUndef CC_target ${CROSS_COMPILE}gcc) +export CXX_target=$(setIfUndef CXX_target ${CROSS_COMPILE}g++) +export AR_target=${CROSS_COMPILE}ar +export AS_target=${CROSS_COMPILE}as +export RANLIB_target=${CROSS_COMPILE}ranlib + +export SYSROOTDIR="${GBS_ROOT_PATH}"/local/BUILD-ROOTS/scratch.armv7l.0 +export PKG_CONFIG_SYSROOT_DIR="${SYSROOTDIR}" +export PKG_CONFIG_PATH="${SYSROOTDIR}/usr/lib/pkgconfig:${SYSROOTDIR}/usr/share/pkgconfig" +export GYP_CROSSCOMPILE=1 + +export PATH="${TOPDIR}/build/cross-shim:$PATH" + +preBuild ${SYSROOTDIR} + +export __GYP_CHROMIUMEFL_TARGET=crosscompile +hostGypChromiumEfl -Dbuilding_for_tizen_mobile=1 + +hostNinja crosscompile +RET=$? + +postBuild ${SYSROOTDIR} + +exit $RET diff --git a/tizen_src/build/cross_build_tv.sh b/tizen_src/build/cross_build_tv.sh new file mode 100755 index 0000000..fec7dd6 --- /dev/null +++ b/tizen_src/build/cross_build_tv.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +SCRIPTDIR=$( cd $(dirname $0) ; pwd -P ) +TOPDIR=$( cd ${SCRIPTDIR}/.. ; pwd -P ) + +source ${SCRIPTDIR}/common.sh +trap 'postBuild ${SYSROOTDIR};\ + error_report $0 $LINENO' ERR SIGINT SIGTERM SIGQUIT + +host_arch=$(getHostArch) + + +__SUFFIX=crosscompile.orig + +function adaptGbsSysrootToCrossCompilation() { + echo "cd /etc/; [ -e ld.so.conf.d ] && mv ld.so.conf.d ld.so.conf.d.$__SUFFIX;" | gbs chroot --root ${1} +} +function rollbackGbsSysrootChanges() { + echo "cd /etc/; [ -e ld.so.conf.d.$__SUFFIX ] && mv ld.so.conf.d.$__SUFFIX ld.so.conf.d;" | gbs chroot --root ${1} +} + +function preBuild() { + adaptGbsSysrootToCrossCompilation $1 + ${SCRIPTDIR}/apply_patches.sh ${SCRIPTDIR}/patches +} + +function postBuild() { + rollbackGbsSysrootChanges $1 + ${SCRIPTDIR}/apply_patches.sh -r ${SCRIPTDIR}/patches +} + +if [ -z "$GYP_GENERATOR_OUTPUT" ]; then + export GYP_GENERATOR_OUTPUT=${TOPDIR}/"out.cross.tv.arm" +fi + +parseHostBuildScriptParams crosscompile $@ + +if [ -z "$GBS_ROOT_PATH" ]; then + echo "Set GBS_ROOT_PATH for cross compilation" + exit 1 +fi + +if [ -z "$CROSS_COMPILE" ]; then + echo "Set CROSS_COMPILE for cross compilation like: /home/user/toolchains/bin/armv7l-tizen-linux-gnueabi-" + exit 1 +fi + +# Only override if not set to enable customization for distributed compiling. +export CC_target=$(setIfUndef CC_target ${CROSS_COMPILE}gcc) +export CXX_target=$(setIfUndef CXX_target ${CROSS_COMPILE}g++) +export AR_target=${CROSS_COMPILE}ar +export AS_target=${CROSS_COMPILE}as +export RANLIB_target=${CROSS_COMPILE}ranlib + +export SYSROOTDIR="${GBS_ROOT_PATH}"/local/BUILD-ROOTS/scratch.armv7l.0 +export PKG_CONFIG_SYSROOT_DIR="${SYSROOTDIR}" +export PKG_CONFIG_PATH="${SYSROOTDIR}/usr/lib/pkgconfig:${SYSROOTDIR}/usr/share/pkgconfig" +export GYP_CROSSCOMPILE=1 + +export PATH="${TOPDIR}/build/cross-shim:$PATH" + +preBuild ${SYSROOTDIR} + +export __GYP_CHROMIUMEFL_TARGET=crosscompile +hostGypChromiumEfl -Dbuilding_for_tizen_tv=1 -Dchromium_efl_tizen_version="2.2.1" + +hostNinja crosscompile +RET=$? + +postBuild ${SYSROOTDIR} + +exit $RET diff --git a/tizen_src/build/gyp_chromiumefl.sh b/tizen_src/build/gyp_chromiumefl.sh index cfc7797..bd3cba2 100755 --- a/tizen_src/build/gyp_chromiumefl.sh +++ b/tizen_src/build/gyp_chromiumefl.sh @@ -1,25 +1,34 @@ #!/bin/bash -SCRIPTDIR=$( cd $(dirname $0) ; pwd -P ) -TOPDIR=$( cd ${SCRIPTDIR}/.. ; pwd -P ) - -source ${SCRIPTDIR}/common.sh - +source $(dirname $0)/common.sh +trap 'error_report $0 $LINENO' ERR SIGINT SIGTERM SIGQUIT host_arch=$(getHostArch) -target=desktop -export GYP_GENERATOR_OUTPUT=${TOPDIR}/"out.${host_arch}" +if [ -z "$GYP_GENERATOR_OUTPUT" ]; then + GYP_GENERATOR_OUTPUT=${TOPDIR}/"out.${host_arch}" +fi + +EXTRA_GYP_ARGS="$@" -if echo "$@" | grep -cq '\-\Dbuilding_for_tizen_mobile=1'; then - GYP_GENERATOR_OUTPUT=${TOPDIR}/"out.mobile.${host_arch}" +# __GYP_CHROMIUMEFL_TARGET is defined when we are called from build_desktop.sh. +# Otherwise we are called by gbs whch already passes the correct building_for_* flag. +if [ "$__GYP_CHROMIUMEFL_TARGET" == "desktop" ]; then + target=desktop +elif echo "$@" | grep -cq '\-\Dbuilding_for_tizen_mobile=1'; then target=mobile -fi -if echo "$@" | grep -cq '\-\Dbuilding_for_tizen_tv=1'; then - GYP_GENERATOR_OUTPUT=${TOPDIR}/"out.tv.${host_arch}" + buildType=gbs +elif echo "$@" | grep -cq '\-\Dbuilding_for_tizen_tv=1'; then target=tv + buildType=gbs fi -set -e +if [ "$__GYP_CHROMIUMEFL_TARGET" == "crosscompile" ]; then + buildType=crosscompile + EXTRA_GYP_ARGS+=" -Dedje_compiler=${TOPDIR}/out.${host_arch}/Dependencies/Root/bin/edje_cc" + if [ "$target" == "mobile" ]; then + EXTRA_GYP_ARGS+=" -Dcustom_libc_dir=/opt/usr/eglibc-2.18/lib" + fi +fi ORIGINAL_GYP_DEFINES="$GYP_DEFINES" export GYP_DEFINES=$(echo "$GYP_DEFINES" | sed -e 's/component\s*=\s*shared_library//g') @@ -39,35 +48,41 @@ COMMON_GYP_PARAMETERS=" -Dtoolkit_uses_gtk=0 " -if [ "$target" == "desktop" ]; then - ADDITIONAL_GYP_PARAMETERS+="-Dbuilding_for_tizen=0 +add_desktop_flags() { + ADDITIONAL_GYP_PARAMETERS+="-Dbuilding_for_tizen=0" +} + +add_arm_flags() { + ADDITIONAL_GYP_PARAMETERS+="-Darmv7=1 + -Darm_thumb=1 + -Darm_neon=1 " -else +} + +add_tizen_flags() { ADDITIONAL_GYP_PARAMETERS+="-Dbuilding_for_tizen=1 -Dwerror= - -Dsysroot= - --no-parallel -Dpython_ver=$(getPythonVersion) - -Dtarget_arch=$host_arch - -Dhost_arch=$host_arch -Denable_basic_printing=1 -Denable_print_preview=1 -Duse_kerberos=0 -Duse_gconf=0 + -Duse_alsa=0 -Dlinux_use_bundled_gold=0 -Dlinux_use_bundled_binutils=0 -Dprebuilt_ld_gold_dir=${TOPDIR}/build/prebuild " +} - if [ "${GBS_ARCH}" == "arm" ]; then - ADDITIONAL_GYP_PARAMETERS+="-Darmv7=1 - -Darm_thumb=1 - -Darm_neon=1 - " - fi - - SYSTEM_DEPS="-Duse_alsa=0 - -Duse_system_expat=1 +add_gbs_flags() { + ADDITIONAL_GYP_PARAMETERS+="-Dtarget_arch=$host_arch + -Dhost_arch=$host_arch + -Dsysroot= + --no-parallel + " + # TODO(b.kelemen): ideally crosscompile should also support system libs. + # Unfortunately the gbs root doesn't contain everything chromium needs. + SYSTEM_DEPS="-Duse_system_expat=1 -Duse_system_flac=1 -Duse_system_icu=1 -Duse_system_libjpeg=0 @@ -80,29 +95,58 @@ else -Duse_system_zlib=1 " if [ "$target" == "mobile" ]; then - SYSTEM_DEPS+=" -Duse_system_bzip2=1 - -Duse_system_libexif=1 - -Duse_system_nspr=1 - -Duse_system_vpx=1" + SYSTEM_DEPS+="-Duse_system_bzip2=1 + -Duse_system_libexif=1 + -Duse_system_nspr=1 + -Duse_system_vpx=1" fi +} - #and replacing original files with correct ones according to $SYSTEM_DEPS - $TOPDIR/src/build/linux/unbundle/replace_gyp_files.py $SYSTEM_DEPS +add_cross_flags() { + ADDITIONAL_GYP_PARAMETERS+="-Dtarget_arch=arm + -Dhost_arch=$host_arch + -Dsysroot=$SYSROOTDIR + -Darm_tune=arm7 + -Dhost_clang=0 + " + # Compiling yasm with crosscompile + icecc leads to some strange errors (one file is built for target instead of host). + # Yasm is an assembler used only by the build (not at runtime) and it is generally available in Linux distros so let's just + # use it from the system. + ADDITIONAL_GYP_PARAMETERS+="-Duse_system_yasm=1" +} + +if [ "$target" == "desktop" ]; then + add_desktop_flags +else + add_tizen_flags + if [ "$target" == "mobile" -o "$target" == "tv" ]; then + if [ "$target_arch" == "arm" ]; then + add_arm_flags + fi + if [ "$buildType" == "gbs" ]; then + add_gbs_flags + elif [ "$buildType" == "crosscompile" ]; then + add_cross_flags + fi + fi + if [ "$SYSTEM_DEPS" != "" ]; then + #replacing original files with correct ones according to $SYSTEM_DEPS + $TOPDIR/src/build/linux/unbundle/replace_gyp_files.py $SYSTEM_DEPS + fi fi -set +e set -x ${TOPDIR}/build/gyp_chromiumefl \ $COMMON_GYP_PARAMETERS \ $SYSTEM_DEPS \ $ADDITIONAL_GYP_PARAMETERS \ - $@ \ + $EXTRA_GYP_ARGS \ ${TOPDIR}/ewk/chromium-ewk.gyp ret=$? -if [ "$target" != "desktop" ]; then +if [ "$SYSTEM_DEPS" != "" ]; then # Restore gyp files to their original states not to mess up the tree permanently. $TOPDIR/src/build/linux/unbundle/replace_gyp_files.py --undo $SYSTEM_DEPS fi diff --git a/tizen_src/impl/chromium-efl-deps.gyp b/tizen_src/impl/chromium-efl-deps.gyp index 84ce6b4..dae3803 100755 --- a/tizen_src/impl/chromium-efl-deps.gyp +++ b/tizen_src/impl/chromium-efl-deps.gyp @@ -154,7 +154,7 @@ ['chromium_efl_tizen_version=="2.2.1"', { 'direct_dependent_settings': { 'include_dirs': [ - '/usr/include/sensor', + '<(sysroot)/usr/include/sensor', ] } }], diff --git a/tizen_src/packaging/chromium-efl.spec b/tizen_src/packaging/chromium-efl.spec index 15a679c..50feab0 100755 --- a/tizen_src/packaging/chromium-efl.spec +++ b/tizen_src/packaging/chromium-efl.spec @@ -185,6 +185,7 @@ export LD_RUN_PATH=%{_libdir} %endif %define OUTPUT_BASE_FOLDER out.%{OUTPUT_BUILD_PROFILE_TARGET}.%{EFL_TARGET} +export GYP_GENERATOR_OUTPUT=$PWD/%{OUTPUT_BASE_FOLDER} #set build mode %if 0%{?_debug_mode} diff --git a/tizen_src/scripts/deploy2device.sh b/tizen_src/scripts/deploy2device.sh index c44d2b6..dc2110b 100755 --- a/tizen_src/scripts/deploy2device.sh +++ b/tizen_src/scripts/deploy2device.sh @@ -81,7 +81,7 @@ setupDevice() { } get_arm_strip() { - if [ -n "$CROSS_COMPILE" -a -x "${CROSS_COMPILE}strip" ]; then + if [ -n "$CROSS_COMPILE" ] && type "${CROSS_COMPILE}strip" &> /dev/null; then echo "${CROSS_COMPILE}strip" return 0 fi -- 2.7.4