Add a mechanism for patching Chromium
Any *.patch files added to the (not-yet-extant) patches/ directory will be applied before we build. If patches fail to apply, we'll revert all changes and try again. Reverting will delete our copied gyp files, so we have to make sure to copy them *after* applying patches.
This commit is contained in:
Родитель
8513c9e227
Коммит
764277dc66
|
@ -0,0 +1,3 @@
|
|||
[submodule "vendor/python-patch"]
|
||||
path = vendor/python-patch
|
||||
url = https://github.com/svn2github/python-patch
|
|
@ -0,0 +1,48 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import glob
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
PATCHES_DIR = os.path.join(SOURCE_ROOT, 'patches')
|
||||
VENDOR_DIR = os.path.join(SOURCE_ROOT, 'vendor')
|
||||
DEPOT_TOOLS_DIR = os.path.join(VENDOR_DIR, 'depot_tools')
|
||||
CHROMIUM_DIR = os.path.join(VENDOR_DIR, 'chromium')
|
||||
SRC_DIR = os.path.join(CHROMIUM_DIR, 'src')
|
||||
PATCH_PY = os.path.join(VENDOR_DIR, 'python-patch', 'patch.py')
|
||||
|
||||
|
||||
def main():
|
||||
if apply_patches():
|
||||
return
|
||||
sys.stderr.write('Patches failed to apply. '
|
||||
'Reverting changes and trying again.\n')
|
||||
sys.stderr.flush()
|
||||
revert_changes()
|
||||
apply_patches()
|
||||
|
||||
|
||||
def apply_patches():
|
||||
args = [sys.executable, PATCH_PY, '--directory', SRC_DIR, '--quiet']
|
||||
for patch in glob.glob(os.path.join(PATCHES_DIR, '*.patch')):
|
||||
retcode = subprocess.call(args + [patch])
|
||||
if retcode:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def revert_changes():
|
||||
gclient = os.path.join(DEPOT_TOOLS_DIR, 'gclient.py')
|
||||
cwd = os.getcwd()
|
||||
os.chdir(CHROMIUM_DIR)
|
||||
try:
|
||||
subprocess.check_call([sys.executable, gclient, 'revert'])
|
||||
finally:
|
||||
os.chdir(cwd)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
|
@ -18,6 +18,7 @@ def main():
|
|||
gclient_sync()
|
||||
install_win_toolchain()
|
||||
import_win_environment()
|
||||
apply_patches()
|
||||
copy_gyp_files()
|
||||
run_gyp()
|
||||
|
||||
|
@ -85,6 +86,14 @@ def copy_gyp_files():
|
|||
os.path.join(CHROMIUMCONTENT_DIR, 'chromiumcontent.gyp'))
|
||||
|
||||
|
||||
def apply_patches():
|
||||
# Applying patches can invoke gclient, which in turn can invoke gyp, so make
|
||||
# sure we have our gyp environment set.
|
||||
ensure_nacl_disabled()
|
||||
|
||||
subprocess.check_call([sys.executable, os.path.join(SOURCE_ROOT, 'script', 'apply-patches')])
|
||||
|
||||
|
||||
def run_gyp():
|
||||
ensure_nacl_disabled()
|
||||
os.environ['GYP_GENERATORS'] = 'ninja'
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit aeb08758d1a170dbb408310b53e0a43e0b2ebcc9
|
Загрузка…
Ссылка в новой задаче