Skip to content

Commit

Permalink
Apply Fix for Qt running in Snap Packages (#214)
Browse files Browse the repository at this point in the history
- Apply fix for QDesktopServices/linux to fix issue with Snap confinements (https://bugs.launchpad.net/ubuntu/+source/qtbase-opensource-src/+bug/1876237)
- Remove openssl dependency since its no longer used
- Minor script fixes
- Update rev numbers for Linux (and aarch64)
- Fix the 'custom_install_cmd' for Qt to reflect updates on how custom scripts are interpreted in the build config files
- Add 3P OpenSSL dependency to Qt (to use O3DE static openssl instead of the system one)
- Add qt patch for mac

Signed-off-by: Steve Pham <[email protected]>
  • Loading branch information
spham-amzn authored Sep 19, 2023
1 parent 025ebab commit f2df42b
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 27 deletions.
5 changes: 3 additions & 2 deletions package-system/Qt/build-linux-aarch64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

TIFF_PACKAGE=tiff-4.2.0.15-rev3-linux-aarch64
ZLIB_PACKAGE=zlib-1.2.11-rev5-linux-aarch64
OPENSSL_PACKAGE=OpenSSL-1.1.1t-rev1-linux-aarch64

./build-linux.sh $TIFF_PACKAGE $ZLIB_PACKAGE || exit 1
./build-linux.sh $TIFF_PACKAGE $ZLIB_PACKAGE $OPENSSL_PACKAGE

exit 0
exit $?
5 changes: 3 additions & 2 deletions package-system/Qt/build-linux-x86.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

TIFF_PACKAGE=tiff-4.2.0.15-rev3-linux
ZLIB_PACKAGE=zlib-1.2.11-rev5-linux
OPENSSL_PACKAGE=OpenSSL-1.1.1t-rev1-linux

./build-linux.sh $TIFF_PACKAGE $ZLIB_PACKAGE || exit 1
./build-linux.sh $TIFF_PACKAGE $ZLIB_PACKAGE $OPENSSL_PACKAGE

exit 0
exit $?
20 changes: 15 additions & 5 deletions package-system/Qt/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ TIFF_FOLDER_NAME=$1
# Arg 2: The zlib package name
ZLIB_FOLDER_NAME=$2

# Arg 3: The openssl package name
OPENSSL_FOLDER_NAME=$3

# Make sure docker is installed
DOCKER_VERSION=$(docker --version)
if [ $? -ne 0 ]
Expand Down Expand Up @@ -51,7 +54,7 @@ fi

# Run the Docker Image
echo "Running docker build script"
docker run -v $TEMP_FOLDER/src:/data/workspace/src -v $TEMP_FOLDER/$TIFF_FOLDER_NAME:/data/workspace/$TIFF_FOLDER_NAME -v $TEMP_FOLDER/$ZLIB_FOLDER_NAME:/data/workspace/$ZLIB_FOLDER_NAME --tty ${DOCKER_IMAGE_NAME}:latest ./docker_build_qt_linux.sh
docker run -v $TEMP_FOLDER/src:/data/workspace/src -v $TEMP_FOLDER/$TIFF_FOLDER_NAME:/data/workspace/o3de_tiff -v $TEMP_FOLDER/$ZLIB_FOLDER_NAME:/data/workspace/o3de_zlib -v $TEMP_FOLDER/$OPENSSL_FOLDER_NAME:/data/workspace/o3de_openssl --tty ${DOCKER_IMAGE_NAME}:latest ./docker_build_qt_linux.sh
if [ $? -ne 0 ]
then
echo "Error occurred running Docker image ${DOCKER_IMAGE_NAME}:latest."
Expand All @@ -71,20 +74,27 @@ fi

# Copy the build artifacts from the Docker Container
echo "Copying the built contents from the docker container for image ${DOCKER_IMAGE_NAME}"
docker cp --quiet $CONTAINER_ID:/data/workspace/qt/. $TARGET_INSTALL_ROOT
docker cp $CONTAINER_ID:/data/workspace/qt/. $TARGET_INSTALL_ROOT
if [ $? -ne 0 ]
then
echo "Error occurred copying build artifacts from Docker image ${DOCKER_IMAGE_NAME}:latest."
exit 1
fi


# Clean up the docker image and container
echo "Cleaning up container"
docker container rm $CONTAINER_ID || (echo "Warning: Unable to clean up container for image ${DOCKER_IMAGE_NAME}")
docker container rm $CONTAINER_ID
if [ $? -ne 0 ]
then
echo "Warning: Unable to clean up container for image ${DOCKER_IMAGE_NAME}"
fi

echo "Cleaning up image"
docker rmi --force $IMAGE_ID || (echo "Warning: Unable to clean up image ${DOCKER_IMAGE_NAME}")
docker rmi --force $IMAGE_ID
if [ $? -ne 0 ]
then
echo "Warning: Unable to clean up image ${DOCKER_IMAGE_NAME}"
fi

popd

Expand Down
20 changes: 11 additions & 9 deletions package-system/Qt/build_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
"build-windows.bat"
],
"custom_install_cmd": [
"copy_platform_cmakes.py"
"{python}", "copy_platform_cmakes.py"
]
}
},
"Darwin": {
"Mac": {
"cmake_find_source": "FindQt.cmake.mac",
"package_version": "5.15.2-rev8",
"patch_file": "qt-image-format.patch",
"patch_file": "qt-mac.patch",
"depends_on_packages": [
["tiff-4.2.0.15-rev3-mac", "c2615ccdadcc0e1d6c5ed61e5965c4d3a82193d206591b79b805c3b3ff35a4bf", ""],
["zlib-1.2.11-rev5-mac", "b6fea9c79b8bf106d4703b67fecaa133f832ad28696c2ceef45fb5f20013c096", ""]
Expand All @@ -43,37 +43,39 @@
"./build-darwin.sh"
],
"custom_install_cmd": [
"{python} copy_platform_cmakes.py"
"{python}", "copy_platform_cmakes.py"
]
}
},
"Linux": {
"Linux": {
"package_version": "5.15.2-rev8",
"patch_file": "qt-image-format.patch",
"package_version": "5.15.2-rev9",
"patch_file": "qt-linux.patch",
"depends_on_packages": [
["OpenSSL-1.1.1t-rev1-linux", "63aea898b7afe8faccd0c7261e62d2f8b7b870f678a4520d5be81e5815542b39", ""],
["tiff-4.2.0.15-rev3-linux", "2377f48b2ebc2d1628d9f65186c881544c92891312abe478a20d10b85877409a", ""],
["zlib-1.2.11-rev5-linux", "9be5ea85722fc27a8645a9c8a812669d107c68e6baa2ca0740872eaeb6a8b0fc", ""]
],
"custom_build_cmd": [
"./build-linux-x86.sh"
],
"custom_install_cmd": [
"{python} copy_platform_cmakes.py"
"{python}", "copy_platform_cmakes.py"
]
},
"Linux-aarch64": {
"package_version": "5.15.2-rev8",
"patch_file": "qt-image-format.patch",
"package_version": "5.15.2-rev9",
"patch_file": "qt-linux.patch",
"depends_on_packages": [
["OpenSSL-1.1.1t-rev1-linux-aarch64", "f32721bec9c82d1bd7fb244d78d5dc4e2a47e7b808bb36027236ad377e241ea5", ""],
["tiff-4.2.0.15-rev3-linux-aarch64", "429461014b21a530dcad597c2d91072ae39d937a04b7bbbf5c34491c41767f7f", ""],
["zlib-1.2.11-rev5-linux-aarch64", "ce9d1ed2883d77ffc69c7982c078595c1f89ca55ec19d89fe7e6beb05f774775", ""]
],
"custom_build_cmd": [
"./build-linux-aarch64.sh"
],
"custom_install_cmd": [
"{python} copy_platform_cmakes.py"
"{python}", "copy_platform_cmakes.py"
]
}
}
Expand Down
19 changes: 14 additions & 5 deletions package-system/Qt/docker_build_qt_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
# TEMP_FOLDER and TARGET_INSTALL_ROOT get set from the pull_and_build_from_git.py script

