@@ -1730,6 +1730,10 @@ def InstallUSD(context, force, buildArgs):
17301730 if Windows ():
17311731 # Increase the precompiled header buffer limit.
17321732 extraArgs .append ('-DCMAKE_CXX_FLAGS="/Zm150"' )
1733+ if MacOS ():
1734+ extraArgs .append (f"-DPXR_BUILD_APPLE_FRAMEWORK={ 'ON' if context .buildAppleFramework else 'OFF' } " )
1735+ if context .macOSCodesign :
1736+ extraArgs .append (f"-DPXR_APPLE_CODESIGN_IDENTITY={ context .macOSCodesign } " )
17331737
17341738 # Make sure to use boost installed by the build script and not any
17351739 # system installed boost
@@ -1845,6 +1849,12 @@ def InstallUSD(context, force, buildArgs):
18451849 help = ("Build target for macOS cross compilation. "
18461850 "(default: {})" .format (
18471851 apple_utils .GetBuildTargetDefault ())))
1852+ subgroup = group .add_mutually_exclusive_group ()
1853+ subgroup .add_argument ("--build-apple-framework" , dest = "build_apple_framework" , action = "store_true" ,
1854+ help = "Build USD as an Apple Framework (Default if using build)" )
1855+ subgroup .add_argument ("--no-build-apple-framework" , dest = "no_build_apple_framework" , action = "store_true" ,
1856+ help = "Do not build USD as an Apple Framework (Default if macOS)" )
1857+
18481858 if apple_utils .IsHostArm ():
18491859 # Intel Homebrew stores packages in /usr/local which unfortunately can
18501860 # be where a lot of other things are too. So we only add this flag on arm macs.
@@ -1880,6 +1890,7 @@ def InstallUSD(context, force, buildArgs):
18801890 default = codesignDefault , action = "store_true" ,
18811891 help = ("Enable code signing for macOS builds "
18821892 "(defaults to enabled on Apple Silicon)" ))
1893+ group .add_argument ("--codesign-id" , dest = "macos_codesign_id" , type = str )
18831894
18841895if Linux ():
18851896 group .add_argument ("--use-cxx11-abi" , type = int , choices = [0 , 1 ],
@@ -2161,11 +2172,18 @@ def __init__(self, args):
21612172 self .buildTarget = args .build_target
21622173 apple_utils .SetTarget (self , self .buildTarget )
21632174
2164- self .macOSCodesign = \
2165- ( args .macos_codesign if hasattr ( args , "macos_codesign" )
2166- else False )
2175+ self .macOSCodesign = False
2176+ if args .macos_codesign :
2177+ self . macOSCodesign = args . macos_codesign_id or apple_utils . GetCodeSignID ( )
21672178 if apple_utils .IsHostArm () and args .ignore_homebrew :
21682179 self .ignorePaths .append ("/opt/homebrew" )
2180+
2181+ self .buildAppleFramework = ((args .build_apple_framework
2182+ or self .buildTarget in apple_utils .EMBEDDED_PLATFORMS )
2183+ and not args .no_build_apple_framework )
2184+ if self .buildAppleFramework :
2185+ self .buildShared = False
2186+ self .buildMonolithic = True
21692187 else :
21702188 self .buildTarget = ""
21712189
@@ -2479,6 +2497,7 @@ def _JoinVersion(v):
24792497summaryMsg += """\
24802498 Variant {buildVariant}
24812499 Target {buildTarget}
2500+ Framework Build {buildAppleFramework}
24822501 Imaging {buildImaging}
24832502 Ptex support: {enablePtex}
24842503 OpenVDB support: {enableOpenVDB}
@@ -2563,7 +2582,8 @@ def FormatBuildArguments(buildArgs):
25632582 buildMaterialX = ("On" if context .buildMaterialX else "Off" ),
25642583 buildMayapyTests = ("On" if context .buildMayapyTests else "Off" ),
25652584 buildAnimXTests = ("On" if context .buildAnimXTests else "Off" ),
2566- enableHDF5 = ("On" if context .enableHDF5 else "Off" ))
2585+ enableHDF5 = ("On" if context .enableHDF5 else "Off" ),
2586+ buildAppleFramework = ("On" if MacOS () and context .buildAppleFramework else "Off" ))
25672587
25682588Print (summaryMsg )
25692589
@@ -2625,8 +2645,9 @@ def FormatBuildArguments(buildArgs):
26252645 ])
26262646
26272647if MacOS ():
2628- if context .macOSCodesign :
2629- apple_utils .Codesign (context .usdInstDir , verbosity > 1 )
2648+ # We don't need to codesign when building a framework because it's handled during framework creation
2649+ if context .macOSCodesign and not context .buildAppleFramework :
2650+ apple_utils .Codesign (context , verbosity > 1 )
26302651
26312652printInstructions = any ([context .buildPython , context .buildTools , context .buildPrman ])
26322653if printInstructions :
@@ -2649,3 +2670,12 @@ def FormatBuildArguments(buildArgs):
26492670if context .buildPrman :
26502671 Print ("See documentation at http://openusd.org/docs/RenderMan-USD-Imaging-Plugin.html "
26512672 "for setting up the RenderMan plugin.\n " )
2673+
2674+ if context .buildAppleFramework :
2675+ Print ("""
2676+ Added the following framework to your Xcode Project, (recommended as Embed Without Signing):
2677+ OpenUSD.framework
2678+
2679+ Set the following compiler argument, to find the headers:
2680+ SYSTEM_HEADER_SEARCH_PATHS=$(SRCROOT)/$(TARGET_NAME)/OpenUSD.framework/Headers
2681+ """ )
0 commit comments