From 3924630cbc3a5d528b0e7ae1aabb4b55f4cfdf7b Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Thu, 5 Sep 2024 18:27:24 -0700 Subject: [PATCH] iOS,macOS: Add logging of duplicate codesign binaries (flutter/engine#54987) When duplicates are found in the input lists, log them to stderr. For the case of duplicates across list, we print the whole list, sorted, rather than three separate lists, as it makes it simpler to spot the duplicate, at which point the file will be easy to spot in either `create_ios_framework.py` or `create_macos_framework.py`. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- engine/src/flutter/sky/tools/sky_utils.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/sky/tools/sky_utils.py b/engine/src/flutter/sky/tools/sky_utils.py index 72ca3647d0..c79fb115f9 100644 --- a/engine/src/flutter/sky/tools/sky_utils.py +++ b/engine/src/flutter/sky/tools/sky_utils.py @@ -33,18 +33,25 @@ def assert_valid_codesign_config( either entitlements or without_entitlements.""" if _contains_duplicates(entitlements): log_error('ERROR: duplicate value(s) found in entitlements.txt') + log_error_items(sorted(entitlements)) sys.exit(os.EX_DATAERR) if _contains_duplicates(without_entitlements): log_error('ERROR: duplicate value(s) found in without_entitlements.txt') + log_error_items(sorted(without_entitlements)) sys.exit(os.EX_DATAERR) if _contains_duplicates(unsigned_binaries): log_error('ERROR: duplicate value(s) found in unsigned_binaries.txt') + log_error_items(sorted(unsigned_binaries)) sys.exit(os.EX_DATAERR) if _contains_duplicates(entitlements + without_entitlements + unsigned_binaries): - log_error('ERROR: value(s) found in both entitlements and without_entitlements.txt') + log_error( + 'ERROR: duplicate value(s) found between ' + 'entitlements.txt, without_entitlements.txt, unsigned_binaries.txt' + ) + log_error_items(sorted(entitlements + without_entitlements + unsigned_binaries)) sys.exit(os.EX_DATAERR) binaries = set() @@ -254,6 +261,12 @@ def log_error(message): print(message, file=sys.stderr) +def log_error_items(items): + """Writes each item indented to stderr, followed by a newline.""" + for item in items: + log_error(' ' + item) + + def strip_binary(binary_path, unstripped_copy_path): """Makes a copy of an unstripped binary, then strips symbols from the binary.""" assert_file(binary_path, 'binary to strip')