From 5034749463a67a8689cffecdebd6aa0ca02b4953 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Tue, 26 Jul 2022 10:09:01 -0700 Subject: [PATCH] patcher: Skip missing platform-specific third-party directories --- tools/patch_updater.py | 8 ++++++++ tools/patcher.py | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/patch_updater.py b/tools/patch_updater.py index b636c3d91..b7e64ba89 100644 --- a/tools/patch_updater.py +++ b/tools/patch_updater.py @@ -166,6 +166,14 @@ for patch in patches: msg('Reading patch file %s' % patch_file) if 'path' in patch: patch_root_abs = os.path.abspath(os.path.join(src_dir, patch['path'])) + if not os.path.isdir(patch_root_abs): + line = 'Target directory does not exist: %s' % patch_root_abs + msg(line) + if options.resave: + # Report as a fatal error for manual resave only, as the missing + # directory may be platform-specific. + failed_patches[patch['name']] = [line] + continue else: patch_root_abs = src_dir diff --git a/tools/patcher.py b/tools/patcher.py index 4d7ed34d8..023e91d4b 100644 --- a/tools/patcher.py +++ b/tools/patcher.py @@ -30,7 +30,8 @@ def write_note(type, note): def apply_patch_file(patch_file, patch_dir): ''' Apply a specific patch file in optional patch directory. ''' - patch_path = os.path.join(cef_patch_dir, 'patches', patch_file + '.patch') + patch_name = patch_file + '.patch' + patch_path = os.path.join(cef_patch_dir, 'patches', patch_name) if patch_dir is None or len(patch_dir) == 0: patch_dir = src_dir @@ -39,6 +40,10 @@ def apply_patch_file(patch_file, patch_dir): # Apply patch relative to the Chromium 'src' directory. patch_dir = os.path.join(src_dir, patch_dir) patch_dir = os.path.abspath(patch_dir) + if not os.path.isdir(patch_dir): + sys.stdout.write('\nApply %s in %s\n' % (patch_name, patch_dir)) + sys.stdout.write('... target directory does not exist (skipping).\n') + return 'skip' result = git_apply_patch_file(patch_path, patch_dir) if result == 'fail':