74 lines
2.6 KiB
Python
74 lines
2.6 KiB
Python
# (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
|
|
import common.settings
|
|
from package.package_info import get_package_info
|
|
|
|
|
|
def build_qt6(prefix: Path | str, sbom: dict):
|
|
|
|
print_banner("Building Qt6")
|
|
|
|
package_info = get_package_info("qt6")
|
|
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 "
|
|
"-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 "
|
|
"-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 "
|
|
"-- "
|
|
# 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()}\" "
|
|
)
|
|
|
|
# Qt6 can use Cmake, Qt5 cannot
|
|
run_in_shell(f'cmake --build . --parallel {common.settings.num_cores}')
|
|
run_in_shell(f'cmake --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
|