Skip to content

Commit 0ff1ba9

Browse files
committed
[CES-3162] Implement ultimaker build system and CI support
1 parent a441088 commit 0ff1ba9

File tree

8 files changed

+240
-195
lines changed

8 files changed

+240
-195
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build package on Push
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
tags-ignore:
8+
- 'docker_img-v*'
9+
10+
jobs:
11+
Prepare:
12+
name: 'Prepare'
13+
uses: Ultimaker/embedded-workflows/.github/workflows/prepare_env.yml@main
14+
secrets: inherit
15+
16+
Shellcheck:
17+
name: 'Test'
18+
needs: Prepare
19+
uses: Ultimaker/embedded-workflows/.github/workflows/shellcheck.yml@main
20+
secrets: inherit
21+
22+
Build:
23+
name: 'Build'
24+
needs: Prepare
25+
uses: Ultimaker/embedded-workflows/.github/workflows/build.yml@main
26+
with:
27+
RELEASE_VERSION: ${{ needs.Prepare.outputs.RELEASE_VERSION }}
28+
secrets: inherit
29+
30+
Release_Package:
31+
name: 'Release'
32+
needs: [Prepare, Shellcheck, Build]
33+
if: ${{ (success() && needs.Prepare.outputs.RELEASE_REPO != 'none') ||
34+
(failure() && needs.Build.result == 'success' && needs.Prepare.outputs.RELEASE_REPO == 'packages-dev') }}
35+
uses: Ultimaker/embedded-workflows/.github/workflows/release_pkg.yml@main
36+
with:
37+
RELEASE_REPO: ${{ needs.Prepare.outputs.RELEASE_REPO }}
38+
secrets: inherit
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Release a new docker image upon tagging
2+
3+
on:
4+
push:
5+
tags:
6+
- 'docker_img-v[0-9a-zA-Z]+'
7+
8+
9+
jobs:
10+
Release:
11+
name: 'Release'
12+
uses: Ultimaker/embedded-workflows/.github/workflows/release_docker_img.yml@main
13+
with:
14+
DOCKER_IMAGE_NAME: 'qt5-ultimaker'
15+
DOCKER_TAG_PREFIX: 'docker_img-'
16+
secrets: inherit

build.sh

Lines changed: 62 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,67 @@ ARCH="${ARCH:-arm64}" # armhf or x86_64 or amr64
77
UM_ARCH="${UM_ARCH:-imx8m}" # Empty string, or sun7i for R1, or imx6dl for R2, or imx8m for colorado
88

99
SRC_DIR="$(pwd)"
10+
BUILD_DIR_TEMPLATE="_build"
1011
BUILD_DIR="${BUILD_DIR:-${SRC_DIR}/${BUILD_DIR_TEMPLATE}_${ARCH}_${UM_ARCH}}"
1112

13+
1214
# Debian package information
1315
PACKAGE_NAME="${PACKAGE_NAME:-qt-ultimaker}"
1416
QT_VERSION="5.12.3"
1517
RELEASE_VERSION="${RELEASE_VERSION:-${QT_VERSION}}"
16-
EXTRA_VERSION="${EXTRA_VERSION:-eglfs}"
1718

1819
DEBIAN_DIR="${BUILD_DIR}/debian"
1920
TARGET_DIR="${DEBIAN_DIR}/opt"
2021
CROSS_COMPILE="aarch64-linux-gnu-"
2122

2223
TOOLS_DIR="${SRC_DIR}/tools"
23-
SYSROOT="${TOOLS_DIR}/sysroot"
24-
MAKEFLAGS=-j$(($(getconf _NPROCESSORS_ONLN) - 1))
24+
SYSROOT="${BUILD_DIR}/sysroot"
25+
26+
cpu_cnt="$(nproc)"
27+
export MAKEFLAGS="-j${cpu_cnt}"
28+
export CCACHE_DIR="${BUILD_DIR}/ccache"
2529

2630
PYQT_TARGET_PYTHON_VERSION="3.11"
2731

2832
export PKG_CONFIG_PATH=${SYSROOT}/usr/lib/pkgconfig:${SYSROOT}/usr/lib/arm-linux-gnueabihf/pkgconfig:${SYSROOT}/usr/share/pkgconfig:${SYSROOT}/usr/local/lib/pkgconfig
2933

