This commit is contained in:
Viktor Petersson
2020-11-30 19:38:26 +00:00
parent 8335c3ea60
commit bf660dde70
2 changed files with 0 additions and 437 deletions

View File

@@ -1,186 +0,0 @@
FROM --platform=linux/arm/v7 balenalib/rpi-raspbian:buster as builder
# There are likely a large number of dependencies that can be stripped out here
# depending on your needs (and probably in general). My primary objective was just
# to make things work.
RUN apt-get update && \
apt-get install -y \
firebird-dev \
freetds-dev \
gstreamer-tools \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly \
gstreamer1.0-x \
libasound2-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libbz2-dev \
libcap-dev \
libdbus-1-dev \
libdbus-glib-1-dev \
libdrm-dev \
libegl1-mesa-dev \
libevent-dev \
libfontconfig1-dev \
libfreetype6-dev \
libgbm-dev \
libgcrypt20-dev \
libgles2-mesa-dev \
libglib2.0-dev \
libgst-dev \
libgstreamer-plugins-base0.10-dev \
libgstreamer0.10-dev \
libicu-dev \
libinput-dev \
libiodbc2-dev \
libjpeg62-turbo-dev \
libjsoncpp-dev \
libminizip-dev \
libnss3-dev \
libopus-dev \
libpci-dev \
libpng-dev \
libpng16-16 \
libpq-dev \
libpulse-dev \
libraspberrypi-bin \
libraspberrypi-dev \
libraspberrypi0 \
librsvg2-common \
libsnappy-dev \
libsqlite0-dev \
libsqlite3-dev \
libsrtp0-dev \
libsrtp2-dev \
libssl-dev \
libssl1.1 \
libswscale-dev \
libsystemd-dev \
libts-dev \
libudev-dev \
libvpx-dev \
libwebp-dev \
libx11-dev \
libx11-xcb-dev \
libx11-xcb1 \
libxcb-glx0-dev \
libxcb-icccm4 \
libxcb-icccm4-dev \
libxcb-image0 \
libxcb-image0-dev \
libxcb-keysyms1 \
libxcb-keysyms1-dev \
libxcb-randr0-dev \
libxcb-render-util0 \
libxcb-render-util0-dev \
libxcb-shape0-dev \
libxcb-shm0 \
libxcb-shm0-dev \
libxcb-sync-dev \
libxcb-sync1 \
libxcb-xfixes0-dev \
libxcb-xinerama0 \
libxcb-xinerama0-dev \
libxcb1 \
libxcb1-dev \
libxext-dev \
libxi-dev \
libxkbcommon-dev \
libxrender-dev \
libxslt1-dev \
libxss-dev \
libxtst-dev \
nodejs \
ruby \
va-driver-all \
wget
FROM debian:buster
# This list can most likely be slimmed down *a lot* but that's for another day.
RUN apt-get update && \
apt-get -y install \
bison \
build-essential \
cowsay \
flex \
freetds-dev \
g++ \
g++-multilib \
gcc-multilib \
git \
gperf \
gyp \
lib32z1-dev \
libasound2 \
libasound2-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libbz2-dev \
libcap-dev \
libdbus-1-dev \
libdbus-glib-1-dev \
libdrm-dev \
libegl1-mesa-dev \
libevent-dev \
libfontconfig1 \
libfontconfig1-dev \
libfreetype6 \
libgbm-dev \
libgcrypt20-dev \
libgles2-mesa-dev \
libinput-dev \
libjpeg62-turbo-dev \
libjsoncpp-dev \
libminizip-dev \
libnss3 \
libnss3-dev \
libopus-dev \
libpci-dev \
libpng16-16 \
libpulse-dev \
libsecret-1-0 \
libsnappy-dev \
libsrtp2-dev \
libssl-dev \
libssl1.1 \
libtiff5 \
libts-dev \
libudev-dev \
libvpx-dev \
libwebp-dev \
libxss-dev \
libxss1 \
libxtst-dev \
lsb-release \
ninja-build \
nodejs \
python \
rsync \
ruby \
subversion \
wget \
make && \
apt-get clean
WORKDIR /build
RUN wget -q https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py \
-O /usr/local/bin/sysroot-relativelinks.py && \
chmod +x /usr/local/bin/sysroot-relativelinks.py
RUN mkdir -p /sysroot/usr /sysroot/opt /sysroot/lib
COPY --from=builder /lib/ /sysroot/lib/
COPY --from=builder /usr/include/ /sysroot/usr/include/
COPY --from=builder /usr/lib/ /sysroot/usr/lib/
COPY --from=builder /opt/vc/ sysroot/opt/vc/
COPY . /webview
ENV BUILD_WEBENGINE 1
ENV BUILD_WEBVIEW 1
COPY build_qtbase_cross_compile.sh /usr/local/bin/
CMD /usr/local/bin/build_qtbase_cross_compile.sh