# Read the dependent 3P library paths from the arguments
TIFF_PACKAGE_DIR=$1
ZLIB_PACKAGE_DIR=$2
TIFF_PACKAGE_DIR=/data/workspace/o3de_tiff
ZLIB_PACKAGE_DIR=/data/workspace/o3de_zlib
OPENSSL_PACKAGE_DIR=/data/workspace/o3de_openssl

set -euo pipefail

Expand All @@ -20,18 +21,24 @@ MAKE_FLAGS=-j32
echo "Building Qt5 from source with dependencies on"
echo " " $TIFF_PACKAGE_DIR
echo " " $ZLIB_PACKAGE_DIR
echo " " $OPENSSL_PACKAGE_DIR


# Base the Tiff of the dependent tiff O3DE package (static)
TIFF_PREFIX=$TIFF_PACKAGE_DIR/tiff
TIFF_INCDIR=$TIFF_PREFIX/include
TIFF_LIBDIR=$TIFF_PREFIX/lib

# We need to also bring in the zlib dependency since Tiff is a static lib dependency
# Bring in the zlib dependency since Tiff is a static lib dependency
ZLIB_PREFIX=$ZLIB_PACKAGE_DIR/zlib
ZLIB_INCDIR=$ZLIB_PREFIX/include
ZLIB_LIBDIR=$ZLIB_PREFIX/lib

