Skip to content

Commit fe3fdda

Browse files
committed
Boost: Use Headers instead of building when not required
When building USD without Python, OIIO or VDB, Boost libs aren't required. In this scenario, it is preferable to just copy over the headers instead and save some time and complexity. This also has a significant benefit that it allows the core USD build to be supported on platforms that Boost doesn't natively build on yet like iOS and visionOS. It means that the build_usd.py script doesn't need to carry as many patches to Boost itself if someone is just building the core USD library. This is similar to [PR 2914](PixarAnimationStudios#2914) but can short circuit the entire bootstrap and b2 process, which may still error on platforms that b2 doesn't understand.
1 parent c317892 commit fe3fdda

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

build_scripts/build_usd.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,8 +768,38 @@ def InstallBoost_Helper(context, force, buildArgs):
768768
"*/libs/wave/test/testwave/testfiles/utf8-test-*"
769769
]
770770

771-
with CurrentWorkingDirectory(DownloadURL(BOOST_URL, context, force,
771+
headersOnly = not (context.buildOIIO or context.enableOpenVDB or context.buildPython)
772+
773+
with CurrentWorkingDirectory(DownloadURL(BOOST_URL, context, force,
772774
dontExtract=dontExtract)):
775+
if headersOnly:
776+
# We don't need all the headers, so we elide some for space
777+
accepted = {'assert', 'config', 'core', 'detail', 'function', 'intrusive_ptr', 'iterator', 'lexical_cast',
778+
'mpl', 'exception', 'move', 'container', 'integer', 'range', 'concept', 'noncopyable',
779+
'numeric', 'optional', 'preprocessor', 'smart_ptr', 'variant', 'vmd', 'type', 'utility'}
780+
781+
def _filteredHeaderCopy(src, dst):
782+
"""This utility function only copies over headers that meet our criteria"""
783+
doCopy = False
784+
parent = os.path.dirname(src)
785+
# First we copy over any headers that are in the root of the boost dir, but have no associated subdir
786+
# We assume these are shared across many boost libs
787+
if src.endswith(".hpp") and os.path.basename(parent) == "boost":
788+
lookFor = os.path.join(parent, os.path.splitext(os.path.basename(src))[0])
789+
doCopy = not os.path.exists(lookFor)
790+
# For everything else, we check against the accepted list above to see if they're a dir we want
791+
if not doCopy:
792+
for accept in accepted:
793+
if f"boost/{accept}" in dst:
794+
doCopy = True
795+
break
796+
if doCopy:
797+
return shutil.copy2(src, dst)
798+
799+
headersDir = os.path.abspath("./boost")
800+
CopyDirectory(context, headersDir, "include/boost", copy_function=_filteredHeaderCopy)
801+
return
802+
773803
if Windows():
774804
bootstrap = "bootstrap.bat"
775805
else:

0 commit comments

Comments
 (0)