DepperDan/build_functions/build_openusd.py

58 lines
2.4 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
import common.settings
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_openusd(prefix: Path | str, sbom: dict):
print_banner("Building OpenUSD")
package_info = get_package_info("openusd")
package_info.add_to_sbom(sbom)
# I mistook boost for a direct dependency but it turned out to be an indirect one.
# Various other, optional, dependencies such as OpenImageIO use it.
# We don't have them in here yet but I keep boost to prepare for that
deps = [
package_info.dependency("boost"),
package_info.dependency("hdf5"),
package_info.dependency("onetbb"),
package_info.dependency("opensubdiv"),
package_info.dependency("zlib")
]
zlib_install_path = package_info.dependency_path("zlib")
# OpenUSD definately doesn't want to be build static. Only errors. DLL it is then.
with temporarily_set_shared():
cmake_args = [
("PXR_ENABLE_PYTHON_SUPPORT:BOOL", "ON"),
("PXR_ENABLE_HDF5_SUPPORT:BOOL", "ON"),
("PXR_BUILD_EXAMPLES:BOOL", "ON"),
("PXR_BUILD_TESTS:BOOL", "OFF"),
("PXR_BUILD_TUTORIALS:BOOL", "ON"),
("PXR_BUILD_HTML_DOCUMENTATION:BOOL", "ON"),
# This will pull in the Vulkan SDK. We're probably going to need it at some point
("PXR_ENABLE_VULKAN_SUPPORT:BOOL", "OFF"),
("CMAKE_PREFIX_PATH:STRING", assemble_prefix_path(deps)),
("ZLIB_ROOT:PATH", str(zlib_install_path.as_posix())),
("ZLIB_USE_STATIC_LIBS:BOOL", "ON"), # doesn't appear to do its job
("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))
]
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