|
3 | 3 | sudo apt install -y lsb-release |
4 | 4 |
|
5 | 5 | qt_version="$1" |
6 | | -qt_modules="$(echo $2 | tr ' ' ',')" |
| 6 | + |
| 7 | +if [[ "$2" == "" ]]; then |
| 8 | + qt_modules="" |
| 9 | +else |
| 10 | + qt_modules=",$(echo $2 | tr ' ' ',')" |
| 11 | +fi |
| 12 | + |
7 | 13 | target_arch="$3" |
8 | 14 | root_path="$(pwd)" |
9 | | -sysroot_path="${root_path}/sysroot" |
10 | | -sysroot_ubuntu_version="$(lsb_release -rs).1" |
11 | | -sysroot_ubuntu_codename="$(lsb_release -cs)" |
12 | | -host_prefix="${root_path}/qt-host" |
13 | | -cross_prefix="${root_path}/qt-cross" |
| 15 | +#host_prefix="${root_path}/qt-host" |
| 16 | +host_prefix="$QT_HOST_PATH" |
| 17 | +cross_prefix="$QT_CROSS_PATH" |
14 | 18 | target_prefix="/usr/local/qt" |
15 | | -toolchain_config="${root_path}/.ci/qt6-toolchain.cmake" |
16 | | - |
17 | | -case "$target_arch" in |
18 | | - aarch64) |
19 | | - target_arch_name="armv8-a" |
20 | | - toolchain_name="aarch64-linux-gnu" |
21 | | - target_platform="linux-aarch64-gnu-g++" |
22 | | - ;; |
23 | | - armv7) |
24 | | - target_arch_name="armv7-a" |
25 | | - toolchain_name="arm-linux-gnueabihf" |
26 | | - target_platform="linux-arm-gnueabi-g++" |
27 | | - ;; |
28 | | -esac |
29 | | - |
30 | | -toolchain_prefix="${toolchain_name}-" |
31 | | - |
32 | | -case "$target_arch" in |
33 | | - aarch64) |
34 | | - target_arch_debian_name="arm64" |
35 | | - ;; |
36 | | - armv7) |
37 | | - target_arch_debian_name="armhf" |
38 | | - ;; |
39 | | -esac |
40 | 19 |
|
41 | 20 | echo "Qt version to build: ${qt_version}" |
42 | 21 | echo "Qt modules: ${qt_modules}" |
43 | | -echo "Target architecture: ${target_arch} (${target_arch_name})" |
44 | | - |
45 | | -# Install dependencies |
46 | | -${root_path}/.ci/qt6_deps.sh || exit 1 |
47 | | -${root_path}/.ci/install_cross_compiler.sh "${target_arch}" || exit 1 |
48 | | -sudo apt install -y qemu-user-static || exit 1 |
49 | | -sudo apt install -y symlinks || exit 1 |
| 22 | +echo "Target architecture: ${target_arch} (${BUILD_ARCH_NAME})" |
50 | 23 |
|
51 | 24 | # Clone Qt |
52 | 25 | git clone https://github.com/qt/qt5 qt || exit 1 |
53 | 26 | cd qt |
54 | | -git checkout "v$qt_version" || exit 1 |
55 | | -./init-repository --module-subset=qtbase,qttools,qtdeclarative,qtsvg,${qt_modules} || exit 1 |
| 27 | +git checkout $(git tag | grep '^v6\.8\.[0-9]*$' | sort -V | tail -n 1) || exit 1 |
| 28 | +./init-repository --module-subset=qtbase,qttools,qtdeclarative,qtsvg${qt_modules} || exit 1 |
56 | 29 |
|
57 | 30 | # Build Qt (host) |
58 | | -mkdir host-build |
59 | | -cd host-build |
60 | | -echo "Building host Qt..." |
61 | | -../configure -release -nomake examples -nomake tests -opensource -confirm-license -prefix "$host_prefix" || exit 1 |
62 | | -cmake --build . --parallel $(nproc --all) || exit 1 |
63 | | -echo "Installing host Qt..." |
64 | | -cmake --install . || exit 1 |
65 | | -cd .. |
66 | | -rm -rf host-build |
67 | | - |
68 | | -# Prepare sysroot |
69 | | -echo "Preparing sysroot..." |
70 | | -curl "https://cdimage.ubuntu.com/ubuntu-base/releases/${sysroot_ubuntu_codename}/release/ubuntu-base-${sysroot_ubuntu_version}-base-${target_arch_debian_name}.tar.gz" > ./ubuntu-base.tar.gz || exit 1 |
71 | | -mkdir -p "$sysroot_path" |
72 | | -sudo tar -xvzf ubuntu-base.tar.gz -C "$sysroot_path" || exit 1 |
73 | | -sudo update-binfmts --enable qemu-arm || exit 1 |
74 | | -sudo mount -o bind /dev "${sysroot_path}/dev" || exit 1 |
75 | | -sudo cp /etc/resolv.conf "${sysroot_path}/etc" || exit 1 |
76 | | -sudo chmod 1777 "${sysroot_path}/tmp" || exit 1 |
77 | | -sudo cp "${root_path}/.ci/qt6_deps.sh" "${sysroot_path}/" |
78 | | -sudo chroot "$sysroot_path" /bin/bash -c "/qt6_deps.sh" || exit 1 |
79 | | -sudo chroot "$sysroot_path" /bin/bash -c "apt install -y symlinks && symlinks -rc /" || exit 1 |
| 31 | +#mkdir host-build |
| 32 | +#cd host-build |
| 33 | +#echo "Building host Qt..." |
| 34 | +#../configure -release -nomake examples -nomake tests -opensource -confirm-license -prefix "$host_prefix" || exit 1 |
| 35 | +#cmake --build . --parallel $(nproc --all) || exit 1 |
| 36 | +#echo "Installing host Qt..." |
| 37 | +#cmake --install . || exit 1 |
| 38 | +#cd .. |
| 39 | +#rm -rf host-build |
80 | 40 |
|
81 | 41 | # Build Qt (cross) |
82 | 42 | mkdir cross-build |
83 | 43 | cd cross-build |
84 | 44 | echo "Cross-compiling Qt..." |
85 | | -export BUILD_SYSROOT_PATH=${sysroot_path} |
86 | | -export BUILD_TOOLCHAIN_NAME=${toolchain_name} |
87 | | -export BUILD_TOOLCHAIN_PREFIX=${toolchain_prefix} |
88 | | -export BUILD_ARCH_NAME=${target_arch_name} |
89 | | -../configure -release -opengl es2 -nomake examples -nomake tests -qt-host-path "$host_prefix" -xplatform "$target_platform" \ |
90 | | - -device-option CROSS_COMPILE="$toolchain_prefix" -sysroot "$sysroot_path" -opensource -confirm-license \ |
91 | | - -prefix "$target_prefix" -extprefix "$cross_prefix" -- -DCMAKE_TOOLCHAIN_FILE="$toolchain_config" \ |
| 45 | +../configure -release -opengl es2 -nomake examples -nomake tests -qt-host-path "$host_prefix" -xplatform "$BUILD_PLATFORM" \ |
| 46 | + -device-option CROSS_COMPILE="$BUILD_TOOLCHAIN_PREFIX" -sysroot "$BUILD_SYSROOT_PATH" -opensource -confirm-license \ |
| 47 | + -prefix "$target_prefix" -extprefix "$cross_prefix" -- -DCMAKE_TOOLCHAIN_FILE="$BUILD_TOOLCHAIN_CONFIG" \ |
92 | 48 | -DQT_FEATURE_xcb=ON -DFEATURE_xcb_xlib=ON -DQT_FEATURE_xlib=ON || exit 1 |
93 | 49 | cmake --build . --parallel $(nproc --all) || exit 1 |
94 | 50 | echo "Installing cross-compiled Qt..." |
95 | 51 | cmake --install . || exit 1 |
96 | 52 | cd .. |
97 | | -rm -rf cross-build |
98 | 53 |
|
99 | 54 | # Cleanup |
100 | | -sudo umount "${sysroot_path}/dev" || exit 1 |
101 | 55 | cd .. |
102 | 56 | rm -rf qt |
103 | 57 | # Required for cache |
104 | | -sudo chmod 777 -R ${sysroot_path} |
| 58 | +sudo chmod 777 -R ${BUILD_SYSROOT_PATH} |
0 commit comments