diff --git a/BUILD_LINUX.md b/BUILD_LINUX.md index e9c5047e38..1996360fed 100644 --- a/BUILD_LINUX.md +++ b/BUILD_LINUX.md @@ -93,13 +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.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 77d0413690..facc1c999f 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() @@ -101,11 +104,16 @@ 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 ("$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() - include("${CMAKE_BINARY_DIR}/qt.cmake") endif() option(VCPKG_APPLOCAL_DEPS OFF) @@ -290,7 +298,10 @@ set_packaging_parameters() # Locate the required Qt build on the filesystem setup_qt() -list(APPEND CMAKE_PREFIX_PATH "${QT_CMAKE_PREFIX_PATH}") + +if ("$ENV{VIRCADIA_USE_SYSTEM_QT}" STREQUAL "") + 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 6f31a3994c..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 "") @@ -25,6 +28,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}'") @@ -45,49 +51,64 @@ 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") - endif() - if (DEV_BUILD) - if (DEFINED ENV{QT_CMAKE_PREFIX_PATH}) - set(QT_CMAKE_PREFIX_PATH $ENV{QT_CMAKE_PREFIX_PATH}) - endif() - endif() + 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) + # 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}) + 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 () - # 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() - - message(STATUS "Using Qt build in : '${QT_DIR}' with version ${QT_VERSION}") - # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) # Instruct CMake to run rcc automatically when needed set(CMAKE_AUTORCC ON) - if (WIN32) - add_paths_to_fixup_libs("${QT_DIR}/bin") - endif () - endmacro() 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() diff --git a/hifi_qt.py b/hifi_qt.py index 7ee8a787b5..078f80c38d 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 @@ -28,32 +53,85 @@ 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') - - print("Using qt path {}".format(self.path)) - 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 (os.getenv('VIRCADIA_USE_PREBUILT_QT')): - print("Using pre-built Qt5") - return - # OS dependent information system = platform.system() - cpu_architecture = platform.machine() + + qt_found = False + system_qt = 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") + + self.path = None + self.cmakePath = None + + qt_found = True + system_qt = 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 not system_qt: + if qt_found: + # Sanity check, ensure we have a good cmake directory + 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) + 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") + return if 'Windows' == system: self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-windows.tar.gz' @@ -61,7 +139,7 @@ endif() self.qtUrl = self.assets_url + '/dependencies/vcpkg/qt5-install-5.15.2-macos.tar.gz' elif 'Linux' == system: import distro - dist = distro.linux_distribution() + cpu_architecture = platform.machine() if 'x86_64' == cpu_architecture: if distro.id() == 'ubuntu': @@ -71,16 +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: - 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() ) @@ -89,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() ) @@ -101,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!!!') @@ -124,6 +190,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 @@ -138,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) 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/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') diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index c307c63142..a2a29ed4ba 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() @@ -435,18 +435,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 ("$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}/../..") + 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/prebuild.py b/prebuild.py index d5bed2d813..f272b04b23 100644 --- a/prebuild.py +++ b/prebuild.py @@ -130,23 +130,33 @@ 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 + 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 != '': + 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 @@ -197,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) 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} )