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)