Skip to content

Commit 4e57c2d

Browse files
committed
Integrate suggestions from Sunya
1 parent d857716 commit 4e57c2d

1 file changed

Lines changed: 27 additions & 20 deletions

File tree

build_scripts/apple_utils.py

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# Licensed under the terms set forth in the LICENSE.txt file available at
55
# https://openusd.org/license.
66
#
7-
87
# Utilities for managing Apple OS build concerns.
98
#
109
# NOTE: This file and its contents may change significantly as we continue
@@ -19,6 +18,7 @@
1918
import platform
2019
import shlex
2120
import subprocess
21+
import glob
2222
from typing import Optional, List, Dict
2323

2424
TARGET_NATIVE = "native"
@@ -278,40 +278,47 @@ def Codesign(install_path, identifier=None, force=False, verbose_output=False) -
278278
if not MacOS():
279279
return False
280280

281-
codeSignID = identifier or GetCodeSignID()
281+
identifier = identifier or GetCodeSignID()
282282

283283
if verbose_output:
284284
global devout
285285
devout = sys.stdout
286286
print(f"Code-signing files in {install_path} with {identifier}", file=devout)
287287

288288
try:
289-
team_identifier = GetDevelopmentTeamID(codeSignID)
289+
team_identifier = GetDevelopmentTeamID(identifier)
290290
except:
291+
if verbose_output:
292+
print("Could not get team_identifier")
291293
team_identifier = None
292294

293-
for root, dirs, files in os.walk(install_path, topdown=True):
294-
for f in files:
295-
296-
_, ext = os.path.splitext(f)
297-
if ext in (".dylib", ".so"):
298-
path = os.path.join(root, f)
299-
result = CodesignPath(path, identifier, team_identifier=team_identifier, force=force, is_framework=False)
300-
if verbose_output:
301-
if result:
302-
print(f"Code-signed binary: {path}")
303-
else:
304-
print(f"Did not code-sign binary: {path}")
305-
306-
# Bit annoying to have to do this twice, but seems the fastest way to skip traversing frameworks
307-
frameworks = [d for d in dirs if d.endswith(".framework")]
308-
dirs[:] = [d for d in dirs if not d.endswith(".framework")]
295+
codesignPaths = [
296+
os.path.join(install_path, 'lib'),
297+
os.path.join(install_path, 'plugin'),
298+
os.path.join(install_path, 'share/usd'),
299+
os.path.join(install_path, "frameworks")
300+
]
301+
302+
for basePath in codesignPaths:
303+
if not os.path.exists(basePath):
304+
continue
309305

306+
shared_libs = glob.glob(f"{os.path.join(basePath, '*.dylib')}")
307+
shared_libs += glob.glob(f"{os.path.join(basePath, '*.so')}")
308+
for path in shared_libs:
309+
result = CodesignPath(path, identifier, team_identifier=team_identifier, force=force, is_framework=False)
310+
if verbose_output:
311+
if result:
312+
print(f"Code-signed binary: {path}")
313+
else:
314+
print(f"Did not code-sign binary: {path}")
315+
316+
frameworks = glob.glob(f"{os.path.join(basePath, '*.framework')}")
310317
for framework in frameworks:
311318
framework_name = os.path.splitext(framework)[0]
312319
if framework_name.lower() not in ["openusd", "opensubdiv", "materialx"]:
313320
continue
314-
path = os.path.join(root, framework)
321+
path = os.path.join(basePath, framework)
315322
result = CodesignPath(path, identifier, team_identifier=team_identifier, force=force, is_framework=True)
316323
if verbose_output:
317324
if result:

0 commit comments

Comments
 (0)