# Bring in the openssl dependency based
OPENSSL_PREFIX=$OPENSSL_PACKAGE_DIR/OpenSSL
OPENSSL_INCDIR=$OPENSSL_PREFIX/include
OPENSSL_LIBDIR=$OPENSSL_PREFIX/lib

BUILD_PATH=/data/workspace/build
INSTALL_PATH=/data/workspace/qt

Expand Down Expand Up @@ -64,12 +71,14 @@ echo Configuring Qt...
-no-egl \
-qpa xcb \
-xcb-xlib \
-openssl \
-I $TIFF_INCDIR \
-I $ZLIB_INCDIR \
-I $OPENSSL_INCDIR \
-L $TIFF_LIBDIR \
-L $ZLIB_LIBDIR \
-L $OPENSSL_LIBDIR \
-c++std c++1z \
-openssl \
-fontconfig
if [ $? -ne 0 ]
then
Expand Down Expand Up @@ -99,7 +108,7 @@ for qtlib in "${qtarray[@]}"; do
echo Installing $qtlib...
make module-$qtlib-install_subtargets

if [ ?$ -ne 0 ]
if [ $? -ne 0 ]
then
echo "Failed installing Qt module $qtlib"
exit 1
Expand Down
38 changes: 38 additions & 0 deletions package-system/Qt/qt-linux.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
diff --git a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
index b583d636c0..4615ebb126 100644
--- a/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
+++ b/qtbase/src/platformsupport/services/genericunix/qgenericunixservices.cpp
@@ -203,8 +203,7 @@ static inline QDBusMessage xdgDesktopPortalOpenFile(const QUrl &url)
// handle_token (s) - A string that will be used as the last element of the @handle.
// writable (b) - Whether to allow the chosen application to write to the file.

-#ifdef O_PATH
- const int fd = qt_safe_open(QFile::encodeName(url.toLocalFile()), O_PATH);
+ const int fd = qt_safe_open(QFile::encodeName(url.toLocalFile()), O_RDONLY);
if (fd != -1) {
QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.portal.Desktop"),
QLatin1String("/org/freedesktop/portal/desktop"),
@@ -219,9 +218,6 @@ static inline QDBusMessage xdgDesktopPortalOpenFile(const QUrl &url)

return QDBusConnection::sessionBus().call(message);
}
-#else
- Q_UNUSED(url)
-#endif

return QDBusMessage::createError(QDBusError::InternalError, qt_error_string());
}

