DepperDan/build_functions/build_curl.py

61 lines
2.3 KiB
Python

# (c) 2025 by Stephan Menzel
# Licensed under the Apache License, Version 2.0.
# See attached file LICENSE for full details
from pathlib import Path
from build_functions.build_utils import print_banner
from common.azure import write_package_version_batch
from common.cmake import cmake_build_install
from common.git_helpers import clone_git_tag
import common.settings
from package.package_info import get_package_info
def build_curl(prefix: Path | str, sbom: dict):
print_banner("Building CURL")
package_info = get_package_info("curl")
package_info.add_to_sbom(sbom)
zlib_install_path = package_info.dependency_path("zlib")
# It only appears to depend on gtest when I enable tests, which I don't
# googletest_install_path = package_info.dependency_path(prefix, "googletest")
curl_cmake_args = [
("BUILD_LIBCURL_DOCS:BOOL", "OFF"),
("BUILD_MISC_DOCS:BOOL", "OFF"),
("BUILD_CURL_EXE:BOOL", "OFF"),
("BUILD_EXAMPLES:BOOL", "OFF"),
("BUILD_STATIC_LIBS:BOOL", "ON"),
# This is only optional until 8.11, which is why this is not using a more recent version
# Libpsl has no Windows build support. https://github.com/curl/curl/issues/16486
# This means, you're probably not able to upgrade beyond 8.11.x
("CURL_USE_LIBPSL:BOOL", "OFF"),
("CURL_USE_LIBIDN2:BOOL", "OFF"),
("CURL_USE_LIBSSH2:BOOL", "OFF"),
("ENABLE_CURL_MANUAL:BOOL", "OFF"),
# Many optional dependencies. I switch off as many as I can get away with.
# Once we know for sure which ones we need we can always bring them in
("USE_HTTPSRR:BOOL", "OFF"),
("USE_ECH:BOOL", "OFF"),
("USE_LIBIDN2:BOOL", "OFF"),
("USE_MSH3:BOOL", "OFF"),
("USE_NGHTTP2:BOOL", "OFF"),
("USE_NGTCP2:BOOL", "OFF"),
("ZLIB_ROOT:PATH", str(zlib_install_path)),
("ZLIB_USE_STATIC_LIBS:BOOL", "ON"),
("ZLIB_LIBRARY_RELEASE:FILEPATH", str(zlib_install_path / "lib" / common.settings.zlib_static_lib_name)),
("ZLIB_LIBRARY_DEBUG:FILEPATH", str(zlib_install_path / "lib" / common.settings.zlib_static_lib_name))
]
curl_dir = clone_git_tag(package_info, recursive=True)
install_dir = cmake_build_install(curl_dir, package_info, cmake_args=curl_cmake_args)
write_package_version_batch(package_info.version)
return install_dir