From 5145be6b183e0102a9693dfc843df889c0ce4d85 Mon Sep 17 00:00:00 2001 From: Emerick Rogul Date: Wed, 23 Jul 2025 16:07:40 -0400 Subject: [PATCH] [cr140] Fix `stub_out_signing_in_upstream` to address signing failure on Mac Signing with `--skip_signing` stopped working on Mac due to the following upstream commit. This happened because we override the behavior of `run_command` to scrub signing-related commands/arguments from the command-line when `--skip_signing` is passed. However, this upstream commit added a new async function named `run_command_all_output_async` which also needs to be scrubbed. Chromium change: https://source.chromium.org/chromium/chromium/src/+/8062ee35c902563309983726a37b90d5ca10caed commit 8062ee35c902563309983726a37b90d5ca10caed Author: Joshua Pawlicki Date: Tue Jul 15 10:45:21 2025 -0700 mac signing: Parallelize some per-distribution operations. This may speed up the per-distribution section of signing by up to 45%. codesign --verify and spctl --assess will now run in parallel. This is expected to provide a speed-up up to 20% depending on I/O throughput. The app bundle needs to be zipped prior to notarization. Previously, the execution would wait for zipping to be complete and then start notarization in the background (while continuing in parallel with processing the next distribution). Now, the zipping is also done in the background while execution moves on to the next distribution. This could provide a speed-up of up to 25% depending on I/O vs CPU bottlenecks. Bug: 426019706 Change-Id: I0a054c43c2b51f56abd0a94e78a9caf337a2a216 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6699494 Commit-Queue: Mark Mentovai Reviewed-by: Mark Mentovai Commit-Queue: Joshua Pawlicki Cr-Commit-Position: refs/heads/main@{#1487061} --- build/mac/signing/internal_invoker.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/build/mac/signing/internal_invoker.py b/build/mac/signing/internal_invoker.py index b708f1a2834..ecf9f7ed0af 100644 --- a/build/mac/signing/internal_invoker.py +++ b/build/mac/signing/internal_invoker.py @@ -31,21 +31,34 @@ class Invoker(standard_invoker.Invoker): def stub_out_signing_in_upstream(): run_command_orig = commands.run_command + run_command_all_output_async_orig = commands.run_command_all_output_async - def run_command(args, **kwargs): + def scrub_signing_args(args): if args[0] == 'codesign': # Even non-signing commands such as `codesign --verify` or # `codesign --display` fail when signing is skipped. So don't invoke # codesign at all: - return + return None # Indicates the command should not be run if args[0] == 'productbuild': try: sign_index = args.index('--sign') + # Remove '--sign' and the following argument + del args[sign_index:sign_index + 2] except ValueError: pass - else: - for _ in range(2): - args.pop(sign_index) - run_command_orig(args, **kwargs) + return args + + def run_command(args, **kwargs): + scrubbed = scrub_signing_args(args.copy()) + if scrubbed is not None: + return run_command_orig(scrubbed, **kwargs) + return None + + async def run_command_all_output_async(args, **kwargs): + scrubbed = scrub_signing_args(args.copy()) + if scrubbed is not None: + return await run_command_all_output_async_orig(scrubbed, **kwargs) + return ('%s' % args, 0, '', '') commands.run_command = run_command + commands.run_command_all_output_async = run_command_all_output_async