diff --git a/qtimageformats/src/imageformats/configure.json b/qtimageformats/src/imageformats/configure.json
index 5b876c3..f2fa1cc 100644
--- a/qtimageformats/src/imageformats/configure.json
+++ b/qtimageformats/src/imageformats/configure.json
@@ -85,7 +85,7 @@
},
"sources": [
{ "type": "pkgConfig", "args": "libtiff-4" },
- { "libs": "-ltiff" }
+ { "libs": "-ltiff -lz" }
]
},
"webp": {
File renamed without changes.
4 changes: 2 additions & 2 deletions package_build_list_host_linux-aarch64.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"poly2tri-7f0487a-rev1-linux-aarch64": "package-system/poly2tri/build_package_image.py --platform-name linux-aarch64",
"pyside2-5.15.2.1-py3.10-rev4-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/pyside2 --platform-name Linux-aarch64 --clean",
"python-3.10.5-rev4-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/python --platform-name Linux-aarch64 --clean",
"qt-5.15.2-rev8-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/Qt --platform-name Linux-aarch64 --clean",
"qt-5.15.2-rev9-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/Qt --platform-name Linux-aarch64 --clean",
"sdformat-13.5.0-rev1-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/sdformat --platform-name Linux-aarch64 --clean",
"SPIRVCross-2021.04.29-rev1-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/SPIRVCross --platform-name Linux-aarch64 --clean",
"SQLite-3.37.2-rev1-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/sqlite --platform-name Linux-aarch64 --clean",
Expand Down Expand Up @@ -75,7 +75,7 @@
"poly2tri-7f0487a-rev1-linux-aarch64": "package-system/poly2tri-linux-aarch64",
"pyside2-5.15.2.1-py3.10-rev4-linux-aarch64": "package-system/pyside2/temp/pyside2-linux-aarch64",
"python-3.10.5-rev4-linux-aarch64": "package-system/python/temp/python-linux-aarch64",
"qt-5.15.2-rev8-linux-aarch64": "package-system/Qt/temp/qt-linux-aarch64",
"qt-5.15.2-rev9-linux-aarch64": "package-system/Qt/temp/qt-linux-aarch64",
"sdformat-13.5.0-rev1-linux-aarch64": "package-system/sdformat/temp/sdformat-linux-aarch64",
"SPIRVCross-2021.04.29-rev1-linux-aarch64": "package-system/SPIRVCross/temp/SPIRVCross-linux-aarch64",
"SQLite-3.37.2-rev1-linux-aarch64": "package-system/sqlite/temp/SQLite-linux-aarch64",
Expand Down
4 changes: 2 additions & 2 deletions package_build_list_host_linux.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"python-3.10.5-rev4-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/python --platform-name Linux --clean",
"python-3.10.5-rev4-linux-aarch64": "Scripts/extras/pull_and_build_from_git.py ../../package-system/python --platform-name Linux-aarch64 --clean",
"mikkelsen-1.0.0.4-linux": "package-system/mikkelsen/build_package_image.py",
"qt-5.15.2-rev8-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/Qt --platform-name Linux --package-root ../../package-system/Qt/temp --clean",
"qt-5.15.2-rev9-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/Qt --platform-name Linux --package-root ../../package-system/Qt/temp --clean",
"zlib-1.2.11-rev5-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/zlib --platform-name Linux --package-root ../../package-system --clean",
"lz4-1.9.4-rev2-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/lz4 --platform-name Linux --package-root ../../package-system/lz4/temp --clean",
"expat-2.4.2-rev2-linux": "Scripts/extras/pull_and_build_from_git.py ../../package-system/expat --platform-name Linux --package-root ../../package-system/expat/temp --clean",
Expand Down Expand Up @@ -93,7 +93,7 @@
"unwind-1.2.1-linux": "package-system/unwind-linux",
"SQLite-3.37.2-rev1-linux": "package-system/SQLite-linux",
"xxhash-0.7.4-rev1-multiplatform": "package-system/xxhash-multiplatform",
"qt-5.15.2-rev8-linux": "package-system/Qt/temp/qt-linux",
"qt-5.15.2-rev9-linux": "package-system/Qt/temp/qt-linux",
"zlib-1.2.11-rev5-linux": "package-system/zlib-linux",
"lz4-1.9.4-rev2-linux": "package-system/lz4/temp/lz4-linux",
"expat-2.4.2-rev2-linux": "package-system/expat/temp/expat-linux",
Expand Down

0 comments on commit f2df42b

Please sign in to comment.