# (c) 2025 by Stephan Menzel # Licensed under the Apache License, Version 2.0. # See attached file LICENSE for full details import os from pathlib import Path from build_functions.build_utils import run_in_shell, print_banner, file_and_console_log from common.azure import write_package_version_batch from common.directory_helpers import pushd, get_local_prefix from common.git_helpers import clone_git_tag from package.package_info import get_package_info def build_qt5(prefix: Path | str, sbom: dict): print_banner("Building Qt5") package_info = get_package_info("qt5") package_info.add_to_sbom(sbom) zlib_install_path = package_info.dependency_path("zlib") # Protobuf may not be such a strong dependency protobuf_install_path = package_info.dependency_path("protobuf") qt_src_dir = clone_git_tag(package_info, recursive=True) with pushd(qt_src_dir): install_dir = package_info.install_location() build_folder = "_build" if not os.path.isdir(build_folder): os.makedirs(build_folder) with pushd(build_folder): configure = Path("..") / "configure.bat" zlib_include = zlib_install_path / 'include' zlib_lib = zlib_install_path / 'lib' / 'zlibstatic.lib' run_in_shell( f"{configure} " f"-prefix {install_dir} " "-release " "-mp " "-confirm-license " "-c++std c++2b " "-opensource " # Specify exactly which modules we need. This is way better than excluding # what we don't need, assuming this is a lot # "-submodules qtbase,qtsvg " "-gui -widgets -no-dbus " "-D QT_BUILD_TESTS_BY_DEFAULT=OFF " # f"-system-zlib -I {str((zlib_install_path / 'include').as_posix())} -L {str(zlib_lib.as_posix())} " "-nomake examples " "-nomake tests " "-skip qtlottie " "-skip qtmultimedia " "-skip qtpurchasing " "-skip qtwebengine " "-skip qtwebchannel " "-skip qtwayland " "-skip qtspeech " "-skip qtdatavis3d " "-skip qtlocation " "-skip qtdeclarative " "-skip qtconnectivity " "-skip qtsystems " "-skip qtxmlpatterns " "-skip qtscript " # "-- " # This should not be necessary but the -system-zlib parameter above appears bugged. # It should help CMake to find ZLib # f"-DZLIB_INCLUDE_DIR=\"{zlib_include.as_posix()}\" " # f"-DZLIB_LIBRARY=\"{zlib_lib.as_posix()}\" " ) run_in_shell(f'nmake') run_in_shell(f'nmake install') with open("built_and_installed.txt", "w") as lockfile: lockfile.write(f"built release") write_package_version_batch(package_info.version) return install_dir