Skip to content

Commit ce374ff

Browse files
committed
Make qt build multistage
1 parent 3279e0e commit ce374ff

2 files changed

Lines changed: 115 additions & 97 deletions

File tree

qt/Dockerfile

Lines changed: 63 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,44 @@
11
# Full Qt toolchain for the reMarkable
22
ARG FROM
3-
FROM $FROM
3+
FROM $FROM AS qt6base
44

5-
# Build Qt 5.15.1 targeting armhf
6-
COPY linux-arm-remarkable-g++ /linux-arm-remarkable-g++
7-
COPY linux-aarch64-remarkable-g++ /linux-aarch64-remarkable-g++
5+
# Install build dependencies
86
RUN export DEBIAN_FRONTEND=noninteractive \
9-
# Install build dependencies
107
&& apt-get update -y \
118
&& apt-get install -y --no-install-recommends \
12-
libudev-dev \
13-
# Build Qt
14-
&& cd /root \
15-
&& git clone https://code.qt.io/qt/qt5.git \
16-
&& cd qt5 \
9+
libudev-dev
10+
11+
# Build Qt
12+
RUN cd /root \
13+
&& git clone https://code.qt.io/qt/qt5.git qt6 \
14+
&& cd qt6 \
1715
&& git switch 6.7.3 \
18-
&& GIT_ASKPASS="/bin/echo" perl init-repository --module-subset=qtbase,qtshadertools,qtdeclarative \
19-
# Setup reMarkable mkspec
20-
&& mv /linux-arm-remarkable-g++ qtbase/mkspecs/devices \
21-
&& mv /linux-aarch64-remarkable-g++ qtbase/mkspecs/devices \
22-
&& cd .. \
23-
# Build for host machine (required from Qt6+)
24-
&& bash -c 'source /opt/x-tools/switch-aarch64.sh \
25-
&& mkdir qt5-build \
26-
&& cd qt5-build \
27-
&& unset SYSROOT \
28-
&& unset PKG_CONFIG_SYSROOT_DIR \
29-
&& ../qt5/configure \
16+
&& GIT_ASKPASS="/bin/echo" perl init-repository --module-subset=qtbase,qtshadertools,qtdeclarative
17+
18+
COPY linux-arm-remarkable-g++ /root/qt6/qtbase/mkspecs/devices/linux-arm-remarkable-g++
19+
COPY linux-aarch64-remarkable-g++ /root/qt6/qtbase/mkspecs/devices/linux-aarch64-remarkable-g++
20+
21+
# Build host
22+
RUN mkdir qt6-build \
23+
&& cd qt6-build \
24+
&& /root/qt6/configure \
3025
-prefix /usr \
3126
-no-opengl \
3227
-no-widgets \
3328
-no-feature-sql \
3429
-- -DQT_BUILD_EXAMPLES=OFF \
3530
-DQT_BUILD_TESTS=OFF \
3631
&& cmake --build . --parallel $(nproc) \
37-
&& cmake --install . \
38-
&& cd .. \
39-
# Clean up
40-
&& rm -rf qt5-build \
41-
# Build for armhf
42-
&& export SYSROOT=/opt/x-tools/arm-remarkable-linux-gnueabihf/arm-remarkable-linux-gnueabihf/sysroot \
43-
&& export PKG_CONFIG_SYSROOT_DIR="$SYSROOT" \
44-
&& mkdir qt5-build \
45-
&& cd qt5-build \
46-
&& ../qt5/configure \
32+
&& cmake --install .
33+
34+
FROM qt6base AS arm
35+
36+
# Build arm
37+
RUN rm -r qt6-build \
38+
&& mkdir qt6-build \
39+
&& cd qt6-build \
40+
&& bash -c 'source /opt/x-tools/switch-arm.sh \
41+
&& /root/qt6/configure \
4742
-prefix /usr \
4843
-extprefix $SYSROOT/usr \
4944
-device linux-arm-remarkable-g++ \
@@ -56,17 +51,16 @@ RUN export DEBIAN_FRONTEND=noninteractive \
5651
-DQT_BUILD_EXAMPLES=OFF \
5752
-DQT_BUILD_TESTS=OFF \
5853
-DCMAKE_TOOLCHAIN_FILE=/usr/share/cmake/arm-linux-gnueabihf.cmake \
59-
&& cmake --build . --parallel $(nproc) \
60-
&& cmake --install . \
61-
&& cd .. \
62-
# Clean up
63-
&& rm -rf qt5-build \
64-
&& find "$SYSROOT" -type l,f -name "*.la" | xargs --no-run-if-empty rm' \
65-
# Now Build AArch64
54+
&& cmake --build . --parallel $(nproc)'
55+
56+
FROM qt6base AS aarch64
57+
58+
# Build aarch64
59+
RUN rm -r qt6-build \
60+
&& mkdir qt6-build \
61+
&& cd qt6-build \
6662
&& bash -c 'source /opt/x-tools/switch-aarch64.sh \
67-
&& mkdir qt5-build \
68-
&& cd qt5-build \
69-
&& ../qt5/configure \
63+
&& /root/qt6/configure \
7064
-prefix /usr \
7165
-extprefix $SYSROOT/usr \
7266
-device linux-aarch64-remarkable-g++ \
@@ -80,12 +74,36 @@ RUN export DEBIAN_FRONTEND=noninteractive \
8074
-DQT_BUILD_EXAMPLES=OFF \
8175
-DQT_BUILD_TESTS=OFF \
8276
-DCMAKE_TOOLCHAIN_FILE=/usr/share/cmake/aarch64-remarkable-linux-gnu.cmake \
83-
&& cmake --build . --parallel $(nproc) \
77+
&& cmake --build . --parallel $(nproc)'
78+
79+
FROM $FROM AS final
80+
81+
RUN --mount=target=/root/qt6,from=qt6base,src=/root/qt6 \
82+
--mount=target=qt6-host,from=qt6base,src=qt6-build \
83+
--mount=target=qt6-arm,from=arm,src=qt6-build \
84+
--mount=target=qt6-aarch64,from=aarch64,src=qt6-build \
85+
# Install build dependenciesh
86+
export DEBIAN_FRONTEND=noninteractive \
87+
&& apt-get update -y \
88+
&& apt-get install -y --no-install-recommends \
89+
libudev-dev \
90+
&& cp -r qt6-host qt6-build \
91+
&& cd qt6-build \
8492
&& cmake --install . \
8593
&& cd .. \
86-
&& rm -rf qt5-build \
94+
&& rm -r qt6-build \
95+
&& cp -r qt6-arm qt6-build \
96+
&& bash -c 'source /opt/x-tools/switch-arm.sh \
97+
&& cd qt6-build \
98+
&& cmake --install . \
99+
&& find "$SYSROOT" -type l,f -name "*.la" | xargs --no-run-if-empty rm' \
100+
&& rm -r qt6-build \
101+
&& cp -r qt6-aarch64 qt6-build \
102+
&& bash -c 'source /opt/x-tools/switch-aarch64.sh \
103+
&& cd qt6-build \
104+
&& cmake --install . \
87105
&& find "$SYSROOT" -type l,f -name "*.la" | xargs --no-run-if-empty rm' \
106+
&& rm -r qt6-build \
88107
&& apt-get autoremove -y \
89108
&& apt-get clean \
90109
&& rm -rf /var/lib/apt/lists/* /var/log/dpkg.log /var/log/apt
91-

toolchain/Dockerfile

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,43 @@ ARG CHOST_AARCH64="aarch64-remarkable-linux-gnu"
99
RUN export DEBIAN_FRONTEND=noninteractive \
1010
&& apt-get update -y \
1111
&& apt-get install -y --no-install-recommends \
12-
build-essential \
13-
ca-certificates \
14-
cmake \
15-
curl \
16-
gcc-11 \
17-
g++-11 \
18-
meson \
19-
pkg-config \
20-
git \
21-
git-lfs \
12+
build-essential \
13+
ca-certificates \
14+
cmake \
15+
curl \
16+
gcc-11 \
17+
g++-11 \
18+
meson \
19+
pkg-config \
20+
git \
21+
git-lfs \
2222
&& apt-get clean \
2323
&& rm -rf /var/lib/apt/lists/* /var/log/dpkg.log /var/log/apt \
2424
# Force use of gcc and g++ 11
2525
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11 \
26-
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 \
27-
--slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-11 \
28-
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11 \
29-
--slave /usr/bin/g++ g++ /usr/bin/g++-11
26+
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 \
27+
--slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-11 \
28+
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11 \
29+
--slave /usr/bin/g++ g++ /usr/bin/g++-11
3030

3131
# Build latest crosstool-ng and use it to build the toolchain
3232
COPY crosstool-ng "/$NGCONFIG"
3333
RUN export DEBIAN_FRONTEND=noninteractive \
3434
# Install build dependencies
3535
&& apt-get update -y \
3636
&& apt-get install -y --no-install-recommends \
37-
autoconf \
38-
automake \
39-
bison \
40-
file \
41-
flex \
42-
gawk \
43-
help2man \
44-
libncurses-dev \
45-
libtool-bin \
46-
rsync \
47-
texinfo \
48-
unzip \
37+
autoconf \
38+
automake \
39+
bison \
40+
file \
41+
flex \
42+
gawk \
43+
help2man \
44+
libncurses-dev \
45+
libtool-bin \
46+
rsync \
47+
texinfo \
48+
unzip \
4949
# Build crosstool-ng itself
5050
&& cd /root \
5151
&& git clone https://github.com/crosstool-ng/crosstool-ng \
@@ -91,18 +91,18 @@ RUN export DEBIAN_FRONTEND=noninteractive \
9191
&& find "/opt/x-tools/$NGCONFIG_AARCH64/$NGCONFIG_AARCH64" -type l,f -name "*.la" -delete \
9292
&& rm "/opt/x-tools/$NGCONFIG_AARCH64/build.log.bz2" \
9393
&& apt-get autoremove -y \
94-
autoconf \
95-
automake \
96-
bison \
97-
file \
98-
flex \
99-
gawk \
100-
help2man \
101-
libncurses-dev \
102-
libtool-bin \
103-
rsync \
104-
texinfo \
105-
unzip \
94+
autoconf \
95+
automake \
96+
bison \
97+
file \
98+
flex \
99+
gawk \
100+
help2man \
101+
libncurses-dev \
102+
libtool-bin \
103+
rsync \
104+
texinfo \
105+
unzip \
106106
&& apt-get clean \
107107
&& rm -rf /var/lib/apt/lists/* /var/log/dpkg.log /var/log/apt
108108

@@ -111,39 +111,39 @@ RUN export DEBIAN_FRONTEND=noninteractive \
111111
# Install build dependencies
112112
&& apt-get update -y \
113113
&& apt-get install -y --no-install-recommends \
114-
automake \
115-
libarchive-dev \
116-
libcurl4-gnutls-dev \
117-
libgpgme-dev \
118-
libssl-dev \
119-
libtool-bin \
114+
automake \
115+
libarchive-dev \
116+
libcurl4-gnutls-dev \
117+
libgpgme-dev \
118+
libssl-dev \
119+
libtool-bin \
120120
&& cd /root \
121121
&& git clone --depth 1 --branch v0.4.5 https://git.yoctoproject.org/git/opkg \
122122
&& cd opkg \
123123
&& ./autogen.sh \
124124
&& ./configure \
125-
--enable-sha256 \
126-
--prefix=/ \
127-
--exec-prefix=/usr \
125+
--enable-sha256 \
126+
--prefix=/ \
127+
--exec-prefix=/usr \
128128
&& make -j$(nproc) \
129129
&& make install \
130130
&& cd .. \
131131
# Clean up
132132
&& rm -rf opkg \
133133
&& rm /usr/lib/libopkg.la \
134134
&& apt-get autoremove -y \
135-
automake \
136-
libarchive-dev \
137-
libssl-dev \
138-
libtool-bin \
135+
automake \
136+
libarchive-dev \
137+
libssl-dev \
138+
libtool-bin \
139139
&& apt-get clean \
140140
&& rm -rf /var/lib/apt/lists/* /var/log/dpkg.log /var/log/apt
141141

142142
RUN touch /opt/x-tools/switch-arm.sh && chmod +x /opt/x-tools/switch-arm.sh && cat <<EOF > /opt/x-tools/switch-arm.sh
143143
export ARCH=arm
144144
export CHOST="$CHOST"
145145
export CROSS_COMPILE="$CHOST-"
146-
PATH="\$PATH:/opt/x-tools/$NGCONFIG/bin"
146+
export PATH="\$PATH:/opt/x-tools/$NGCONFIG/bin"
147147
export PKG_CONFIG_LIBDIR="/opt/x-tools/$NGCONFIG/$NGCONFIG/sysroot/usr/lib/pkgconfig:/opt/x-tools/$NGCONFIG/$NGCONFIG/sysroot/lib/pkgconfig:/opt/x-tools/$NGCONFIG/$NGCONFIG/sysroot/opt/lib/pkgconfig"
148148
export PKG_CONFIG_SYSROOT_DIR="/opt/x-tools/$NGCONFIG/$NGCONFIG/sysroot"
149149
export SYSROOT="/opt/x-tools/$NGCONFIG/$NGCONFIG/sysroot"

0 commit comments

Comments
 (0)