From 356c3975a417424f9bd429877382877ef5cc2c43 Mon Sep 17 00:00:00 2001 From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> Date: Mon, 14 Apr 2025 17:00:52 -0400 Subject: [PATCH] Windows-build: improve search for jom.exe Change-Id: I8695b0774f930841f8667c97f3a7642f98de78a7 --- extras/scripts/winmake.py | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/extras/scripts/winmake.py b/extras/scripts/winmake.py index c76bc0a2b9..b7d943770b 100644 --- a/extras/scripts/winmake.py +++ b/extras/scripts/winmake.py @@ -49,13 +49,37 @@ def build_contrib(args, paths): "CONTRIB_SRC_DIR": os.path.join(paths.contrib_dir, "src"), } ) - # Find JOM if it is installed. (default C:/Qt/Tools/QtCreator/bin/jom) - # Used to accelerate the build process when normally using nmake. - qt_tools_dir = os.path.join(os.getenv("QTDIR", "C:\Qt"), "Tools") - jom_path = os.path.join(qt_tools_dir, "QtCreator", "bin", "jom", "jom.exe") - if os.path.exists(jom_path): - log.info("Found JOM at " + jom_path) - sh_exec.append_extra_env_vars({"MAKE_TOOL": jom_path}) + # Allow supplying the path to the jom executable via the environment variable JOM_PATH. + # It is used to accelerate the build processes that use nmake. + jom_path = os.getenv("JOM_PATH") + if jom_path and os.path.exists(jom_path): + log.info(f"Using JOM from environment: {jom_path}") + else: + # Try to find JOM in the default Qt installation path + qt_tools_dir = os.path.join(os.getenv("QTDIR", "C:\\Qt"), "Tools") + jom_path = os.path.join(qt_tools_dir, "QtCreator", "bin", "jom", "jom.exe") + + if not os.path.exists(jom_path): + # Fallback to looking in other common Qt Creator paths + qt_creator_paths = [ + os.path.join(qt_tools_dir, "QtCreator"), + os.path.join(os.getenv("ProgramFiles", "C:\\Program Files"), "Qt Creator"), + os.path.join(os.getenv("ProgramFiles(x86)", "C:\\Program Files (x86)"), "Qt Creator") + ] + + for path in qt_creator_paths: + test_path = os.path.join(path, "bin", "jom", "jom.exe") + if os.path.exists(test_path): + jom_path = test_path + break + + if os.path.exists(jom_path): + log.info(f"Found JOM at: {jom_path}") + else: + log.warning("JOM not found. Build performance may be reduced.") + return + + sh_exec.append_extra_env_vars({"MAKE_TOOL": jom_path}) versioner.builder.set_vs_env_init_cb(vs_env_init_cb) -- GitLab