View File

@@ -1,251 +0,0 @@
#!/bin/bash
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# -*- sh-basic-offset: 4 -*-
set -exuo pipefail
BUILD_TARGET=/build
SRC=/src
QT_BRANCH="5.15.2"
DEBIAN_VERSION=$(lsb_release -cs)
mkdir -p "$BUILD_TARGET"
mkdir -p "$SRC"
/usr/games/cowsay -f tux "Building QT Base version $QT_BRANCH."
if [ "${BUILD_WEBENGINE-x}" == "1" ]; then
/usr/games/cowsay -f tux "...with QTWebEngine."
fi
function fetch_cross_compile_tool () {
# The Raspberry Pi Foundation's cross compiling tools are too old so we need newer ones.
# References:
# * https://github.com/UvinduW/Cross-Compiling-Qt-for-Raspberry-Pi-4
# * https://releases.linaro.org/components/toolchain/binaries/latest-7/armv8l-linux-gnueabihf/
if [ ! -d "/src/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf" ]; then
cd /src/
wget -q https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/arm-linux-gnueabihf/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf.tar.xz
tar xf gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf.tar.xz
rm gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf.tar.xz
fi
}
function fetch_rpi_firmware () {
if [ ! -d "/src/opt" ]; then
cd /src
# We do an `svn checkout` here as the entire git repo here is *huge*
# and `git` doesn't support partial checkouts well (yet)
svn checkout -q https://github.com/raspberrypi/firmware/trunk/opt
fi
rsync -aqP /src/opt/ /sysroot/opt/
}
function fetch_qt () {
local SRC_DIR="/src/qtbase"
if [ ! -d "$SRC_DIR" ]; then
git clone git://code.qt.io/qt/qtbase.git -b "$QT_BRANCH" "$SRC_DIR"
cd "$SRC_DIR"
git submodule init
git submodule update
else
cd "$SRC_DIR"
git reset --hard
git clean -dfx
fi
}
function fetch_qtdeclarative () {
local SRC_DIR="/src/qtdeclarative"
if [ ! -d "$SRC_DIR" ]; then
git clone git://code.qt.io/qt/qtdeclarative.git -b "$QT_BRANCH" "$SRC_DIR"
cd "$SRC_DIR"
git submodule init
git submodule update
else
cd "$SRC_DIR"
git reset --hard
git clean -dfx
fi
}
function fetch_qtwebchannel () {
local SRC_DIR="/src/qtwebchannel"
if [ ! -d "$SRC_DIR" ]; then
git clone git://code.qt.io/qt/qtwebchannel.git -b "$QT_BRANCH" "$SRC_DIR"
cd "$SRC_DIR"
git submodule init
git submodule update
else
cd "$SRC_DIR"
git reset --hard
git clean -dfx
fi
}
function fetch_qtwebengine () {
local SRC_DIR="/src/qtwebengine"
if [ ! -d "$SRC_DIR" ]; then
git clone git://code.qt.io/qt/qtwebengine.git -b "$QT_BRANCH" "$SRC_DIR"
cd "$SRC_DIR"
git submodule init
git submodule update
else
cd "$SRC_DIR"
git reset --hard
git clean -dfx
fi
# Patch up WebEngine due to GCC bug
# https://www.enricozini.org/blog/2020/qt5/build-qt5-cross-builder-with-raspbian-sysroot-compiling-with-the-sysroot/
cd "$SRC_DIR"
sed -i '1s/^/#pragma GCC push_options\n#pragma GCC optimize ("O0")\n/' src/3rdparty/chromium/third_party/skia/third_party/skcms/skcms.cc
echo "#pragma GCC pop_options" >> src/3rdparty/chromium/third_party/skia/third_party/skcms/skcms.cc
}
function build_qtbase () {
# This build process is inspired by
# https://www.tal.org/tutorials/building-qt-512-raspberry-pi
local SRC_DIR="/src/$1"
if [ ! -f "$BUILD_TARGET/qtbase-$QT_BRANCH-$DEBIAN_VERSION-$1.tar.gz" ]; then
/usr/games/cowsay -f tux "Building QT Base for $1"
mkdir -p "$SRC_DIR"
cd "$SRC_DIR"
if [ "$1" = "pi1" ]; then
local BUILD_ARGS=(
"-device" "linux-rasp-pi-g++"
)
elif [ "$1" = "pi2" ]; then
local BUILD_ARGS=(
"-device" "linux-rasp-pi2-g++"
)
elif [ "$1" = "pi3" ]; then
local BUILD_ARGS=(
"-device" "linux-rasp-pi3-g++"
)
elif [ "$1" = "pi4" ]; then
local BUILD_ARGS=(
"-device" "linux-rasp-pi4-v3d-g++"
)
else
echo "Unknown device. Exiting."
exit 1
fi
/src/qtbase/configure \
"${BUILD_ARGS[@]}" \
-confirm-license \
-dbus-linked \
-device-option CROSS_COMPILE=/src/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- \
-eglfs \
-evdev \
-extprefix "$SRC_DIR/qt5pi" \
-force-pkg-config \
-glib \
-no-compile-examples \
-no-cups \
-no-gbm \
-no-gtk \
-no-pch \
-no-use-gold-linker \
-nomake examples \
-nomake tests \
-opengl es2 \
-opensource \
-prefix /usr/local/qt5pi \
-qpa eglfs \
-qt-pcre \
-reduce-exports \
-release \
-skip qtandroidextras \
-skip qtcanvas3d \
-skip qtgamepad \
-skip qtlocation \
-skip qtmacextras \
-skip qtpurchasing \
-skip qtscript \
-skip qtwayland \
-skip qtwinextras \
-skip qtx11extras \
-ssl \
-system-freetype \
-system-libjpeg \
-system-libpng \
-system-zlib \
-sysroot /sysroot
make -j "$(nproc --all)"
make install
cp -r /usr/share/fonts/truetype/dejavu/ "$SRC_DIR/qt5pi/lib/fonts"
if [ "${BUILD_WEBENGINE-x}" == "1" ]; then
/usr/games/cowsay -f tux "Building QTDeclarative for $1"
fetch_qtdeclarative
cd /src/qtdeclarative
"$SRC_DIR/qt5pi/bin/qmake"
make -j"$(nproc --all)"
make install
/usr/games/cowsay -f tux "Building QTWebchannel for $1"
fetch_qtwebchannel
cd /src/qtwebchannel
"$SRC_DIR/qt5pi/bin/qmake"
make -j"$(nproc --all)"
make install
/usr/games/cowsay -f tux "Building QTWebEngine for $1"
fetch_qtwebengine
cd /src/qtwebengine
"$SRC_DIR/qt5pi/bin/qmake"
# Due to a bug, we can't specify a number of corse here.
# If we do, the build bcomes single threaded.
make -j
make install
fi
if [ "${BUILD_WEBVIEW-x}" == "1" ]; then
cp -rf /webview "$SRC_DIR/"
cd "$SRC_DIR/webview"
"$SRC_DIR/qt5pi/bin/qmake"
make -j"$(nproc --all)"
make install
mkdir -p fakeroot/bin fakeroot/share/ScreenlyWebview
mv ScreenlyWebview fakeroot/bin/
cp -rf /webview/res fakeroot/share/ScreenlyWebview/
cd fakeroot
tar cfz "$BUILD_TARGET/webview-$QT_BRANCH-$DEBIAN_VERSION-$1.tar.gz" .
cd "$BUILD_TARGET"
sha256sum "webview-$QT_BRANCH-$DEBIAN_VERSION-$1.tar.gz" > "webview-$QT_BRANCH-$DEBIAN_VERSION-$1.tar.gz.sha256"
fi
cd "$SRC_DIR"
tar cfz "$BUILD_TARGET/qtbase-$QT_BRANCH-$DEBIAN_VERSION-$1.tar.gz" qt5pi
cd "$BUILD_TARGET"
sha256sum "qtbase-$QT_BRANCH-$DEBIAN_VERSION-$1.tar.gz" > "qtbase-$QT_BRANCH-$DEBIAN_VERSION-$1.tar.gz.sha256"
else
echo "Build already exist."
fi
}
# Modify paths for build process
/usr/local/bin/sysroot-relativelinks.py /sysroot
fetch_qt
fetch_cross_compile_tool
fetch_rpi_firmware
# Let's work our way through all Pis in order of relevance
for device in pi4 pi3 pi2 pi1; do
build_qtbase "$device"
done