|
4 | 4 | # Licensed under the terms set forth in the LICENSE.txt file available at |
5 | 5 | # https://openusd.org/license. |
6 | 6 | # |
7 | | - |
8 | 7 | # Utilities for managing Apple OS build concerns. |
9 | 8 | # |
10 | 9 | # NOTE: This file and its contents may change significantly as we continue |
|
19 | 18 | import platform |
20 | 19 | import shlex |
21 | 20 | import subprocess |
| 21 | +import glob |
22 | 22 | from typing import Optional, List, Dict |
23 | 23 |
|
24 | 24 | TARGET_NATIVE = "native" |
@@ -278,40 +278,47 @@ def Codesign(install_path, identifier=None, force=False, verbose_output=False) - |
278 | 278 | if not MacOS(): |
279 | 279 | return False |
280 | 280 |
|
281 | | - codeSignID = identifier or GetCodeSignID() |
| 281 | + identifier = identifier or GetCodeSignID() |
282 | 282 |
|
283 | 283 | if verbose_output: |
284 | 284 | global devout |
285 | 285 | devout = sys.stdout |
286 | 286 | print(f"Code-signing files in {install_path} with {identifier}", file=devout) |
287 | 287 |
|
288 | 288 | try: |
289 | | - team_identifier = GetDevelopmentTeamID(codeSignID) |
| 289 | + team_identifier = GetDevelopmentTeamID(identifier) |
290 | 290 | except: |
| 291 | + if verbose_output: |
| 292 | + print("Could not get team_identifier") |
291 | 293 | team_identifier = None |
292 | 294 |
|
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 |
309 | 305 |
|
| 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')}") |
310 | 317 | for framework in frameworks: |
311 | 318 | framework_name = os.path.splitext(framework)[0] |
312 | 319 | if framework_name.lower() not in ["openusd", "opensubdiv", "materialx"]: |
313 | 320 | continue |
314 | | - path = os.path.join(root, framework) |
| 321 | + path = os.path.join(basePath, framework) |
315 | 322 | result = CodesignPath(path, identifier, team_identifier=team_identifier, force=force, is_framework=True) |
316 | 323 | if verbose_output: |
317 | 324 | if result: |
|
0 commit comments