Mobile/Fennec/RaspberryPi: Difference between revisions

From MozillaWiki
< Mobile‎ | Fennec
Jump to navigation Jump to search
 
(22 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Build Qt5 Mozilla for Raspberry Pi =
= Build Qt Mozilla for Raspberry Pi =


== Prepare multiarch chroot ==
== Build crosstool-ng toolchain ==


Install crosstool-ng using this tutorial:
http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi
In addition to step 13. enable C++<br/>
And choose compiler linaro-4.7-2013.01<br/>
Tested crosstool-ng config available here:<br/>
http://romaxa.info/raspberrypi/rasp-armhf-whz-4.7-config<br/>
== Prepare target wheezy armhf chroot ==
==== Download raspbian public key from root ====
<pre>
<pre>
sudo apt-get install debootstrap
sudo su
export CHROOTPATH=$HOME/squeezeRP
wget http://archive.raspbian.org/raspbian.public.key;apt-key add raspbian.public.key
export CHROOTPREFIX=sqrp
CTRL^D
sudo debootstrap --arch=i386 --variant=buildd squeeze $CHROOTPATH
 
sudo apt-get install qemu-user-static
 
</pre>
 
==== Debootstrap wheezy chroot ====
 
<pre>
export CHROOTPATH=$HOME/wheezy-armhf
export CHROOTPREFIX=whrp
mkdir -p $CHROOTPATH/usr/bin
cp -rf /usr/bin/qemu-arm-static $CHROOTPATH/usr/bin
sudo debootstrap --verbose --arch=armhf --keyring /etc/apt/trusted.gpg  --include=apt  wheezy $CHROOTPATH http://archive.raspbian.org/raspbian
 
sudo cp /usr/bin/qemu-arm-static $CHROOTPATH/usr/bin/
sudo cp -f /etc/apt/apt.conf $CHROOTPATH/etc/apt/
sudo cp -f /etc/apt/apt.conf $CHROOTPATH/etc/apt/
sudo cp -f /etc/apt/apt.conf.d/* $CHROOTPATH/etc/apt/apt.conf.d/
sudo cp -f /etc/apt/apt.conf.d/* $CHROOTPATH/etc/apt/apt.conf.d/
Line 14: Line 39:
</pre>
</pre>


==== Better to make user inside chroot, same as your host user, with sudo permissions ====
==== Install required packages inside chroot ====
<pre>
 
sudo chroot $CHROOTPATH apt-get install -y --force-yes sudo adduser vim bash-completion
</pre>
==== Setup chroot sdk user, enter password and name ====
<pre>
sudo chroot $CHROOTPATH adduser `whoami`
</pre>
==== Setup sudo group ====
<pre>
<pre>
sudo chroot $CHROOTPATH adduser `whoami` sudo
sudo chroot $CHROOTPATH apt-get update
sudo chroot $CHROOTPATH apt-get install -y --force-yes sudo adduser python2.7 bash-completion
</pre>
</pre>


==== make chroot alias ====
==== make chroot alias ====
<pre>
<pre>
echo "alias o"$CHROOTPREFIX"chroot='sudo chroot $CHROOTPATH su - "`whoami`"'" >> ~/.bashrc
echo "alias o"$CHROOTPREFIX"chroot='sudo chroot $CHROOTPATH su - '" >> ~/.bashrc
. ~/.bashrc
. ~/.bashrc
</pre>
</pre>


==== Make chroot shell different from host ====
==== Make chroot shell different from host ====
<pre>
<pre>
echo "PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]-"$CHROOTPREFIX":\[\033[01;34m\]\w\[\033[00m\]\$ '" >>  $CHROOTPATH/home/`whoami`/.bashrc
echo "PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]-"$CHROOTPREFIX":\[\033[01;34m\]\w\[\033[00m\]\$ '" >>  $CHROOTPATH/root/.bashrc
</pre>
</pre>


==== Make sure that proc mounted in order to avoid some warnings ====
==== Make sure that proc mounted in order to avoid some warnings ====
<pre>
<pre>
echo "sudo mount -t proc proc /proc" >> $CHROOTPATH/home/`whoami`/.bashrc
echo "sudo mount -t proc proc /proc" >> $CHROOTPATH/root/.bashrc
</pre>
</pre>


Line 52: Line 72:
   . /etc/bash_completion
   . /etc/bash_completion
fi
fi
" >> $CHROOTPATH/home/`whoami`/.bashrc
" >> $CHROOTPATH/root/.bashrc
</pre>
</pre>


==== Setup non-passwd sudo, Make user sudo without password requests ====
== Setup Scratchbox 2 around installed toolchain and dev rootfs ==


<pre>
<pre>
sudo echo `whoami`" ALL=(ALL)NOPASSWD: ALL" > $CHROOTPATH/tmp/user_full
# Install sbox2 with:
sudo chmod 0440 $CHROOTPATH/tmp/user_full
 
sudo chown root: $CHROOTPATH/tmp/user_full
sudo apt-get install scratchbox2
sudo chroot $CHROOTPATH mv /tmp/user_full /etc/sudoers.d/
 
</pre>
# or use these instructions:
# http://russelldavis.org/2011/09/07/setting-up-scratchbox2-from-scratch-for-the-raspberry-pi/


== Switch into chroot and perform basic setup ==
# also small hack around: error "Never use <bits/predefs.h> directly; include <stdc-predef.h> instead."
sudo cp /opt/cross/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/usr/include/features.h $CHROOTPATH/usr/include


<pre>
sudo chroot $CHROOTPATH su - "`whoami`"
</pre>
</pre>


==== Set up the /etc/apt/sources.list inside the chroot : ====
==== Initialize sb2 config ====
 
<pre>
<pre>
sudo su -c 'echo "# Squeeze cross sources list
cd $CHROOTPATH
deb http://backports.debian.org/debian-backports squeeze-backports main contrib non-free
sb2-init Raspi /opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc
deb http://www.emdebian.org/debian squeeze main
sb2-config -d Raspi
deb [arch=i386] http://ftp.fi.debian.org/debian/ squeeze main contrib non-free
deb [arch=armel] http://ftp.fi.debian.org/debian/ squeeze main contrib non-free
deb-src http://ftp.fi.debian.org/debian/ squeeze main contrib non-free
" > /etc/apt/sources.list'
</pre>
</pre>


==== In /etc/apt/apt.conf.d/10local disable installing recommends: ====
= Build Qt-Mozilla inside chroot =
<pre>
sudo su -c 'echo "APT::Install-Recommends \"0\";
APT::Install-Suggests \"0\";" > /etc/apt/apt.conf.d/10local'
sudo apt-get update
</pre>


==== Install toolchain and essentials ====
==== Install Qt dev packages to Dev rootfs ====
<pre>
<pre>
sudo apt-get update
# Core dependencies (--enable-default-toolkit=linuxgl)
sudo apt-get install apt-utils xapt g++-4.4-arm-linux-gnueabi build-essential pkg-config unzip zip autoconf2.13 gdb-arm-linux-gnueabi -y --force-yes
sudo chroot $CHROOTPATH apt-get install -y --force-yes libpango1.0-dev libasound-dev libfreetype6-dev libffi-dev
# Qt dependencies (--enable-default-toolkit=cairo-qt)
sudo chroot $CHROOTPATH apt-get install -y --force-yes libqt4-dev libqt4-opengl-dev libxt-dev libx11-dev libxext-dev
# Gtk dependencies (--enable-default-toolkit=cairo-gtk2)
sudo chroot $CHROOTPATH apt-get install -y --force-yes libgtk2.0-dev
</pre>
</pre>


==== Create cross arm pkg-config:====
==== Clone Mozilla-Central and build====
<pre>
echo '#!/bin/sh
triplet=`basename $0 | sed -e "s:-pkg-config::"`
PKG_CONFIG_LIBDIR=/usr/${triplet}/lib/pkgconfig pkg-config $@
' > /tmp/arm-linux-gnueabi-pkg-config
sudo mv /tmp/arm-linux-gnueabi-pkg-config /usr/local/bin/arm-linux-gnueabi-pkg-config
sudo chmod a+x /usr/local/bin/arm-linux-gnueabi-pkg-config
</pre>


==== Add some useful packages for development environment ====
<pre>
<pre>
sudo apt-get install automake libtool debhelper mercurial git-core openssh-client -y --force-yes
mkdir ~/build && cd ~/build
</pre>
hg clone http://hg.mozilla.org/mozilla-central


==== Setup mercurial config ====
cd mozilla-central
<pre>
# Apply configure hacks for crosstool-ng toolchain problems, probably could be fixed with better configuration of cross-toolchain
echo "[ui]
hg qimport -P http://pastebin.mozilla.org/?dl=2137908
username = UserName
[extensions]
hgext.mq =
hgext.color =
hgext.graphlog =
hgext.rebase =
" > ~/.hgrc
</pre>


= Build Qt5-Mozilla inside chroot =
cat > mozconfig.rsppi
#####################################################################
export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
export CPPFLAGS="-I/usr/include/arm-linux-gnueabihf"
export CFLAGS="-I/usr/include/arm-linux-gnueabihf"
mk_add_options  CPPFLAGS=$CPPFLAGS
mk_add_options  CFLAGS=$CFLAGS


mkdir ~/build && cd ~/build
FIX_LINK_LDFLAGS="-L/usr/arm-linux-gnueabihf/lib -Wl,-rpath-link=/usr/arm-linux-gnueabihf/lib -L/lib/arm-linux-gnueabihf -Wl,-rpath-link=/lib/arm-linux-gnueabihf"
FIX_LINK_LDFLAGS="$FIX_LINK_LDFLAGS -L/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link=/usr/lib/arm-linux-gnueabihf"
export LDFLAGS="$FIX_LINK_LDFLAGS"
LDFLAGS="$FIX_LINK_LDFLAGS"
export WRAP_LDFLAGS="$FIX_LINK_LDFLAGS"
mk_add_options LDFLAGS="$FIX_LINK_LDFLAGS"


==== install pre-compiled Qt5 and GLES libraries into chroot SDK====
export ac_cv_have_usable_wchar_option_v2="no"
<pre>
ac_add_options --enable-application=browser  # or browser for desktop firefox build
wget http://romaxa.info/raspberrypi/qt5rmx.tar.gz
ac_add_options --disable-tests
wget http://romaxa.info/raspberrypi/vc.tar.gz
ac_add_options --disable-dbus
sudo tar -zxvf qt5rmx.tar.gz -C /opt/
ac_add_options --disable-accessibility
sudo tar -zxvf vc.tar.gz -C /opt/
ac_add_options --disable-webrtc
</pre>
ac_add_options --enable-logging
ac_add_options --enable-default-toolkit=cairo-qt # or cairo-gtk2
ac_add_options --enable-mobile-optimize
ac_add_options --enable-optimize
ac_add_options --enable-system-ffi


==== Install common Mozilla build dependencies====
export MOZ_DEBUG_SYMBOLS=1
<pre>
ac_add_options --enable-debug-symbols="-gdwarf-2"
sudo xapt -k -a armel libpango1.0-dev libasound-dev libfreetype6-dev
export MOZILLA_OFFICIAL=1
</pre>
mk_add_options PROFILE_GEN_SCRIPT=@TOPSRCDIR@/build/profile_pageloader.pl


==== Fix pango dependencies pkg-config path====
export CXXFLAGS="$CXXFLAGS -DFORCE_BASICTILEDTHEBESLAYER=1 -DEGL_HAS_BACKING_SURFACE=1 -DUSE_ANDROID_OMTC_HACKS=1 "
<pre>
sudo ln -s /usr/arm-linux-gnueabi/share/pkgconfig/pthread-stubs.pc /usr/arm-linux-gnueabi/lib/pkgconfig/pthread-stubs.pc
</pre>


==== Clone Mozilla-Central and build====
ac_add_options --disable-elf-hack
<pre>
ac_add_options --enable-libjpeg-turbo
hg clone http://hg.mozilla.org/mozilla-central
ac_add_options --with-gl-provider=EGL
cd mozilla-central


# Qt5 No-X11 mozconfig
mk_add_options MOZ_MAKE_FLAGS="-j4"
wget http://romaxa.info/raspberrypi/mozconfig
mk_add_options MOZ_OBJDIR="@TOPSRCDIR@/objdir-arm-rasppi"


# Minimal build patch queue, (hope will be 0 soon)
ac_add_options --with-arm-kuser
hg clone http://hg.mozilla.org/users/romaxa_gmail.com/rmxmq .hg/patches
ac_add_options --with-thumb=toolchain-default
hg update -C `cat .hg/patches/changeset`
ac_add_options --with-arch=armv6
hg qpush -a
ac_add_options --with-float-abi=hard
ac_add_options --with-thumb=no
ac_add_options --with-fpu=vfp
ac_add_options --with-arm-kuser
#####################################################################


# Finally build
# Finally build
MOZCONFIG=$(pwd)/mozconfig make -f client.mk build_all
# switch to sb2 environment
sb2
{
  MOZCONFIG=$(pwd)/mozconfig.rsppi make -f client.mk build_all
}
</pre>
</pre>
[[/mozconfig2|Alternate mozconfig]]

Latest revision as of 21:45, 23 March 2013

Build Qt Mozilla for Raspberry Pi

Build crosstool-ng toolchain

Install crosstool-ng using this tutorial: http://www.bootc.net/archives/2012/05/26/how-to-build-a-cross-compiler-for-your-raspberry-pi

In addition to step 13. enable C++
And choose compiler linaro-4.7-2013.01
Tested crosstool-ng config available here:
http://romaxa.info/raspberrypi/rasp-armhf-whz-4.7-config

Prepare target wheezy armhf chroot

Download raspbian public key from root

sudo su
wget http://archive.raspbian.org/raspbian.public.key;apt-key add raspbian.public.key
CTRL^D

sudo apt-get install qemu-user-static

Debootstrap wheezy chroot

export CHROOTPATH=$HOME/wheezy-armhf
export CHROOTPREFIX=whrp
mkdir -p $CHROOTPATH/usr/bin
cp -rf /usr/bin/qemu-arm-static $CHROOTPATH/usr/bin
sudo debootstrap --verbose --arch=armhf --keyring /etc/apt/trusted.gpg  --include=apt  wheezy $CHROOTPATH http://archive.raspbian.org/raspbian

sudo cp /usr/bin/qemu-arm-static $CHROOTPATH/usr/bin/
sudo cp -f /etc/apt/apt.conf $CHROOTPATH/etc/apt/
sudo cp -f /etc/apt/apt.conf.d/* $CHROOTPATH/etc/apt/apt.conf.d/
sudo cp -f /etc/resolv.conf $CHROOTPATH/etc/
sudo cp -f /etc/hosts $CHROOTPATH/etc/

Install required packages inside chroot

sudo chroot $CHROOTPATH apt-get update
sudo chroot $CHROOTPATH apt-get install -y --force-yes sudo adduser python2.7 bash-completion

make chroot alias

echo "alias o"$CHROOTPREFIX"chroot='sudo chroot $CHROOTPATH su - '" >> ~/.bashrc
 . ~/.bashrc

Make chroot shell different from host

echo "PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]-"$CHROOTPREFIX":\[\033[01;34m\]\w\[\033[00m\]\$ '" >>  $CHROOTPATH/root/.bashrc

Make sure that proc mounted in order to avoid some warnings

echo "sudo mount -t proc proc /proc" >> $CHROOTPATH/root/.bashrc

fix undefined locale warnings, and enable bash completion

echo "
export LANGUAGE=C
export LC_ALL=C
export LANG=C
if [ -f /etc/bash_completion ]; then
   . /etc/bash_completion
fi
" >> $CHROOTPATH/root/.bashrc

Setup Scratchbox 2 around installed toolchain and dev rootfs

# Install sbox2 with:

sudo apt-get install scratchbox2

# or use these instructions:
# http://russelldavis.org/2011/09/07/setting-up-scratchbox2-from-scratch-for-the-raspberry-pi/

# also small hack around: error "Never use <bits/predefs.h> directly; include <stdc-predef.h> instead."
sudo cp /opt/cross/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/usr/include/features.h $CHROOTPATH/usr/include

Initialize sb2 config

cd $CHROOTPATH
sb2-init Raspi /opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc
sb2-config -d Raspi

Build Qt-Mozilla inside chroot

Install Qt dev packages to Dev rootfs

# Core dependencies (--enable-default-toolkit=linuxgl)
sudo chroot $CHROOTPATH apt-get install -y --force-yes libpango1.0-dev libasound-dev libfreetype6-dev libffi-dev
# Qt dependencies (--enable-default-toolkit=cairo-qt)
sudo chroot $CHROOTPATH apt-get install -y --force-yes libqt4-dev libqt4-opengl-dev libxt-dev libx11-dev libxext-dev
# Gtk dependencies (--enable-default-toolkit=cairo-gtk2)
sudo chroot $CHROOTPATH apt-get install -y --force-yes libgtk2.0-dev

Clone Mozilla-Central and build

mkdir ~/build && cd ~/build
hg clone http://hg.mozilla.org/mozilla-central

cd mozilla-central
# Apply configure hacks for crosstool-ng toolchain problems, probably could be fixed with better configuration of cross-toolchain
hg qimport -P http://pastebin.mozilla.org/?dl=2137908

cat > mozconfig.rsppi
#####################################################################
export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig
export CPPFLAGS="-I/usr/include/arm-linux-gnueabihf"
export CFLAGS="-I/usr/include/arm-linux-gnueabihf"
mk_add_options  CPPFLAGS=$CPPFLAGS
mk_add_options  CFLAGS=$CFLAGS

FIX_LINK_LDFLAGS="-L/usr/arm-linux-gnueabihf/lib -Wl,-rpath-link=/usr/arm-linux-gnueabihf/lib -L/lib/arm-linux-gnueabihf -Wl,-rpath-link=/lib/arm-linux-gnueabihf"
FIX_LINK_LDFLAGS="$FIX_LINK_LDFLAGS -L/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link=/usr/lib/arm-linux-gnueabihf"
export LDFLAGS="$FIX_LINK_LDFLAGS"
LDFLAGS="$FIX_LINK_LDFLAGS"
export WRAP_LDFLAGS="$FIX_LINK_LDFLAGS"
mk_add_options LDFLAGS="$FIX_LINK_LDFLAGS"

export ac_cv_have_usable_wchar_option_v2="no"
ac_add_options --enable-application=browser  # or browser for desktop firefox build
ac_add_options --disable-tests
ac_add_options --disable-dbus
ac_add_options --disable-accessibility
ac_add_options --disable-webrtc
ac_add_options --enable-logging
ac_add_options --enable-default-toolkit=cairo-qt # or cairo-gtk2
ac_add_options --enable-mobile-optimize
ac_add_options --enable-optimize
ac_add_options --enable-system-ffi

export MOZ_DEBUG_SYMBOLS=1
ac_add_options --enable-debug-symbols="-gdwarf-2"
export MOZILLA_OFFICIAL=1
mk_add_options PROFILE_GEN_SCRIPT=@TOPSRCDIR@/build/profile_pageloader.pl

export CXXFLAGS="$CXXFLAGS -DFORCE_BASICTILEDTHEBESLAYER=1 -DEGL_HAS_BACKING_SURFACE=1 -DUSE_ANDROID_OMTC_HACKS=1 "

ac_add_options --disable-elf-hack
ac_add_options --enable-libjpeg-turbo
ac_add_options --with-gl-provider=EGL

mk_add_options MOZ_MAKE_FLAGS="-j4"
mk_add_options MOZ_OBJDIR="@TOPSRCDIR@/objdir-arm-rasppi"

ac_add_options --with-arm-kuser
ac_add_options --with-thumb=toolchain-default
ac_add_options --with-arch=armv6
ac_add_options --with-float-abi=hard
ac_add_options --with-thumb=no
ac_add_options --with-fpu=vfp
ac_add_options --with-arm-kuser
#####################################################################

# Finally build
# switch to sb2 environment
sb2
{
  MOZCONFIG=$(pwd)/mozconfig.rsppi make -f client.mk build_all
}

Alternate mozconfig