Skip to content

Commit ac4a4f1

Browse files
committed
Add iOS build support for USD Core
This PR adds **Core** iOS support to the OpenUSD project. This does not include Imaging, and any Imaging related components at this time. Imaging will be added in a follow up PR. MaterialX is also disabled as requested and the upgrade will be handled in a follow up PR. It is a minimal version of #2455 against the latest `dev` branch. Changes include: * Using latest dev branch * No imaging support. Will be added in a follow up PR. * Makes use of CMake's inbuilt iOS support, negating the need for toolchain support * Structures the code in such a way that we can add support for other iOS derived platforms+simulator in future PRs * Swaps `ARCH_OS_IOS` with `ARCH_OS_IPHONE` to align with compiler directives. IPHONE refers to all derivative platforms, whereas iOS refers to only iPhone/iPad (Confusing but the case for historical reasons as [documented here](https://chaosinmotion.com/2021/08/02/things-to-remember-compiler-conditionals-for-macos-ios-etc/)) * TBB requires SDKROOT to be passed in or it can often go off and find some random compiler toolchain and fail. * Add APPLE_EMBEDDED boolean to designate when using the CMake supported cross compilation targets. Added in Options.cmake so it can be used to configure defaults properly.
1 parent 1e08671 commit ac4a4f1

2 files changed

Lines changed: 57 additions & 18 deletions

File tree

build_scripts/apple_utils.py

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import shlex
2020
import subprocess
2121
from typing import Optional, List
22+
import re
23+
from typing import Optional, List
2224

2325
TARGET_NATIVE = "native"
2426
TARGET_X86 = "x86_64"
@@ -163,26 +165,63 @@ def ExtractFilesRecursive(path, cond):
163165
files.append(os.path.join(r, file))
164166
return files
165167

166-
def CodesignFiles(files):
167-
SDKVersion = subprocess.check_output(
168-
['xcodebuild', '-version']).strip()[6:10]
169-
codeSignIDs = subprocess.check_output(
170-
['security', 'find-identity', '-vp', 'codesigning'])
168+
def _GetCodeSignStringFromTerminal():
169+
codeSignIDs = GetCommandOutput(['security', 'find-identity', '-vp', 'codesigning'])
170+
return codeSignIDs
171171

172-
codeSignID = "-"
172+
def GetCodeSignID():
173173
if os.environ.get('CODE_SIGN_ID'):
174-
codeSignID = os.environ.get('CODE_SIGN_ID')
175-
elif float(SDKVersion) >= 11.0 and \
176-
codeSignIDs.find(b'Apple Development') != -1:
177-
codeSignID = "Apple Development"
178-
elif codeSignIDs.find(b'Mac Developer') != -1:
179-
codeSignID = "Mac Developer"
174+
return os.environ.get('CODE_SIGN_ID')
175+
176+
codeSignIDs = _GetCodeSignStringFromTerminal()
177+
if not codeSignIDs:
178+
return "-"
179+
for codeSignID in codeSignIDs.splitlines():
180+
if "CSSMERR_TP_CERT_REVOKED" in codeSignID:
181+
continue
182+
if ")" not in codeSignID:
183+
continue
184+
codeSignID = codeSignID.split()[1]
185+
break
186+
else:
187+
raise RuntimeError("Could not find a valid codesigning ID")
188+
189+
return codeSignID or "-"
190+
191+
def GetCodeSignIDHash():
192+
codeSignIDs = _GetCodeSignStringFromTerminal()
193+
try:
194+
return re.findall(r'\(.*?\)', codeSignIDs)[0][1:-1]
195+
except:
196+
raise Exception("Unable to parse codesign ID hash")
197+
198+
def GetDevelopmentTeamID():
199+
if os.environ.get("DEVELOPMENT_TEAM"):
200+
return os.environ.get("DEVELOPMENT_TEAM")
201+
codesignID = GetCodeSignIDHash()
202+
203+
certs = subprocess.check_output(["security", "find-certificate", "-c", codesignID, "-p"])
204+
subject = GetCommandOutput(["openssl", "x509", "-subject"], input=certs)
205+
subject = subject.splitlines()[0]
206+
207+
# Extract the Organizational Unit (OU field) from the cert
208+
try:
209+
team = [elm for elm in subject.split(
210+
'/') if elm.startswith('OU')][0].split('=')[1]
211+
if team is not None and team != "":
212+
return team
213+
except Exception as ex:
214+
raise Exception("No development team found with exception " + ex)
215+
216+
def CodesignFiles(files):
217+
codeSignID = GetCodeSignID()
180218

181219
for f in files:
182220
subprocess.call(['codesign', '-f', '-s', '{codesignid}'
183-
.format(codesignid=codeSignID), f],
221+
.format(codesignid=codeSignID), f],
184222
stdout=devout, stderr=devout)
185223

224+
186225
def Codesign(install_path, verbose_output=False):
187226
if not MacOS():
188227
return False

build_scripts/build_usd.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ def InstallBoost(context, force, buildArgs):
955955

956956
def InstallOneTBB(context, force, buildArgs):
957957
with CurrentWorkingDirectory(DownloadURL(ONETBB_URL, context, force)):
958-
RunCMake(context, force,
958+
RunCMake(context, force,
959959
['-DTBB_TEST=OFF',
960960
'-DTBB_STRICT=OFF'] + buildArgs)
961961

@@ -1326,12 +1326,12 @@ def InstallOpenImageIO(context, force, buildArgs):
13261326
'-DUSE_PYTHON=OFF',
13271327
'-DSTOP_ON_WARNING=OFF']
13281328

1329-
# OIIO's FindOpenEXR module circumvents CMake's normal library
1329+
# OIIO's FindOpenEXR module circumvents CMake's normal library
13301330
# search order, which causes versions of OpenEXR installed in
13311331
# /usr/local or other hard-coded locations in the module to
1332-
# take precedence over the version we've built, which would
1333-
# normally be picked up when we specify CMAKE_PREFIX_PATH.
1334-
# This may lead to undefined symbol errors at build or runtime.
1332+
# take precedence over the version we've built, which would
1333+
# normally be picked up when we specify CMAKE_PREFIX_PATH.
1334+
# This may lead to undefined symbol errors at build or runtime.
13351335
# So, we explicitly specify the OpenEXR we want to use here.
13361336
extraArgs.append('-DOPENEXR_ROOT="{instDir}"'
13371337
.format(instDir=context.instDir))

0 commit comments

Comments
 (0)