Make Windows build script traverse paths for Qt Location

The environment variable still has precedence, and will be used before
all other versions if it exists.
This commit is contained in:
Vasily
2019-07-24 10:54:55 +02:00
committed by username223
parent 275d0813b5
commit 112e611709
2 changed files with 46 additions and 5 deletions
+5 -5
View File
@@ -90,7 +90,7 @@ def deploy():
set_dirs()
say("Testing if all required build environment variables are set:")
QT_LOC = get_required_env_var_path(QT_LOC_VAR_NAME, QT_LOC_DEFAULT)
QT_LOC = find_qt_path()
say("All required build environment values are set.")
if is_env_var_set(BUILD_DEBUG_VAR_NAME):
@@ -153,13 +153,13 @@ def build():
COMPILE_MODE = ""
COMPILER = ""
say("Attempting to build version: " + VERSION_STRING)
say("Testing if all required build environment variables are set:")
QT_LOC = get_required_env_var_path(QT_LOC_VAR_NAME, QT_LOC_DEFAULT)
QT_LOC = find_qt_path()
VS_LOC = get_required_env_var_path(VS_LOC_VAR_NAME, VS_LOC_DEFAULT)
if is_env_var_set(BUILD_CLANG_VAR_NAME):
say(f"{BUILD_CLANG_VAR_NAME} defined. Building for win32-clang-msvc.")
get_required_env_var_path(LLVM_LOC_VAR_NAME, LLVM_LOC_DEFAULT)
+41
View File
@@ -7,6 +7,7 @@ import argparse
import subprocess
import shutil
import distutils.dir_util
import string
def get_version_string():
dir_path = os.path.dirname(os.path.realpath(__file__))
@@ -123,6 +124,46 @@ def get_required_env_var_path(env_var_name: str, default_env_var_value: str):
say(f"{env_var_name} exists.")
return path
def find_qt_path():
if is_env_var_set(QT_LOC_VAR_NAME):
say(f"{QT_LOC_VAR_NAME} is defined. Attempting to find first.")
qt_path = os.getenv(QT_LOC_VAR_NAME).replace('"', '')
say(f"{QT_LOC_VAR_NAME} is set to '{qt_path}'.")
if os.path.exists(qt_path):
say(f"'{qt_path}' exists. Using this path.")
return qt_path
else:
say(f"'{qt_path}' does not exist, attempting to traverse filesystem.")
qt_path = traverse_and_find_qt_path()
if qt_path == "NOTFOUND":
say("Qt path could not be find by traversal. Exiting.")
exit_on_error(EXIT_CODE_FAILURE_BUILD_LOCATION)
return qt_path
def traverse_and_find_qt_path():
qt_folder_name = r":\\Qt\\"
qt_visual_studio_name = r"\\msvc2017_64\bin\\"
qt_major_version = 5
qt_minor_versions = [12, 13, 14, 15, 16]
qt_patch_versions = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# We search the A and B drive letters even though it's
# unlikely for the install to be there
windows_drive_letters = string.ascii_uppercase
for drive in windows_drive_letters:
# Go in reverse because we want the highest versions first
for minor in reversed(qt_minor_versions):
for patch in reversed(qt_patch_versions):
version = str(qt_major_version) + "." + str(minor) + "." + str(patch)
path = str(drive) + qt_folder_name + version + qt_visual_studio_name
if os.path.exists(path):
say("Found QT path: '" + path + "'")
return path
say("Did not find any valid QT path.")
return "NOTFOUND"
def create_batch_file():
"""
Creates a batch file in the dir. Must be called by another outside batch file.