Bug 1704628 Part 1: Make selectContextMenuItem use .activateItem() semantics. r=ochameau
[gecko.git] / media / libvpx / update.py
blob8e0b93878116f665bca2d41c53b39d8bef1ed2d5
1 #!/usr/bin/env python
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 import argparse
6 import os
7 import re
8 import shutil
9 import sys
10 import subprocess
11 import tarfile
12 import urllib.request
13 from pprint import pprint
14 from io import StringIO
16 def prepare_upstream(prefix, commit=None):
17 upstream_url = 'https://chromium.googlesource.com/webm/libvpx'
18 shutil.rmtree(os.path.join(base, 'libvpx/'))
19 print(upstream_url + '/+archive/' + commit + '.tar.gz')
20 urllib.request.urlretrieve(upstream_url + '/+archive/' + commit + '.tar.gz', 'libvpx.tar.gz')
21 tarfile.open('libvpx.tar.gz').extractall(path='libvpx')
22 os.remove(os.path.join(base, 'libvpx.tar.gz'))
23 os.chdir(base)
24 return commit
26 def cleanup_upstream():
27 os.remove(os.path.join(base, 'libvpx', '.gitattributes'))
28 os.remove(os.path.join(base, 'libvpx', '.gitignore'))
29 shutil.rmtree(os.path.join(base, 'libvpx', 'third_party', 'libwebm'))
30 shutil.rmtree(os.path.join(base, 'libvpx', 'tools'))
32 def apply_patches():
33 # Patch to fix a crash caused by MSVC 2013
34 os.system("patch -p3 < bug1137614.patch")
35 # Bug 1263384 - Check input frame resolution
36 os.system("patch -p3 < input_frame_validation.patch")
37 # Bug 1315288 - Check input frame resolution for vp9
38 os.system("patch -p3 < input_frame_validation_vp9.patch")
39 # Avoid c/asm name collision for loopfilter_sse2
40 os.system("patch -p3 < rename_duplicate_files.patch")
41 os.system("mv libvpx/vpx_dsp/x86/loopfilter_sse2.c libvpx/vpx_dsp/x86/loopfilter_intrin_sse2.c")
42 # Ensure float_control_word.asm is included
43 os.system("patch -p3 < win64_build_fix.patch")
45 def update_readme(commit):
46 with open('README_MOZILLA') as f:
47 readme = f.read()
49 if 'The git commit ID used was' in readme:
50 new_readme = re.sub('The git commit ID used was [v\.a-f0-9]+',
51 'The git commit ID used was %s' % commit, readme)
52 else:
53 new_readme = "%s\n\nThe git commit ID used was %s\n" % (readme, commit)
55 if readme != new_readme:
56 with open('README_MOZILLA', 'w') as f:
57 f.write(new_readme)
59 if __name__ == '__main__':
60 parser = argparse.ArgumentParser(description='''Update libvpx''')
61 parser.add_argument('--debug', dest='debug', action="store_true")
62 parser.add_argument('--commit', dest='commit', type=str, default='master')
64 args = parser.parse_args()
66 commit = args.commit
67 DEBUG = args.debug
69 base = os.path.abspath(os.curdir)
70 prefix = os.path.join(base, 'libvpx/')
72 commit = prepare_upstream(prefix, commit)
74 apply_patches()
75 update_readme(commit)
77 cleanup_upstream()