Improve handling of patches during Chromium update (issue #2435)

This commit is contained in:
Marshall Greenblatt 2018-05-11 14:09:26 +03:00
parent 46e8152b6d
commit d1d4f7a3ef
3 changed files with 38 additions and 9 deletions

View File

@ -300,10 +300,12 @@ def apply_deps_patch():
raise Exception("Path does not exist: %s" % (deps_path))
def run_patch_updater(args):
def run_patch_updater(args=''):
""" Run the patch updater script. """
tool = os.path.join(cef_src_dir, 'tools', 'patch_updater.py')
run('%s %s %s' % (python_exe, tool, args), cef_src_dir, depot_tools_dir)
if len(args) > 0:
args = ' ' + args
run('%s %s%s' % (python_exe, tool, args), cef_src_dir, depot_tools_dir)
def onerror(func, path, exc_info):
@ -419,7 +421,7 @@ def get_chromium_compat_version():
def get_chromium_target_version(os='win', channel='canary', target_distance=0):
""" Returns the target Chromium version based on a heuristic. """
# The current compatible version from CEF.
compat_version = get_chromium_compat_version()
compat_version = chromium_compat_version
compat_commit = get_git_hash(chromium_src_dir, compat_version)
if compat_version == compat_commit:
versions = get_chromium_versions(compat_commit)
@ -1112,6 +1114,7 @@ if not options.nochromiumupdate and os.path.exists(chromium_src_dir):
run("%s fetch --tags" % (git_exe), chromium_src_dir, depot_tools_dir)
# Determine the Chromium checkout options required by CEF.
chromium_compat_version = get_chromium_compat_version()
if len(options.chromiumcheckout) > 0:
chromium_checkout = options.chromiumcheckout
elif len(options.chromiumchannel) > 0:
@ -1120,7 +1123,7 @@ elif len(options.chromiumchannel) > 0:
chromium_checkout = get_chromium_target_version(
channel=options.chromiumchannel, target_distance=target_distance)
else:
chromium_checkout = get_chromium_compat_version()
chromium_checkout = chromium_compat_version
# Determine if the Chromium checkout needs to change.
if not options.nochromiumupdate and os.path.exists(chromium_src_dir):
@ -1211,6 +1214,11 @@ elif not out_src_dir_exists:
# Write the config file for identifying the branch.
write_branch_config_file(out_src_dir, cef_branch)
if not options.fastupdate and chromium_checkout_changed and \
chromium_checkout != chromium_compat_version:
# Not using the known-compatible Chromium version. Try to update patch files.
run_patch_updater()
##
# Build CEF.
##

View File

@ -18,11 +18,16 @@ def msg(message):
sys.stdout.write('--> ' + message + "\n")
def linebreak():
""" Output a line break. """
sys.stdout.write('-' * 80 + "\n")
def warn(message):
""" Output a warning. """
sys.stdout.write('-' * 80 + "\n")
linebreak()
sys.stdout.write('!!!! WARNING: ' + message + "\n")
sys.stdout.write('-' * 80 + "\n")
linebreak()
def extract_paths(file):
@ -129,6 +134,8 @@ scope = {}
execfile(patch_cfg, scope)
patches = scope["patches"]
failed_patches = {}
# Read each individual patch file.
patches_dir = os.path.join(patch_dir, 'patches')
for patch in patches:
@ -193,8 +200,13 @@ for patch in patches:
raise Exception('Failed to apply patch file: %s' % result['err'])
sys.stdout.write(result['out'])
if result['out'].find('FAILED') != -1:
failed_lines = []
for line in result['out'].split('\n'):
if line.find('FAILED') != -1:
failed_lines.append(line.strip())
warn('Failed to apply %s, fix manually and run with --resave' % \
patch['name'])
failed_patches[patch['name']] = failed_lines
continue
if options.restore:
@ -235,3 +247,14 @@ for patch in patches:
f.close()
else:
raise Exception('Patch file does not exist: %s' % patch_file)
if len(failed_patches) > 0:
sys.stdout.write("\n")
linebreak()
sys.stdout.write("!!!! FAILED PATCHES, fix manually and run with --resave\n")
for name in sorted(failed_patches.keys()):
sys.stdout.write("%s:\n" % name)
for line in failed_patches[name]:
sys.stdout.write(" %s\n" % line)
linebreak()
sys.exit(1)

View File

@ -87,9 +87,7 @@ def apply_patch_config():
write_note('ERROR',
'%d patches failed to apply. Your build will not be correct.' %
results['fail'])
raise Exception(
'%d patches failed to apply. Your build will not be correct.' %
results['fail'])
sys.exit(1)
# Parse command-line options.