DepperDan/build_functions/build_udpcap.py

49 lines
1.8 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
from common.settings import temporarily_set_shared
from package.package_info import get_package_info
def build_udpcap(prefix: Path | str, sbom: dict):
print_banner("Building udpcap")
package_info = get_package_info("udpcap")
package_info.add_to_sbom(sbom)
# this is a can of worms here...
#
# This depends on pcapplusplus which in turn depends on npcap.
# But npcap can only be built with spectre mitigated VS SDK libraries,
# which I don't want to impose on the user. I will
# leave this out until I know for sure what this is needed for
asio_install_path = package_info.dependency_path("asio")
pcapplusplus_install_path = package_info.dependency_path("pcapplusplus")
cmake_args = [
("UDPCAP_BUILD_SAMPLES:BOOL", "OFF"),
("UDPCAP_BUILD_TESTS:BOOL", "OFF"),
("UDPCAP_THIRDPARTY_ENABLED:BOOL", "ON"),
("UDPCAP_THIRDPARTY_USE_BUILTIN_NPCAP:BOOL", "OFF"),
("UDPCAP_THIRDPARTY_USE_BUILTIN_PCAPPLUSPLUS:BOOL", "OFF"),
("UDPCAP_THIRDPARTY_USE_BUILTIN_ASIO:BOOL", "OFF"),
("UDPCAP_THIRDPARTY_USE_BUILTIN_GTEST:BOOL", "OFF"),
("asio_DIR:PATH", str(asio_install_path)),
("asio_INCLUDE_DIR:PATH", str(asio_install_path / "include")),
]
src_dir = clone_git_tag(package_info, recursive=False)
install_dir = cmake_build_install(src_dir, package_info, cmake_args=cmake_args)
write_package_version_batch(package_info.version)
return install_dir