DepperDan/build_functions/build_abseil.py

43 lines
1.5 KiB
Python

# (c) 2025 by Stephan Menzel
# Licensed under the Apache License, Version 2.0.
# See attached file LICENSE for full details
import subprocess
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.directory_helpers import pushd
from common.git_helpers import clone_git_tag
from package.package_info import get_package_info
def build_abseil_cpp(prefix: Path | str, sbom: dict) -> Path:
print_banner("Building Abseil")
package_info = get_package_info("abseil-cpp")
package_info.add_to_sbom(sbom)
abseil_cmake_args = [
("BUILD_SHARED_LIBS:BOOL", "OFF"),
("BUILD_TESTING:BOOL", "OFF"),
("ABSL_PROPAGATE_CXX_STD:BOOL", "ON"),
("ABSL_BUILD_TESTING:BOOL", "OFF"),
("ABSL_BUILD_TEST_HELPERS", "OFF"),
("ABSL_ENABLE_INSTALL:BOOL", "ON"),
("ABSL_RUN_TESTS:BOOL", "OFF"),
]
abseil_dir = clone_git_tag(package_info, recursive=True)
# Abseil LTS doesn't build with CMake>=3.30 due to some imported GTest target.
# Gotta patch that shit until this situation is resolved. https://github.com/abseil/abseil-cpp/issues/690
# with pushd(abseil_dir):
# subprocess.run(["git", "apply", "..\\..\\gtest_fix.patch"])
install_dir = cmake_build_install(abseil_dir, package_info, cmake_args=abseil_cmake_args)
write_package_version_batch(package_info.version)
return install_dir