From 474cd6b1c7dc7b8f338d914ec89bc79f0fbe9361 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Mon, 21 Dec 2020 20:58:11 +0100 Subject: [PATCH 01/21] Improve Qt handling in CMake Support 3 options: * VIRCADIA_USE_SYSTEM_QT is set -- use system's Qt * VIRCADIA_QT_PATH is set -- use Qt found in that dir * Otherwise -- use downloaded Qt package This removes these variables: * VIRCADIA_USE_QT_VERSION * VIRCADIA_USE_PREBUILT_QT * HIFI_QT_BASE --- cmake/macros/SetupQt.cmake | 14 +++ hifi_qt.py | 100 +++++++++++++++--- interface/CMakeLists.txt | 32 +++--- .../src/controllers/UserInputMapper.cpp | 4 + tools/nitpick/CMakeLists.txt | 2 +- tools/skeleton-dump/src/SkeletonDumpApp.cpp | 5 + 6 files changed, 126 insertions(+), 31 deletions(-) diff --git a/cmake/macros/SetupQt.cmake b/cmake/macros/SetupQt.cmake index 6f31a3994c..35a22ecb4d 100644 --- a/cmake/macros/SetupQt.cmake +++ b/cmake/macros/SetupQt.cmake @@ -25,6 +25,9 @@ function(calculate_qt5_version result _QT_DIR) set(_QT_CORE_DIR "${_QT_DIR}/lib/QtCore.framework/Versions/5/Headers") else() set(_QT_CORE_DIR "${_QT_DIR}/include/QtCore") + if(NOT EXISTS "${_QT_CORE_DIR}") + set(_QT_CORE_DIR "${_QT_DIR}/include/qt5/QtCore") + endif() endif() if(NOT EXISTS "${_QT_CORE_DIR}") message(FATAL_ERROR "Could not find 'include/QtCore' in '${_QT_DIR}'") @@ -78,6 +81,17 @@ macro(setup_qt) message(FATAL_ERROR "Unable to locate Qt5CoreConfig.cmake in '${QT_CMAKE_PREFIX_PATH}'") endif() + set(RCC_BINARY "${QT_DIR}/bin/rcc") + + if(NOT EXISTS "${RCC_BINARY}") + set(RCC_BINARY "${QT_DIR}/bin/rcc-qt5") + endif() + + if(NOT EXISTS "${RCC_BINARY}") + message(FATAL_ERROR "Unable to locate rcc '${QT_DIR}'") + endif() + + message(STATUS "Using Qt build in : '${QT_DIR}' with version ${QT_VERSION}") # Instruct CMake to run moc automatically when needed. diff --git a/hifi_qt.py b/hifi_qt.py index 7ee8a787b5..dbff6319ff 100644 --- a/hifi_qt.py +++ b/hifi_qt.py @@ -28,18 +28,83 @@ endif() self.args = args self.configFilePath = os.path.join(args.build_root, 'qt.cmake') self.version = os.getenv('VIRCADIA_USE_QT_VERSION', '5.15.2') - self.assets_url = hifi_utils.readEnviromentVariableFromFile(args.build_root, 'EXTERNAL_BUILD_ASSETS') - defaultBasePath = os.path.expanduser('~/hifi/qt') - self.basePath = os.getenv('HIFI_QT_BASE', defaultBasePath) - if (not os.path.isdir(self.basePath)): - os.makedirs(self.basePath) - self.path = os.path.join(self.basePath, self.version) - self.fullPath = os.path.join(self.path, 'qt5-install') - self.cmakePath = os.path.join(self.fullPath, 'lib/cmake') + # OS dependent information + system = platform.system() - print("Using qt path {}".format(self.path)) + qt_found = False + + # Here we handle the 3 possible cases of dealing with Qt: + if os.getenv('VIRCADIA_USE_SYSTEM_QT'): + # 1. Using the system provided Qt. This is only recommended for Qt 5.15.0 and above, + # as it includes a required fix on Linux. + # + # This path only works on Linux as neither Windows nor OSX ship Qt. + + if system != "Linux": + raise Exception("Using the system Qt is only supported on Linux") + + cmake_paths = [ "lib64/cmake", "lib/cmake" ] + cmake_path_ok = False + + # This makes the lockFile stuff happy. Needs to be writable. + self.path = tempfile.mkdtemp() + + self.fullPath = '/usr' + + # Find the cmake directory + for cp in cmake_paths: + self.cmakePath = os.path.join(self.fullPath, cp) + if os.path.isdir(self.cmakePath): + cmake_path_ok = True + break + + if not cmake_path_ok: + raise Exception("Failed to find cmake directory. Looked under " + self.fullPath + " in " + (', '.join(cmake_paths))) + + qt_found = True + print("Using system Qt") + + elif os.getenv('VIRCADIA_QT_PATH'): + # 2. Using an user-provided directory. + # VIRCADIA_QT_PATH must point to a directory with a Qt install in it. + + self.path = os.getenv('VIRCADIA_QT_PATH') + self.fullPath = self.path + self.cmakePath = os.path.join(self.fullPath, 'lib/cmake') + + qt_found = True + print("Using Qt from " + self.fullPath) + + else: + # 3. Using a pre-built Qt. + # + # This works somewhat differently from above, notice how path and fullPath are + # used differently in this case. + # + # In the case of an user-provided directory, we just use the user-supplied directory. + # + # For a pre-built qt, however, we have to unpack it. The archive is required to contain + # a qt5-install directory in it. + + self.path = os.path.expanduser("~/vircadia-files/qt") + self.fullPath = os.path.join(self.path, 'qt5-install') + self.cmakePath = os.path.join(self.fullPath, 'lib/cmake') + + if (not os.path.isdir(self.path)): + os.makedirs(self.path) + + qt_found = os.path.isdir(self.fullPath) + print("Using a packaged Qt") + + if qt_found: + # Sanity check, ensure we have a good cmake directory + if not os.path.isdir(os.path.join(self.cmakePath, "Qt5")): + raise Exception("Failed to find Qt5 directory under " + self.cmakePath) + + # I'm not sure why this is needed. It's used by hifi_singleton. + # Perhaps it stops multiple build processes from interferring? lockDir, lockName = os.path.split(self.path) lockName += '.lock' if not os.path.isdir(lockDir): @@ -47,21 +112,16 @@ endif() self.lockFile = os.path.join(lockDir, lockName) - if (os.getenv('VIRCADIA_USE_PREBUILT_QT')): - print("Using pre-built Qt5") + if qt_found: + print("Found pre-built Qt5") return - # OS dependent information - system = platform.system() - cpu_architecture = platform.machine() - if 'Windows' == system: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-windows.tar.gz' elif 'Darwin' == system: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-macos.tar.gz' elif 'Linux' == system: import distro - dist = distro.linux_distribution() if 'x86_64' == cpu_architecture: if distro.id() == 'ubuntu': @@ -124,6 +184,14 @@ endif() print("Machine : " + platform.machine()) raise Exception('UNKNOWN OPERATING SYSTEM!!!') + def showQtBuildInfo(self): + print("") + print("It's also possible to build Qt for your distribution, please see the documentation at:") + print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder") + print("") + print("Alternatively, you can try building against the system Qt by setting the VIRCADIA_USE_SYSTEM_QT environment variable.") + print("You'll need to install the development packages, and to have Qt 5.15.0 or newer. ") + def writeConfig(self): print("Writing cmake config to {}".format(self.configFilePath)) # Write out the configuration for use by CMake diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index c307c63142..142fda15ce 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -34,14 +34,14 @@ if (ANDROID) add_custom_command( OUTPUT ${RESOURCES_RCC} DEPENDS ${RESOURCES_QRC} ${GENERATE_QRC_DEPENDS} - COMMAND "${QT_DIR}/bin/rcc" + COMMAND "${RCC_BINARY}" ARGS ${RESOURCES_QRC} -no-compress -binary -o ${RESOURCES_RCC} ) else () add_custom_command( OUTPUT ${RESOURCES_RCC} DEPENDS ${RESOURCES_QRC} ${GENERATE_QRC_DEPENDS} - COMMAND "${QT_DIR}/bin/rcc" + COMMAND "${RCC_BINARY}" ARGS ${RESOURCES_QRC} -binary -o ${RESOURCES_RCC} ) endif() @@ -199,6 +199,8 @@ endif() if (WIN32 OR APPLE) add_dependencies(${TARGET_NAME} resources) +if (WIN32 OR APPLE OR UNIX) + add_dependencies(${TARGET_NAME} resources screenshare) endif() if (SCREENSHARE) @@ -435,18 +437,20 @@ else() endif() endif() -if (DEV_BUILD AND (APPLE OR UNIX)) - # create a qt.conf file to override hard-coded search paths in Qt libs - set(QT_LIB_PATH "${QT_CMAKE_PREFIX_PATH}/../..") - if (APPLE) - set(QT_CONF_FILE "${RESOURCES_DEV_DIR}/../Resources/qt.conf") - else () - set(QT_CONF_FILE "${INTERFACE_EXEC_DIR}/qt.conf") - endif () - file(GENERATE - OUTPUT "${QT_CONF_FILE}" - CONTENT "[Paths]\nPrefix=${QT_LIB_PATH}\n" - ) +if (NOT $ENV{VIRCADIA_USE_SYSTEM_QT}) + if (DEV_BUILD AND (APPLE OR UNIX)) + # create a qt.conf file to override hard-coded search paths in Qt libs + set(QT_LIB_PATH "${QT_CMAKE_PREFIX_PATH}/../..") + if (APPLE) + set(QT_CONF_FILE "${RESOURCES_DEV_DIR}/../Resources/qt.conf") + else () + set(QT_CONF_FILE "${INTERFACE_EXEC_DIR}/qt.conf") + endif () + file(GENERATE + OUTPUT "${QT_CONF_FILE}" + CONTENT "[Paths]\nPrefix=${QT_LIB_PATH}\n" + ) + endif() endif() if (SCRIPTS_INSTALL_DIR) diff --git a/libraries/controllers/src/controllers/UserInputMapper.cpp b/libraries/controllers/src/controllers/UserInputMapper.cpp index 6333792b3f..b5e07d5691 100755 --- a/libraries/controllers/src/controllers/UserInputMapper.cpp +++ b/libraries/controllers/src/controllers/UserInputMapper.cpp @@ -44,6 +44,10 @@ #include "impl/Route.h" #include "impl/Mapping.h" +#if QT_VERSION > QT_VERSION_CHECK(5, 13, 0) +// FIXME: Remove this after Qt 5.15 upgrade +#define endl Qt::endl +#endif namespace controller { const uint16_t UserInputMapper::STANDARD_DEVICE = 0; diff --git a/tools/nitpick/CMakeLists.txt b/tools/nitpick/CMakeLists.txt index 8b4a5d03df..18ee84c0e5 100644 --- a/tools/nitpick/CMakeLists.txt +++ b/tools/nitpick/CMakeLists.txt @@ -12,7 +12,7 @@ generate_qrc(OUTPUT ${RESOURCES_QRC} PATH ${CMAKE_CURRENT_SOURCE_DIR}/resources add_custom_command( OUTPUT ${RESOURCES_RCC} DEPENDS ${RESOURCES_QRC} ${GENERATE_QRC_DEPENDS} - COMMAND "${QT_DIR}/bin/rcc" + COMMAND "${RCC_BINARY}" ARGS ${RESOURCES_QRC} -binary -o ${RESOURCES_RCC} ) diff --git a/tools/skeleton-dump/src/SkeletonDumpApp.cpp b/tools/skeleton-dump/src/SkeletonDumpApp.cpp index 42a1c78090..e3169098d6 100644 --- a/tools/skeleton-dump/src/SkeletonDumpApp.cpp +++ b/tools/skeleton-dump/src/SkeletonDumpApp.cpp @@ -15,6 +15,11 @@ #include #include +#if QT_VERSION > QT_VERSION_CHECK(5, 13, 0) +// FIXME: Remove this after Qt 5.15 upgrade +#define endl Qt::endl +#endif + SkeletonDumpApp::SkeletonDumpApp(int argc, char* argv[]) : QCoreApplication(argc, argv) { // parse command-line From b88f380c87b2c0865da3a28952b8c0a3702faf03 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 27 Dec 2020 22:08:45 +0100 Subject: [PATCH 02/21] Update documentation on Qt in Linux --- BUILD_LINUX.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/BUILD_LINUX.md b/BUILD_LINUX.md index e9c5047e38..3bae13df9e 100644 --- a/BUILD_LINUX.md +++ b/BUILD_LINUX.md @@ -93,15 +93,16 @@ git checkout master ### Using a custom Qt build -Qt binaries are only provided for Ubuntu. In order to build on other distributions, a Qt5 install needs to be provided as follows: +Qt binaries are only provided for Ubuntu. In order to build on other distributions, a Qt5 install + needs to be provided by setting the `VIRCADIA_QT_PATH` environment variable to a directory containing + a Qt install. -* Set `VIRCADIA_USE_PREBUILT_QT=1` -* Set `VIRCADIA_USE_QT_VERSION` to the Qt version (defaults to `5.12.3`) -* Set `HIFI_QT_BASE=/path/to/qt` + ### Using the system's Qt -Qt must be installed in `$HIFI_QT_BASE/$VIRCADIA_USE_QT_VERSION/qt5-install`. + The system's Qt can be used, if the development packages are installed, by setting the + `VIRCADIA_USE_SYSTEM_QT` environment variable. The minimum recommended version is Qt 5.15.0. -### Compiling + ### Compiling Create the build directory: ```bash From efd15dc43a09d29244edbd1c27c33a6cebe3e0f7 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Wed, 6 Jan 2021 20:51:17 +0100 Subject: [PATCH 03/21] Make hifi_vcpkg.py use ~/vircadia-files too Makes it consistent with the change made for Qt --- hifi_vcpkg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hifi_vcpkg.py b/hifi_vcpkg.py index fb77fd2507..642ed1253e 100644 --- a/hifi_vcpkg.py +++ b/hifi_vcpkg.py @@ -60,7 +60,7 @@ endif() self.path = args.vcpkg_root self.noClean = True else: - defaultBasePath = os.path.expanduser('~/hifi/vcpkg') + defaultBasePath = os.path.expanduser('~/vircadia-files/vcpkg') self.basePath = os.getenv('HIFI_VCPKG_BASE', defaultBasePath) if self.args.android: self.basePath = os.path.join(self.basePath, 'android') From 6cd8eca159ab32d1e49921309cde21ff15998d7f Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sat, 30 Jan 2021 19:54:33 +0100 Subject: [PATCH 04/21] Take into account that Windows executables have an extension --- cmake/macros/SetupQt.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/macros/SetupQt.cmake b/cmake/macros/SetupQt.cmake index 35a22ecb4d..b39c423a05 100644 --- a/cmake/macros/SetupQt.cmake +++ b/cmake/macros/SetupQt.cmake @@ -81,14 +81,14 @@ macro(setup_qt) message(FATAL_ERROR "Unable to locate Qt5CoreConfig.cmake in '${QT_CMAKE_PREFIX_PATH}'") endif() - set(RCC_BINARY "${QT_DIR}/bin/rcc") + set(RCC_BINARY "${QT_DIR}/bin/rcc${CMAKE_EXECUTABLE_SUFFIX}") if(NOT EXISTS "${RCC_BINARY}") - set(RCC_BINARY "${QT_DIR}/bin/rcc-qt5") + set(RCC_BINARY "${QT_DIR}/bin/rcc-qt5${CMAKE_EXECUTABLE_SUFFIX}") endif() if(NOT EXISTS "${RCC_BINARY}") - message(FATAL_ERROR "Unable to locate rcc '${QT_DIR}'") + message(FATAL_ERROR "Unable to locate rcc. Last looked in '${RCC_BINARY}'") endif() From 2b05c324368c9a244a7805421942c7e98b0209aa Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sat, 30 Jan 2021 22:56:29 +0100 Subject: [PATCH 05/21] Don't depend on screenshare on Android --- interface/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 142fda15ce..9710aa53e8 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -197,9 +197,7 @@ if (BUILD_TOOLS AND NPM_EXECUTABLE) add_dependencies(resources jsdoc) endif() -if (WIN32 OR APPLE) - add_dependencies(${TARGET_NAME} resources) -if (WIN32 OR APPLE OR UNIX) +if ((WIN32 OR APPLE OR UNIX) AND NOT ANDROID) add_dependencies(${TARGET_NAME} resources screenshare) endif() From 1e63916940e5f805f5502a32ce867c2269bf7df4 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Mon, 15 Feb 2021 23:58:20 +0100 Subject: [PATCH 06/21] Disable almost all the code in SetupQt.cmake for system qt We're already using the standard find_package method to setup Qt for the most part, so none of the manipulations of SetupQt should be needed for system Qt. --- CMakeLists.txt | 5 +- cmake/macros/SetupQt.cmake | 100 +++++++++++++++++++------------------ 2 files changed, 56 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77d0413690..5993ab8764 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -290,7 +290,10 @@ set_packaging_parameters() # Locate the required Qt build on the filesystem setup_qt() -list(APPEND CMAKE_PREFIX_PATH "${QT_CMAKE_PREFIX_PATH}") + +if (NOT $ENV{VIRCADIA_USE_SYSTEM_QT}) + list(APPEND CMAKE_PREFIX_PATH "${QT_CMAKE_PREFIX_PATH}") +endif() find_package( Threads ) diff --git a/cmake/macros/SetupQt.cmake b/cmake/macros/SetupQt.cmake index b39c423a05..4676a00e97 100644 --- a/cmake/macros/SetupQt.cmake +++ b/cmake/macros/SetupQt.cmake @@ -48,51 +48,59 @@ endfunction() # Sets the QT_CMAKE_PREFIX_PATH and QT_DIR variables # Also enables CMAKE_AUTOMOC and CMAKE_AUTORCC macro(setup_qt) - # if we are in a development build and QT_CMAKE_PREFIX_PATH is specified - # then use it, - # otherwise, use the vcpkg'ed version - if(NOT DEFINED QT_CMAKE_PREFIX_PATH) - message(FATAL_ERROR "QT_CMAKE_PREFIX_PATH should have been set by hifi_qt.py") + if ($ENV{VIRCADIA_USE_SYSTEM_QT}) + message(STATUS "Using system Qt") + else() + # if we are in a development build and QT_CMAKE_PREFIX_PATH is specified + # then use it, + # otherwise, use the vcpkg'ed version + if(NOT DEFINED QT_CMAKE_PREFIX_PATH) + message(FATAL_ERROR "QT_CMAKE_PREFIX_PATH should have been set by hifi_qt.py") + endif() + if (DEV_BUILD) + if (DEFINED ENV{QT_CMAKE_PREFIX_PATH}) + set(QT_CMAKE_PREFIX_PATH $ENV{QT_CMAKE_PREFIX_PATH}) + endif() + endif() + + message("QT_CMAKE_PREFIX_PATH = " ${QT_CMAKE_PREFIX_PATH}) + + # figure out where the qt dir is + get_filename_component(QT_DIR "${QT_CMAKE_PREFIX_PATH}/../../" ABSOLUTE) + set(QT_VERSION "unknown") + calculate_qt5_version(QT_VERSION "${QT_DIR}") + if (QT_VERSION STREQUAL "unknown") + message(FATAL_ERROR "Could not determine QT_VERSION") + endif() + + if(WIN32) + # windows shell does not like backslashes expanded on the command line, + # so convert all backslashes in the QT path to forward slashes + string(REPLACE \\ / QT_CMAKE_PREFIX_PATH ${QT_CMAKE_PREFIX_PATH}) + string(REPLACE \\ / QT_DIR ${QT_DIR}) + endif() + + if(NOT EXISTS "${QT_CMAKE_PREFIX_PATH}/Qt5Core/Qt5CoreConfig.cmake") + message(FATAL_ERROR "Unable to locate Qt5CoreConfig.cmake in '${QT_CMAKE_PREFIX_PATH}'") + endif() + + set(RCC_BINARY "${QT_DIR}/bin/rcc${CMAKE_EXECUTABLE_SUFFIX}") + + if(NOT EXISTS "${RCC_BINARY}") + set(RCC_BINARY "${QT_DIR}/bin/rcc-qt5${CMAKE_EXECUTABLE_SUFFIX}") + endif() + + if(NOT EXISTS "${RCC_BINARY}") + message(FATAL_ERROR "Unable to locate rcc. Last looked in '${RCC_BINARY}'") + endif() + + + message(STATUS "Using Qt build in : '${QT_DIR}' with version ${QT_VERSION}") + if (WIN32) + add_paths_to_fixup_libs("${QT_DIR}/bin") + endif () + endif() - if (DEV_BUILD) - if (DEFINED ENV{QT_CMAKE_PREFIX_PATH}) - set(QT_CMAKE_PREFIX_PATH $ENV{QT_CMAKE_PREFIX_PATH}) - endif() - endif() - - message("QT_CMAKE_PREFIX_PATH = " ${QT_CMAKE_PREFIX_PATH}) - - # figure out where the qt dir is - get_filename_component(QT_DIR "${QT_CMAKE_PREFIX_PATH}/../../" ABSOLUTE) - set(QT_VERSION "unknown") - calculate_qt5_version(QT_VERSION "${QT_DIR}") - if (QT_VERSION STREQUAL "unknown") - message(FATAL_ERROR "Could not determine QT_VERSION") - endif() - - if(WIN32) - # windows shell does not like backslashes expanded on the command line, - # so convert all backslashes in the QT path to forward slashes - string(REPLACE \\ / QT_CMAKE_PREFIX_PATH ${QT_CMAKE_PREFIX_PATH}) - string(REPLACE \\ / QT_DIR ${QT_DIR}) - endif() - - if(NOT EXISTS "${QT_CMAKE_PREFIX_PATH}/Qt5Core/Qt5CoreConfig.cmake") - message(FATAL_ERROR "Unable to locate Qt5CoreConfig.cmake in '${QT_CMAKE_PREFIX_PATH}'") - endif() - - set(RCC_BINARY "${QT_DIR}/bin/rcc${CMAKE_EXECUTABLE_SUFFIX}") - - if(NOT EXISTS "${RCC_BINARY}") - set(RCC_BINARY "${QT_DIR}/bin/rcc-qt5${CMAKE_EXECUTABLE_SUFFIX}") - endif() - - if(NOT EXISTS "${RCC_BINARY}") - message(FATAL_ERROR "Unable to locate rcc. Last looked in '${RCC_BINARY}'") - endif() - - - message(STATUS "Using Qt build in : '${QT_DIR}' with version ${QT_VERSION}") # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) @@ -100,8 +108,4 @@ macro(setup_qt) # Instruct CMake to run rcc automatically when needed set(CMAKE_AUTORCC ON) - if (WIN32) - add_paths_to_fixup_libs("${QT_DIR}/bin") - endif () - endmacro() From ca489bd4208e4a2d44b9f1d2624304b43f371c0a Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Tue, 16 Feb 2021 11:46:22 +0100 Subject: [PATCH 07/21] Simplify system Qt path --- CMakeLists.txt | 10 ++++++---- hifi_qt.py | 45 +++++++++++++++++---------------------------- prebuild.py | 17 ++++++++++------- 3 files changed, 33 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5993ab8764..cf82dfdfc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,11 +101,13 @@ include("${CMAKE_BINARY_DIR}/vcpkg.cmake") if (HIFI_ANDROID) set(QT_CMAKE_PREFIX_PATH "$ENV{HIFI_ANDROID_PRECOMPILED}/qt/lib/cmake") -else() - if(NOT EXISTS "${CMAKE_BINARY_DIR}/qt.cmake") - message(FATAL_ERROR "qt configuration missing.") +else() + if (NOT $ENV{VIRCADIA_USE_SYSTEM_QT}) + if(NOT EXISTS "${CMAKE_BINARY_DIR}/qt.cmake") + message(FATAL_ERROR "qt configuration missing.") + endif() + include("${CMAKE_BINARY_DIR}/qt.cmake") endif() - include("${CMAKE_BINARY_DIR}/qt.cmake") endif() option(VCPKG_APPLOCAL_DEPS OFF) diff --git a/hifi_qt.py b/hifi_qt.py index dbff6319ff..d11988ed2e 100644 --- a/hifi_qt.py +++ b/hifi_qt.py @@ -34,6 +34,7 @@ endif() system = platform.system() qt_found = False + system_qt = False # Here we handle the 3 possible cases of dealing with Qt: if os.getenv('VIRCADIA_USE_SYSTEM_QT'): @@ -45,25 +46,11 @@ endif() if system != "Linux": raise Exception("Using the system Qt is only supported on Linux") - cmake_paths = [ "lib64/cmake", "lib/cmake" ] - cmake_path_ok = False - - # This makes the lockFile stuff happy. Needs to be writable. - self.path = tempfile.mkdtemp() - - self.fullPath = '/usr' - - # Find the cmake directory - for cp in cmake_paths: - self.cmakePath = os.path.join(self.fullPath, cp) - if os.path.isdir(self.cmakePath): - cmake_path_ok = True - break - - if not cmake_path_ok: - raise Exception("Failed to find cmake directory. Looked under " + self.fullPath + " in " + (', '.join(cmake_paths))) + self.path = None + self.cmakePath = None qt_found = True + system_qt = True print("Using system Qt") elif os.getenv('VIRCADIA_QT_PATH'): @@ -98,19 +85,21 @@ endif() qt_found = os.path.isdir(self.fullPath) print("Using a packaged Qt") - if qt_found: - # Sanity check, ensure we have a good cmake directory - if not os.path.isdir(os.path.join(self.cmakePath, "Qt5")): - raise Exception("Failed to find Qt5 directory under " + self.cmakePath) - # I'm not sure why this is needed. It's used by hifi_singleton. - # Perhaps it stops multiple build processes from interferring? - lockDir, lockName = os.path.split(self.path) - lockName += '.lock' - if not os.path.isdir(lockDir): - os.makedirs(lockDir) + if not system_qt: + if qt_found: + # Sanity check, ensure we have a good cmake directory + if not os.path.isdir(os.path.join(self.cmakePath, "Qt5")): + raise Exception("Failed to find Qt5 directory under " + self.cmakePath) - self.lockFile = os.path.join(lockDir, lockName) + # I'm not sure why this is needed. It's used by hifi_singleton. + # Perhaps it stops multiple build processes from interferring? + lockDir, lockName = os.path.split(self.path) + lockName += '.lock' + if not os.path.isdir(lockDir): + os.makedirs(lockDir) + + self.lockFile = os.path.join(lockDir, lockName) if qt_found: print("Found pre-built Qt5") diff --git a/prebuild.py b/prebuild.py index d5bed2d813..47ec01f8cc 100644 --- a/prebuild.py +++ b/prebuild.py @@ -130,23 +130,26 @@ def main(): with timer('NSIS'): hifi_utils.downloadAndExtract(assets_url + '/dependencies/NSIS-hifi-plugins-1.0.tgz', "C:/Program Files (x86)") - qtInstallPath = '' + qtInstallPath = None # If not android, install our Qt build if not args.android: qt = hifi_qt.QtDownloader(args) qtInstallPath = qt.cmakePath - with hifi_singleton.Singleton(qt.lockFile) as lock: - with timer('Qt'): - qt.installQt() - qt.writeConfig() + + if qtInstallPath is not None: + # qtInstallPath is None when we're doing a system Qt build + with hifi_singleton.Singleton(qt.lockFile) as lock: + with timer('Qt'): + qt.installQt() + qt.writeConfig() pm = hifi_vcpkg.VcpkgRepo(args) - if qtInstallPath != '': + if qtInstallPath is not None: pm.writeVar('QT_CMAKE_PREFIX_PATH', qtInstallPath) # Only allow one instance of the program to run at a time - if qtInstallPath != '': + if qtInstallPath is not None: pm.writeVar('QT_CMAKE_PREFIX_PATH', qtInstallPath) # Only allow one instance of the program to run at a time From 758ebd7f9d212281e16299f94eb2d237574132e1 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Tue, 16 Feb 2021 12:46:30 +0100 Subject: [PATCH 08/21] Fix environment variable cmake syntax --- CMakeLists.txt | 4 ++-- interface/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf82dfdfc6..cbde769d3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,7 +102,7 @@ include("${CMAKE_BINARY_DIR}/vcpkg.cmake") if (HIFI_ANDROID) set(QT_CMAKE_PREFIX_PATH "$ENV{HIFI_ANDROID_PRECOMPILED}/qt/lib/cmake") else() - if (NOT $ENV{VIRCADIA_USE_SYSTEM_QT}) + if (NOT DEFINED ENV{VIRCADIA_USE_SYSTEM_QT}) if(NOT EXISTS "${CMAKE_BINARY_DIR}/qt.cmake") message(FATAL_ERROR "qt configuration missing.") endif() @@ -293,7 +293,7 @@ set_packaging_parameters() # Locate the required Qt build on the filesystem setup_qt() -if (NOT $ENV{VIRCADIA_USE_SYSTEM_QT}) +if (NOT DEFINED ENV{VIRCADIA_USE_SYSTEM_QT}) list(APPEND CMAKE_PREFIX_PATH "${QT_CMAKE_PREFIX_PATH}") endif() diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 9710aa53e8..267f996535 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -435,7 +435,7 @@ else() endif() endif() -if (NOT $ENV{VIRCADIA_USE_SYSTEM_QT}) +if (NOT DEFINED ENV{VIRCADIA_USE_SYSTEM_QT}) if (DEV_BUILD AND (APPLE OR UNIX)) # create a qt.conf file to override hard-coded search paths in Qt libs set(QT_LIB_PATH "${QT_CMAKE_PREFIX_PATH}/../..") From 6611d6ef5b9c40f99a9d925604cd1cb7a8245bbd Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Wed, 17 Feb 2021 20:59:28 +0100 Subject: [PATCH 09/21] Fix quazip cmake portfile to work with system Qt --- cmake/ports/quazip/portfile.cmake | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmake/ports/quazip/portfile.cmake b/cmake/ports/quazip/portfile.cmake index 0789062892..3f5703dcf4 100644 --- a/cmake/ports/quazip/portfile.cmake +++ b/cmake/ports/quazip/portfile.cmake @@ -1,6 +1,15 @@ include(vcpkg_common_functions) -file(READ "${VCPKG_ROOT_DIR}/_env/QT_CMAKE_PREFIX_PATH.txt" QT_CMAKE_PREFIX_PATH) +if(EXISTS "${VCPKG_ROOT_DIR}/_env/QT_CMAKE_PREFIX_PATH.txt") + # This environment var file only exists if we're overridding the default Qt location, + # which happens when using Qt from vcpkg, or using Qt from custom location + file(READ "${VCPKG_ROOT_DIR}/_env/QT_CMAKE_PREFIX_PATH.txt" QT_CMAKE_PREFIX_PATH) + set(QUAZIP_EXTRA_OPTS "-DCMAKE_PREFIX_PATH=${QT_CMAKE_PREFIX_PATH}") +else() + # In the case of using system Qt, don't pass anything. + set(QUAZIP_EXTRA_OPTS "") +endif() + file(READ "${VCPKG_ROOT_DIR}/_env/EXTERNAL_BUILD_ASSETS.txt" EXTERNAL_BUILD_ASSETS) vcpkg_download_distfile( @@ -19,7 +28,7 @@ vcpkg_extract_source_archive_ex( vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA - OPTIONS -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_PREFIX_PATH=${QT_CMAKE_PREFIX_PATH} -DBUILD_WITH_QT4=OFF + OPTIONS -DCMAKE_POSITION_INDEPENDENT_CODE=ON ${QUAZIP_EXTRA_OPTS} -DBUILD_WITH_QT4=OFF ) vcpkg_install_cmake() From 50dfa73244045d667f5ae991e09b4a81d2167113 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sat, 27 Feb 2021 14:47:17 +0100 Subject: [PATCH 10/21] Concatenate Windows paths correctly --- hifi_qt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hifi_qt.py b/hifi_qt.py index d11988ed2e..df84c45ddd 100644 --- a/hifi_qt.py +++ b/hifi_qt.py @@ -59,7 +59,7 @@ endif() self.path = os.getenv('VIRCADIA_QT_PATH') self.fullPath = self.path - self.cmakePath = os.path.join(self.fullPath, 'lib/cmake') + self.cmakePath = os.path.join(self.fullPath, 'lib', 'cmake') qt_found = True print("Using Qt from " + self.fullPath) @@ -77,7 +77,7 @@ endif() self.path = os.path.expanduser("~/vircadia-files/qt") self.fullPath = os.path.join(self.path, 'qt5-install') - self.cmakePath = os.path.join(self.fullPath, 'lib/cmake') + self.cmakePath = os.path.join(self.fullPath, 'lib', 'cmake') if (not os.path.isdir(self.path)): os.makedirs(self.path) From 2a8278f5222b4bb442308f094f3f1d4ff5de24cd Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sat, 13 Mar 2021 23:17:15 +0100 Subject: [PATCH 11/21] Temp changes --- hifi_qt.py | 9 ++++++--- prebuild.py | 7 +++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/hifi_qt.py b/hifi_qt.py index df84c45ddd..e5f54ea545 100644 --- a/hifi_qt.py +++ b/hifi_qt.py @@ -89,9 +89,12 @@ endif() if not system_qt: if qt_found: # Sanity check, ensure we have a good cmake directory - if not os.path.isdir(os.path.join(self.cmakePath, "Qt5")): - raise Exception("Failed to find Qt5 directory under " + self.cmakePath) - + qt5_dir = os.path.join(self.cmakePath, "Qt5") + if not os.path.isdir(qt5_dir): + raise Exception("Failed to find Qt5 directory under " + self.cmakePath + ". There should be a " + qt5_dir) + else: + print("Qt5 check passed, found " + qt5_dir) + # I'm not sure why this is needed. It's used by hifi_singleton. # Perhaps it stops multiple build processes from interferring? lockDir, lockName = os.path.split(self.path) diff --git a/prebuild.py b/prebuild.py index 47ec01f8cc..34549b038c 100644 --- a/prebuild.py +++ b/prebuild.py @@ -138,10 +138,17 @@ def main(): if qtInstallPath is not None: # qtInstallPath is None when we're doing a system Qt build + print("cmake path: " + qtInstallPath) + with hifi_singleton.Singleton(qt.lockFile) as lock: with timer('Qt'): qt.installQt() qt.writeConfig() + else: + if (os.environ["VIRCADIA_USE_SYSTEM_QT"]): + print("System Qt selected") + else: + raise Exception("Internal error: System Qt not selected, but hifi_qt.py failed to return a cmake path") pm = hifi_vcpkg.VcpkgRepo(args) if qtInstallPath is not None: From 506fd9563ae55550963f91023cc163dd0d6b746f Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Wed, 24 Mar 2021 22:15:47 +0100 Subject: [PATCH 12/21] Handle empty environment variables as false --- CMakeLists.txt | 9 ++++++--- hifi_qt.py | 4 ++-- interface/CMakeLists.txt | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cbde769d3f..bbeb92ca4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,11 +102,14 @@ include("${CMAKE_BINARY_DIR}/vcpkg.cmake") if (HIFI_ANDROID) set(QT_CMAKE_PREFIX_PATH "$ENV{HIFI_ANDROID_PRECOMPILED}/qt/lib/cmake") else() - if (NOT DEFINED ENV{VIRCADIA_USE_SYSTEM_QT}) - if(NOT EXISTS "${CMAKE_BINARY_DIR}/qt.cmake") + if ("$ENV{VIRCADIA_USE_SYSTEM_QT}" STREQUAL "") + if(NOT EXISTS "${CMAKE_BINARY_DIR}/qt.cmake") message(FATAL_ERROR "qt configuration missing.") endif() include("${CMAKE_BINARY_DIR}/qt.cmake") + message(STATUS "${CMAKE_BINARY_DIR}/qt.cmake included!") + else() + message(STATUS "System Qt in use, not including qt.cmake!") endif() endif() @@ -293,7 +296,7 @@ set_packaging_parameters() # Locate the required Qt build on the filesystem setup_qt() -if (NOT DEFINED ENV{VIRCADIA_USE_SYSTEM_QT}) +if ("$ENV{VIRCADIA_USE_SYSTEM_QT}" STREQUAL "") list(APPEND CMAKE_PREFIX_PATH "${QT_CMAKE_PREFIX_PATH}") endif() diff --git a/hifi_qt.py b/hifi_qt.py index e5f54ea545..530aaff8ec 100644 --- a/hifi_qt.py +++ b/hifi_qt.py @@ -37,7 +37,7 @@ endif() system_qt = False # Here we handle the 3 possible cases of dealing with Qt: - if os.getenv('VIRCADIA_USE_SYSTEM_QT'): + if os.getenv('VIRCADIA_USE_SYSTEM_QT', "") != "": # 1. Using the system provided Qt. This is only recommended for Qt 5.15.0 and above, # as it includes a required fix on Linux. # @@ -53,7 +53,7 @@ endif() system_qt = True print("Using system Qt") - elif os.getenv('VIRCADIA_QT_PATH'): + elif os.getenv('VIRCADIA_QT_PATH', "") != "": # 2. Using an user-provided directory. # VIRCADIA_QT_PATH must point to a directory with a Qt install in it. diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 267f996535..f6d84e4e4b 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -435,7 +435,7 @@ else() endif() endif() -if (NOT DEFINED ENV{VIRCADIA_USE_SYSTEM_QT}) +if ("$ENV{VIRCADIA_USE_SYSTEM_QT}" STREQUAL "") if (DEV_BUILD AND (APPLE OR UNIX)) # create a qt.conf file to override hard-coded search paths in Qt libs set(QT_LIB_PATH "${QT_CMAKE_PREFIX_PATH}/../..") From 1b999acb2fd5e44ec115d5b30c70b326a397a76e Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Wed, 24 Mar 2021 22:16:42 +0100 Subject: [PATCH 13/21] Add more explanatory comments --- cmake/macros/SetupQt.cmake | 9 ++++++--- hifi_qt.py | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/cmake/macros/SetupQt.cmake b/cmake/macros/SetupQt.cmake index 4676a00e97..743ac934c4 100644 --- a/cmake/macros/SetupQt.cmake +++ b/cmake/macros/SetupQt.cmake @@ -5,6 +5,9 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # +# For understanding the execution flow followed by the Qt setup, +# please look at the comment on top of hifi_qt.py + function(get_sub_directories result curdir) file(GLOB children RELATIVE ${curdir} ${curdir}/*) set(dirlist "") @@ -55,7 +58,9 @@ macro(setup_qt) # then use it, # otherwise, use the vcpkg'ed version if(NOT DEFINED QT_CMAKE_PREFIX_PATH) - message(FATAL_ERROR "QT_CMAKE_PREFIX_PATH should have been set by hifi_qt.py") + # Note: This comes from qt.cmake generated by hifi_qt.py + # See the comment on top of hifi_qt.py for details. + message(FATAL_ERROR "QT_CMAKE_PREFIX_PATH should have been set by hifi_qt.py through qt.cmake") endif() if (DEV_BUILD) if (DEFINED ENV{QT_CMAKE_PREFIX_PATH}) @@ -63,8 +68,6 @@ macro(setup_qt) endif() endif() - message("QT_CMAKE_PREFIX_PATH = " ${QT_CMAKE_PREFIX_PATH}) - # figure out where the qt dir is get_filename_component(QT_DIR "${QT_CMAKE_PREFIX_PATH}/../../" ABSOLUTE) set(QT_VERSION "unknown") diff --git a/hifi_qt.py b/hifi_qt.py index 530aaff8ec..56fb3a0ec1 100644 --- a/hifi_qt.py +++ b/hifi_qt.py @@ -10,6 +10,31 @@ import json import xml.etree.ElementTree as ET import functools +# The way Qt is handled is a bit complicated, so I'm documenting it here. +# +# 1. User runs cmake +# 2. cmake calls prebuild.py, which is referenced in /CMakeLists.txt +# 3. prebuild.py calls this code. +# 4. hifi_qt.py determines how to handle cmake: do we need to download a package, and which? +# 4.a - Using system Qt +# No download, most special paths are turned off. +# We build in the same way a normal Qt program would. +# 4.b - Using an user-provided Qt build in a custom directory. +# We just need to set the cmakePath to the right dir (qt5-install/lib/cmake) +# 4.c - Using a premade package. +# We check the OS and distro and set qtUrl to the URL to download. +# After this, it works on the same pathway as 4.b. +# 5. We write /qt.cmake, which contains paths that are passed down to SetupQt.cmake +# The template for this file is in CMAKE_TEMPLATE just below this comment +# and it sets the QT_CMAKE_PREFIX_PATH variable used by SetupQt.cmake. +# 6. cmake includes /qt.cmake receiving our information +# In the case of system Qt, this step is skipped. +# 7. cmake runs SetupQt.cmake which takes care of the cmake parts of the Qt configuration. +# In the case of system Qt, SetupQt.cmake is a no-op. It runs but exits immediately. +# +# The format for a prebuilt qt is a package containing a top-level directory named +# 'qt5-install', which contains the result of a "make install" from a build of the Qt source. + print = functools.partial(print, flush=True) # Encapsulates the vcpkg system From f7af9a8b2a742fc3818be73174fcd63a5fb4cdd0 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Thu, 10 Jun 2021 22:48:33 +0200 Subject: [PATCH 14/21] Fix build - missing variable --- hifi_qt.py | 1 + 1 file changed, 1 insertion(+) diff --git a/hifi_qt.py b/hifi_qt.py index 56fb3a0ec1..6174a27505 100644 --- a/hifi_qt.py +++ b/hifi_qt.py @@ -139,6 +139,7 @@ endif() self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-macos.tar.gz' elif 'Linux' == system: import distro + cpu_architecture = platform.machine() if 'x86_64' == cpu_architecture: if distro.id() == 'ubuntu': From 3ebcced301377eeec0cabdb29967e418df009b07 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Thu, 10 Jun 2021 22:48:43 +0200 Subject: [PATCH 15/21] Fix build -- screenshare is not found --- interface/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index f6d84e4e4b..72ab17a6f2 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -197,8 +197,8 @@ if (BUILD_TOOLS AND NPM_EXECUTABLE) add_dependencies(resources jsdoc) endif() -if ((WIN32 OR APPLE OR UNIX) AND NOT ANDROID) - add_dependencies(${TARGET_NAME} resources screenshare) +if (WIN32 OR APPLE) + add_dependencies(${TARGET_NAME} resources) endif() if (SCREENSHARE) From 3f8159b3c478ab926bc4815e6b7843ab51994c82 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Thu, 10 Jun 2021 22:51:11 +0200 Subject: [PATCH 16/21] Formatting fix --- BUILD_LINUX.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD_LINUX.md b/BUILD_LINUX.md index 3bae13df9e..e5b6165da1 100644 --- a/BUILD_LINUX.md +++ b/BUILD_LINUX.md @@ -97,12 +97,12 @@ Qt binaries are only provided for Ubuntu. In order to build on other distributio needs to be provided by setting the `VIRCADIA_QT_PATH` environment variable to a directory containing a Qt install. - ### Using the system's Qt +### Using the system's Qt The system's Qt can be used, if the development packages are installed, by setting the `VIRCADIA_USE_SYSTEM_QT` environment variable. The minimum recommended version is Qt 5.15.0. - ### Compiling +### Compiling Create the build directory: ```bash From 586de4d712d8a4962488dedad61f269e1cf2936d Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Thu, 10 Jun 2021 22:51:50 +0200 Subject: [PATCH 17/21] More formatting fixes --- BUILD_LINUX.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/BUILD_LINUX.md b/BUILD_LINUX.md index e5b6165da1..0c2fd23ba3 100644 --- a/BUILD_LINUX.md +++ b/BUILD_LINUX.md @@ -94,13 +94,13 @@ git checkout master ### Using a custom Qt build Qt binaries are only provided for Ubuntu. In order to build on other distributions, a Qt5 install - needs to be provided by setting the `VIRCADIA_QT_PATH` environment variable to a directory containing - a Qt install. +needs to be provided by setting the `VIRCADIA_QT_PATH` environment variable to a directory containing +a Qt install. ### Using the system's Qt - The system's Qt can be used, if the development packages are installed, by setting the - `VIRCADIA_USE_SYSTEM_QT` environment variable. The minimum recommended version is Qt 5.15.0. +The system's Qt can be used, if the development packages are installed, by setting the +`VIRCADIA_USE_SYSTEM_QT` environment variable. The minimum recommended version is Qt 5.15.0. ### Compiling From f90d872752dc0f2e552cc34efb0b9272a00e6594 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sat, 19 Jun 2021 19:38:07 +0200 Subject: [PATCH 18/21] Formatting cleanup --- hifi_qt.py | 2 +- interface/CMakeLists.txt | 2 +- libraries/controllers/src/controllers/UserInputMapper.cpp | 4 ---- prebuild.py | 2 +- tools/skeleton-dump/src/SkeletonDumpApp.cpp | 5 ----- 5 files changed, 3 insertions(+), 12 deletions(-) diff --git a/hifi_qt.py b/hifi_qt.py index 6174a27505..34b9536b0c 100644 --- a/hifi_qt.py +++ b/hifi_qt.py @@ -119,7 +119,7 @@ endif() raise Exception("Failed to find Qt5 directory under " + self.cmakePath + ". There should be a " + qt5_dir) else: print("Qt5 check passed, found " + qt5_dir) - + # I'm not sure why this is needed. It's used by hifi_singleton. # Perhaps it stops multiple build processes from interferring? lockDir, lockName = os.path.split(self.path) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 72ab17a6f2..a2a29ed4ba 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -198,7 +198,7 @@ if (BUILD_TOOLS AND NPM_EXECUTABLE) endif() if (WIN32 OR APPLE) - add_dependencies(${TARGET_NAME} resources) + add_dependencies(${TARGET_NAME} resources) endif() if (SCREENSHARE) diff --git a/libraries/controllers/src/controllers/UserInputMapper.cpp b/libraries/controllers/src/controllers/UserInputMapper.cpp index b5e07d5691..6333792b3f 100755 --- a/libraries/controllers/src/controllers/UserInputMapper.cpp +++ b/libraries/controllers/src/controllers/UserInputMapper.cpp @@ -44,10 +44,6 @@ #include "impl/Route.h" #include "impl/Mapping.h" -#if QT_VERSION > QT_VERSION_CHECK(5, 13, 0) -// FIXME: Remove this after Qt 5.15 upgrade -#define endl Qt::endl -#endif namespace controller { const uint16_t UserInputMapper::STANDARD_DEVICE = 0; diff --git a/prebuild.py b/prebuild.py index 34549b038c..b5390362e8 100644 --- a/prebuild.py +++ b/prebuild.py @@ -139,7 +139,7 @@ def main(): if qtInstallPath is not None: # qtInstallPath is None when we're doing a system Qt build print("cmake path: " + qtInstallPath) - + with hifi_singleton.Singleton(qt.lockFile) as lock: with timer('Qt'): qt.installQt() diff --git a/tools/skeleton-dump/src/SkeletonDumpApp.cpp b/tools/skeleton-dump/src/SkeletonDumpApp.cpp index e3169098d6..42a1c78090 100644 --- a/tools/skeleton-dump/src/SkeletonDumpApp.cpp +++ b/tools/skeleton-dump/src/SkeletonDumpApp.cpp @@ -15,11 +15,6 @@ #include #include -#if QT_VERSION > QT_VERSION_CHECK(5, 13, 0) -// FIXME: Remove this after Qt 5.15 upgrade -#define endl Qt::endl -#endif - SkeletonDumpApp::SkeletonDumpApp(int argc, char* argv[]) : QCoreApplication(argc, argv) { // parse command-line From 2a07f5fd5a9739b5678da155eb8bd6064edbac51 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 20 Jun 2021 12:59:47 +0200 Subject: [PATCH 19/21] Nice colored unsupported distro messages --- BUILD_LINUX.md | 4 +++- CMakeLists.txt | 7 +++++-- hifi_qt.py | 32 ++++++++++++++++++++++++++++---- hifi_utils.py | 26 ++++++++++++++++++++++++++ prebuild.py | 5 ++++- 5 files changed, 66 insertions(+), 8 deletions(-) diff --git a/BUILD_LINUX.md b/BUILD_LINUX.md index 0c2fd23ba3..1996360fed 100644 --- a/BUILD_LINUX.md +++ b/BUILD_LINUX.md @@ -100,7 +100,9 @@ a Qt install. ### Using the system's Qt The system's Qt can be used, if the development packages are installed, by setting the -`VIRCADIA_USE_SYSTEM_QT` environment variable. The minimum recommended version is Qt 5.15.0. +`VIRCADIA_USE_SYSTEM_QT` environment variable. The minimum recommended version is Qt 5.15.2, which is +also the last version available in the Qt 5 branch. It is expected that Linux distributions will have +Qt 5.15.2 available for a long time. ### Compiling diff --git a/CMakeLists.txt b/CMakeLists.txt index bbeb92ca4c..853d00c7f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,7 @@ endif() if (HIFI_ANDROID) execute_process( COMMAND ${HIFI_PYTHON_EXEC} ${CMAKE_CURRENT_SOURCE_DIR}/prebuild.py --release-type ${RELEASE_TYPE} --android ${HIFI_ANDROID_APP} --build-root ${CMAKE_BINARY_DIR} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} RESULTS_VARIABLE PREBUILD_RET ) else() set(VCPKG_BUILD_TYPE_PARAM "") @@ -86,7 +86,7 @@ else() endif() execute_process( COMMAND ${HIFI_PYTHON_EXEC} ${CMAKE_CURRENT_SOURCE_DIR}/prebuild.py --release-type ${RELEASE_TYPE} --build-root ${CMAKE_BINARY_DIR} ${VCPKG_BUILD_TYPE_PARAM} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} RESULTS_VARIABLE PREBUILD_RET ) # squelch the Policy CMP0074 warning without requiring an update to cmake 3.12. if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12) @@ -94,6 +94,9 @@ else() endif() endif() +if ("${PREBUILD_RET}" GREATER 0) + message(FATAL_ERROR "prebuild.py failed with error ${PREBUILD_RET}") +endif() if(NOT EXISTS "${CMAKE_BINARY_DIR}/vcpkg.cmake") message(FATAL_ERROR "vcpkg configuration missing.") endif() diff --git a/hifi_qt.py b/hifi_qt.py index 34b9536b0c..72dcb97211 100644 --- a/hifi_qt.py +++ b/hifi_qt.py @@ -37,6 +37,29 @@ import functools print = functools.partial(print, flush=True) +def unsupported_error(): + import distro + cpu_architecture = platform.machine() + + print('') + hifi_utils.color('red') + print("Sorry, we don't have a prebuilt Qt package for " + distro.name(pretty=True) + " on " + cpu_architecture + ".") + hifi_utils.color('white') + print('') + print("If this is a recent distribution, dating from 2021 or so, you can try building") + print("against the system Qt by running this command, and trying again:") + print(" export VIRCADIA_USE_SYSTEM_QT=1") + print("") + hifi_utils.color('clear') + print("If you'd like to try to build Qt from source either for building Vircadia, or") + print("to contribute a prebuilt package for your distribution, please see the") + print("documentation at: ", end='') + hifi_utils.color('blue') + print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder") + hifi_utils.color('clear') + print('') + + raise hifi_utils.SilentFatalError(2) # Encapsulates the vcpkg system class QtDownloader: CMAKE_TEMPLATE = """ @@ -155,10 +178,11 @@ endif() print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading."); raise Exception('UNKNOWN LINUX DISTRO VERSION!!!') else: - print("Sorry, " + distro.name(pretty=True) + " is not supported on x86_64. Please consider helping us out.") - print("It's also possible to build Qt for your distribution, please see the documentation at:") - print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder") - raise Exception('UNKNOWN LINUX VERSION!!!') + unsupported_error() +# print("Sorry, " + distro.name(pretty=True) + " is not supported on x86_64. Please consider helping us out.") +# print("It's also possible to build Qt for your distribution, please see the documentation at:") +# print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder") +# raise Exception('UNKNOWN LINUX VERSION!!!') elif 'aarch64' == cpu_architecture: if distro.id() == 'ubuntu': u_major = int( distro.major_version() ) diff --git a/hifi_utils.py b/hifi_utils.py index 157e5858a8..19290dbc42 100644 --- a/hifi_utils.py +++ b/hifi_utils.py @@ -16,6 +16,18 @@ import functools print = functools.partial(print, flush=True) +ansi_colors = { + 'black' : 30, + 'red': 31, + 'green': 32, + 'yellow': 33, + 'blue': 34, + 'magenta': 35, + 'cyan': 36, + 'white': 37, + 'clear': 0 +} + def scriptRelative(*paths): scriptdir = os.path.dirname(os.path.realpath(sys.argv[0])) result = os.path.join(scriptdir, *paths) @@ -125,3 +137,17 @@ def downloadAndExtract(url, destPath, hash=None, hasher=hashlib.sha512(), isZip= def readEnviromentVariableFromFile(buildRootDir, var): with open(os.path.join(buildRootDir, '_env', var + ".txt")) as fp: return fp.read() + +class SilentFatalError(Exception): + """Thrown when some sort of fatal condition happened, and we already reported it to the user. + This excecption exists to give a chance to run any cleanup needed before exiting. + + It should be handled at the bottom of the call stack, where the only action is to call + sys.exit(ex.exit_code) + """ + def __init__(self, exit_code): + self.exit_code = exit_code + +def color(color_name): + # Ideally we'd use the termcolor module, but this avoids adding it as a dependency. + print("\033[1;{}m".format(ansi_colors[color_name]), end='') \ No newline at end of file diff --git a/prebuild.py b/prebuild.py index b5390362e8..f272b04b23 100644 --- a/prebuild.py +++ b/prebuild.py @@ -207,4 +207,7 @@ def main(): logger.info('end') print(sys.argv) -main() +try: + main() +except hifi_utils.SilentFatalError as fatal_ex: + sys.exit(fatal_ex.exit_code) From 588528306e29c731d304de4069d4b880c8796b30 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 20 Jun 2021 13:01:04 +0200 Subject: [PATCH 20/21] Cmake cleanup --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 853d00c7f3..facc1c999f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,7 @@ else() endif() endif() -if ("${PREBUILD_RET}" GREATER 0) +if (PREBUILD_RET GREATER 0) message(FATAL_ERROR "prebuild.py failed with error ${PREBUILD_RET}") endif() if(NOT EXISTS "${CMAKE_BINARY_DIR}/vcpkg.cmake") From 6342a8aee3b88bde05d30691eaab5855081a5cd0 Mon Sep 17 00:00:00 2001 From: Dale Glass Date: Sun, 20 Jun 2021 16:22:39 +0200 Subject: [PATCH 21/21] Better Qt error messages --- hifi_qt.py | 93 +++++++++++++++++++++++++++--------------------------- 1 file changed, 47 insertions(+), 46 deletions(-) diff --git a/hifi_qt.py b/hifi_qt.py index 72dcb97211..078f80c38d 100644 --- a/hifi_qt.py +++ b/hifi_qt.py @@ -37,29 +37,6 @@ import functools print = functools.partial(print, flush=True) -def unsupported_error(): - import distro - cpu_architecture = platform.machine() - - print('') - hifi_utils.color('red') - print("Sorry, we don't have a prebuilt Qt package for " + distro.name(pretty=True) + " on " + cpu_architecture + ".") - hifi_utils.color('white') - print('') - print("If this is a recent distribution, dating from 2021 or so, you can try building") - print("against the system Qt by running this command, and trying again:") - print(" export VIRCADIA_USE_SYSTEM_QT=1") - print("") - hifi_utils.color('clear') - print("If you'd like to try to build Qt from source either for building Vircadia, or") - print("to contribute a prebuilt package for your distribution, please see the") - print("documentation at: ", end='') - hifi_utils.color('blue') - print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder") - hifi_utils.color('clear') - print('') - - raise hifi_utils.SilentFatalError(2) # Encapsulates the vcpkg system class QtDownloader: CMAKE_TEMPLATE = """ @@ -172,17 +149,12 @@ endif() if u_major == 18: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-ubuntu-18.04-amd64.tar.xz' elif u_major > 19: - print("We don't support " + distro.name(pretty=True) + " yet. Perhaps consider helping us out?") - raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!') + self.__no_qt_package_error() else: - print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading."); - raise Exception('UNKNOWN LINUX DISTRO VERSION!!!') + self.__unsupported_error() else: - unsupported_error() -# print("Sorry, " + distro.name(pretty=True) + " is not supported on x86_64. Please consider helping us out.") -# print("It's also possible to build Qt for your distribution, please see the documentation at:") -# print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder") -# raise Exception('UNKNOWN LINUX VERSION!!!') + self.__no_qt_package_error() + elif 'aarch64' == cpu_architecture: if distro.id() == 'ubuntu': u_major = int( distro.major_version() ) @@ -191,11 +163,9 @@ endif() if u_major == 18: self.qtUrl = 'http://motofckr9k.ddns.net/vircadia_packages/qt5-install-5.15.2-ubuntu-18.04-aarch64_test.tar.xz' elif u_major > 19: - print("We don't support " + distro.name(pretty=True) + " on aarch64 yet. Perhaps consider helping us out?") - raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!') + self.__no_qt_package_error() else: - print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading."); - raise Exception('UNKNOWN LINUX DISTRO VERSION!!!') + self.__unsupported_error() elif distro.id() == 'debian': u_major = int( distro.major_version() ) @@ -203,20 +173,14 @@ endif() if u_major == 10: #self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.12.3-ubuntu-16.04-with-symbols.tar.gz' - print("We don't support " + distro.name(pretty=True) + " on aarch64 yet. Perhaps consider helping us out?") - raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!') + self.__no_qt_package_error() elif u_major > 10: - print("We don't support " + distro.name(pretty=True) + " on aarch64 yet. Perhaps consider helping us out?") - raise Exception('LINUX DISTRO IS NOT SUPPORTED YET!!!') + self.__no_qt_package_error() else: - print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading."); - raise Exception('UNKNOWN LINUX DISTRO VERSION!!!') + self.__unsupported_error() else: - print("Sorry, " + distro.name(pretty=True) + " is not supported on aarch64. Please consider helping us out.") - print("It's also possible to build Qt for your distribution, please see the documentation at:") - print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder") - raise Exception('UNKNOWN LINUX VERSION!!!') + self.__no_qt_package_error() else: raise Exception('UNKNOWN CPU ARCHITECTURE!!!') @@ -248,3 +212,40 @@ endif() hifi_utils.downloadAndExtract(self.qtUrl, self.path) else: print ('Qt has already been downloaded') + + + def __unsupported_error(self): + import distro + cpu_architecture = platform.machine() + + print('') + hifi_utils.color('red') + print("Sorry, " + distro.name(pretty=True) + " on " + cpu_architecture + " is too old and won't be officially supported.") + hifi_utils.color('white') + print("Please upgrade to a more recent Linux distribution.") + hifi_utils.color('clear') + print('') + raise hifi_utils.SilentFatalError(3) + + def __no_qt_package_error(self): + import distro + cpu_architecture = platform.machine() + + print('') + hifi_utils.color('red') + print("Sorry, we don't have a prebuilt Qt package for " + distro.name(pretty=True) + " on " + cpu_architecture + ".") + hifi_utils.color('white') + print('') + print("If this is a recent distribution, dating from 2021 or so, you can try building") + print("against the system Qt by running this command, and trying again:") + print(" export VIRCADIA_USE_SYSTEM_QT=1") + print("") + hifi_utils.color('clear') + print("If you'd like to try to build Qt from source either for building Vircadia, or") + print("to contribute a prebuilt package for your distribution, please see the") + print("documentation at: ", end='') + hifi_utils.color('blue') + print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder") + hifi_utils.color('clear') + print('') + raise hifi_utils.SilentFatalError(2)