Nice colored unsupported distro messages

This commit is contained in:
Dale Glass 2021-06-20 12:59:47 +02:00
parent f90d872752
commit 2a07f5fd5a
5 changed files with 66 additions and 8 deletions

View file

@ -100,7 +100,9 @@ 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 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 ### Compiling

View file

@ -77,7 +77,7 @@ endif()
if (HIFI_ANDROID) if (HIFI_ANDROID)
execute_process( 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} 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() else()
set(VCPKG_BUILD_TYPE_PARAM "") set(VCPKG_BUILD_TYPE_PARAM "")
@ -86,7 +86,7 @@ else()
endif() endif()
execute_process( 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} 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. # squelch the Policy CMP0074 warning without requiring an update to cmake 3.12.
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12) if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.12)
@ -94,6 +94,9 @@ else()
endif() endif()
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") if(NOT EXISTS "${CMAKE_BINARY_DIR}/vcpkg.cmake")
message(FATAL_ERROR "vcpkg configuration missing.") message(FATAL_ERROR "vcpkg configuration missing.")
endif() endif()

View file

@ -37,6 +37,29 @@ import functools
print = functools.partial(print, flush=True) 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 # Encapsulates the vcpkg system
class QtDownloader: class QtDownloader:
CMAKE_TEMPLATE = """ CMAKE_TEMPLATE = """
@ -155,10 +178,11 @@ endif()
print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading."); print("Sorry, " + distro.name(pretty=True) + " is old and won't be officially supported. Please consider upgrading.");
raise Exception('UNKNOWN LINUX DISTRO VERSION!!!') raise Exception('UNKNOWN LINUX DISTRO VERSION!!!')
else: else:
print("Sorry, " + distro.name(pretty=True) + " is not supported on x86_64. Please consider helping us out.") unsupported_error()
print("It's also possible to build Qt for your distribution, please see the documentation at:") # print("Sorry, " + distro.name(pretty=True) + " is not supported on x86_64. Please consider helping us out.")
print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder") # print("It's also possible to build Qt for your distribution, please see the documentation at:")
raise Exception('UNKNOWN LINUX VERSION!!!') # print("https://github.com/vircadia/vircadia/tree/master/tools/qt-builder")
# raise Exception('UNKNOWN LINUX VERSION!!!')
elif 'aarch64' == cpu_architecture: elif 'aarch64' == cpu_architecture:
if distro.id() == 'ubuntu': if distro.id() == 'ubuntu':
u_major = int( distro.major_version() ) u_major = int( distro.major_version() )

View file

@ -16,6 +16,18 @@ import functools
print = functools.partial(print, flush=True) 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): def scriptRelative(*paths):
scriptdir = os.path.dirname(os.path.realpath(sys.argv[0])) scriptdir = os.path.dirname(os.path.realpath(sys.argv[0]))
result = os.path.join(scriptdir, *paths) result = os.path.join(scriptdir, *paths)
@ -125,3 +137,17 @@ def downloadAndExtract(url, destPath, hash=None, hasher=hashlib.sha512(), isZip=
def readEnviromentVariableFromFile(buildRootDir, var): def readEnviromentVariableFromFile(buildRootDir, var):
with open(os.path.join(buildRootDir, '_env', var + ".txt")) as fp: with open(os.path.join(buildRootDir, '_env', var + ".txt")) as fp:
return fp.read() 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='')

View file

@ -207,4 +207,7 @@ def main():
logger.info('end') logger.info('end')
print(sys.argv) print(sys.argv)
main() try:
main()
except hifi_utils.SilentFatalError as fatal_ex:
sys.exit(fatal_ex.exit_code)