34+
build_sysroot()
35+
{
36+
echo "Going to build sysroot for cross compiling"
37+
38+
mkdir -p "${SYSROOT}/etc/apt/trusted.gpg.d"
39+
rm -rf "${SYSROOT}/etc/apt/trusted.gpg.d/debian-keyring.gpg"
40+
curl https://ftp-master.debian.org/keys/archive-key-11.asc | gpg --dearmor >> "${SYSROOT}/etc/apt/trusted.gpg.d/debian-keyring.gpg"
41+
curl https://ftp-master.debian.org/keys/release-11.asc | gpg --dearmor >> "${SYSROOT}/etc/apt/trusted.gpg.d/debian-keyring.gpg"
42+
43+
multistrap -f "${TOOLS_DIR}/sysroot_multistrap.cfg" -d "${SYSROOT}"
44+
45+
# Fix up the symlinks in the sysroot, find all links that start with absolute paths
46+
# and replace them with relative paths inside the sysroot.
47+
cd "${SYSROOT}"
48+
symlinks="$(find . -type l)"
49+
for file in ${symlinks}
50+
do
51+
link="$(readlink "${file}" || echo '')"
52+
if [ -n "${link}" ]
53+
then
54+
if [ "${link:0:1}" == "/" ]
55+
then
56+
if [ -e "${SYSROOT}/${link}" ]; then
57+
rm "${file}"
58+
ln --relative -sf "${SYSROOT}${link}" "${file}"
59+
fi
60+
fi
61+
fi
62+
done
63+
cd "${SRC_DIR}"
64+
65+
echo "Finished building sysroot in: ${SYSROOT}"
66+
}
67+
3068
build()
3169
{
32-
if [ ! -d "${TARGET_DIR}/qt" ]; then
33-
mkdir -p "${TARGET_DIR}/qt"
34-
fi
70+
mkdir -p "${TARGET_DIR}/qt"
3571

3672
cd "${BUILD_DIR}"
3773
"${SRC_DIR}/configure" \
@@ -98,9 +134,7 @@ build()
98134
# -compile-examples \
99135
# -examplesdir /usr/share/examples \
100136

101-
if [ ! -d "${TOOLS_DIR}/ccache" ]; then
102-
mkdir -p "${TOOLS_DIR}/ccache"
103-
fi
137+
mkdir -p "${CCACHE_DIR}"
104138

105139
make "${MAKEFLAGS}"
106140
make "${MAKEFLAGS}" install
@@ -110,9 +144,7 @@ build()
110144

111145
build_pyqt()
112146
{
113-
if [ ! -d "${BUILD_DIR}/pyqt" ]; then
114-
mkdir -p "${BUILD_DIR}/pyqt"
115-
fi
147+
mkdir -p "${BUILD_DIR}/pyqt"
116148

117149
cd "${BUILD_DIR}/pyqt"
118150
curl -L -o pyqt5.tar.gz https://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.9.2/PyQt5_gpl-5.9.2.tar.gz
@@ -126,7 +158,10 @@ build_pyqt()
126158
--destdir "${TARGET_DIR}/pyqt" \
127159
--configuration "${TOOLS_DIR}/pyqt.cfg" \
128160
--target-py-version="${PYQT_TARGET_PYTHON_VERSION}" \
129-
--qmake="${BUILD_DIR}/qtbase/bin/qmake"
161+
--qmake="${BUILD_DIR}/qtbase/bin/qmake" \
162+
--no-sip-files \
163+
--no-stubs \
164+
--no-tools
130165

131166
make "${MAKEFLAGS}"
132167
make "${MAKEFLAGS}" install
@@ -139,10 +174,10 @@ create_debian_package()
139174
mkdir -p "${DEBIAN_DIR}/DEBIAN"
140175
sed -e 's|@ARCH@|'"${ARCH}"'|g' \
141176
-e 's|@PACKAGE_NAME@|'"${PACKAGE_NAME}"'|g' \
142-
-e 's|@RELEASE_VERSION@|'"${RELEASE_VERSION}-${UM_ARCH}+${EXTRA_VERSION}"'|g' \
177+
-e 's|@RELEASE_VERSION@|'"${RELEASE_VERSION}-${UM_ARCH}"'|g' \
143178
"${SRC_DIR}/debian/control.in" > "${DEBIAN_DIR}/DEBIAN/control"
144179

145-
DEB_PACKAGE="${PACKAGE_NAME}_${RELEASE_VERSION}_${ARCH}-${UM_ARCH}_${EXTRA_VERSION}.deb"
180+
DEB_PACKAGE="${PACKAGE_NAME}_${RELEASE_VERSION}_${ARCH}-${UM_ARCH}.deb"
146181

147182
# Add the QT runtime environment source script
148183
mkdir -p "${DEBIAN_DIR}/etc/qt5"
@@ -153,6 +188,8 @@ create_debian_package()
153188
# Build the Debian package
154189
dpkg-deb --build "${DEBIAN_DIR}" "${BUILD_DIR}/${DEB_PACKAGE}"
155190

191+
mv "${BUILD_DIR}/${DEB_PACKAGE}" "${SRC_DIR}"
192+
156193
echo "Finished building Debian package."
157194
echo "To check the contents of the Debian package run 'dpkg-deb -c *.deb'"
158195
}
@@ -199,7 +236,15 @@ if [ "${#}" -gt 1 ]; then
199236
exit 1
200237
fi
201238

239+
240+
# Clean any lingering file from previous build
241+
clean_debian_dir() {
242+
rm -rf "${DEBIAN_DIR}"
243+
}
244+
202245
if [ "${#}" -eq 0 ]; then
246+
build_sysroot
247+
clean_debian_dir
203248
build
204249
build_pyqt
205250
create_debian_package
@@ -208,6 +253,8 @@ fi
208253

209254
case "${1-}" in
210255
deb)
256+
build_sysroot
257+
clean_debian_dir
211258
build
212259
build_pyqt
213260
create_debian_package

0 commit comments

Comments
 (0)