44 lines
1.6 KiB
Python
44 lines
1.6 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, assemble_prefix_path
|
|
from common.git_helpers import clone_git_tag
|
|
import common.settings
|
|
from package.package_info import get_package_info
|
|
|
|
|
|
def build_protobuf(prefix: Path | str, sbom: dict):
|
|
print_banner("Building Protobuf")
|
|
|
|
package_info = get_package_info("protobuf")
|
|
package_info.add_to_sbom(sbom)
|
|
|
|
deps = [
|
|
package_info.dependency("abseil-cpp"),
|
|
package_info.dependency("zlib")
|
|
]
|
|
|
|
protobuf_cmake_args = [
|
|
("BUILD_SHARED_LIBS:BOOL", "OFF"),
|
|
("BUILD_TESTING:BOOL", "OFF"),
|
|
("protobuf_BUILD_TESTS:BOOL", "OFF"),
|
|
("protobuf_WITH_ZLIB:BOOL", "ON"),
|
|
# ("ABSL_PROPAGATE_CXX_STD:BOOL", "ON"),
|
|
("protobuf_MSVC_STATIC_RUNTIME:BOOL", "OFF"),
|
|
("protobuf_ABSL_PROVIDER:STRING", "package"),
|
|
("protobuf_ZLIB_PROVIDER:STRING", "package"),
|
|
("CMAKE_PREFIX_PATH:STRING", assemble_prefix_path(deps)),
|
|
("protobuf_INSTALL:BOOL", "ON"),
|
|
("ZLIB_USE_STATIC_LIBS:BOOL", "ON"), # doesn't appear to do its job
|
|
# We are on fake debug
|
|
]
|
|
protobuf_dir = clone_git_tag(package_info, recursive=False)
|
|
install_dir = cmake_build_install(protobuf_dir, package_info, cmake_args=protobuf_cmake_args)
|
|
write_package_version_batch(package_info.version)
|
|
return install_dir
|