media/libvpx/update.py

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rwxr-xr-x

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 #!/usr/bin/env python
michael@0 2 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 5 import argparse
michael@0 6 import os
michael@0 7 import re
michael@0 8 import shutil
michael@0 9 import sys
michael@0 10 import subprocess
michael@0 11 from pprint import pprint
michael@0 12 from StringIO import StringIO
michael@0 13
michael@0 14 PLATFORMS= [
michael@0 15 'x86-win32-vs8',
michael@0 16 'x86_64-win64-vs8',
michael@0 17 'x86-linux-gcc',
michael@0 18 'x86_64-linux-gcc',
michael@0 19 'generic-gnu',
michael@0 20 'x86-darwin9-gcc',
michael@0 21 'x86_64-darwin9-gcc',
michael@0 22 'armv7-android-gcc',
michael@0 23 'x86-win32-gcc',
michael@0 24 'x86_64-win64-gcc',
michael@0 25 ]
michael@0 26
michael@0 27
michael@0 28 mk_files = [
michael@0 29 'vp8/vp8_common.mk',
michael@0 30 'vp8/vp8cx_arm.mk',
michael@0 31 'vp8/vp8cx.mk',
michael@0 32 'vp8/vp8dx.mk',
michael@0 33 'vp9/vp9_common.mk',
michael@0 34 'vp9/vp9cx.mk',
michael@0 35 'vp9/vp9dx.mk',
michael@0 36 'vpx_mem/vpx_mem.mk',
michael@0 37 'vpx_ports/vpx_ports.mk',
michael@0 38 'vpx_scale/vpx_scale.mk',
michael@0 39 'vpx/vpx_codec.mk',
michael@0 40 ]
michael@0 41
michael@0 42 extensions = ['.asm', '.c', '.h']
michael@0 43
michael@0 44 MODULES = {
michael@0 45 'UNIFIED_SOURCES': [
michael@0 46 'API_DOC_SRCS-$(CONFIG_VP8_DECODER)',
michael@0 47 'API_DOC_SRCS-yes',
michael@0 48 'API_EXPORTS',
michael@0 49 'API_SRCS-$(CONFIG_VP8_DECODER)',
michael@0 50 'API_SRCS-yes',
michael@0 51 'MEM_SRCS-yes',
michael@0 52 'PORTS_SRCS-yes',
michael@0 53 'SCALE_SRCS-$(CONFIG_SPATIAL_RESAMPLING)',
michael@0 54 'SCALE_SRCS-no',
michael@0 55 'SCALE_SRCS-yes',
michael@0 56 'VP8_COMMON_SRCS-yes',
michael@0 57 'VP8_DX_EXPORTS',
michael@0 58 'VP8_DX_SRCS-$(CONFIG_MULTITHREAD)',
michael@0 59 'VP8_DX_SRCS-no',
michael@0 60 'VP8_DX_SRCS_REMOVE-no',
michael@0 61 'VP8_DX_SRCS_REMOVE-yes',
michael@0 62 'VP8_DX_SRCS-yes',
michael@0 63 'VP9_COMMON_SRCS-yes',
michael@0 64 'VP9_DX_EXPORTS',
michael@0 65 'VP9_DX_SRCS-no',
michael@0 66 'VP9_DX_SRCS_REMOVE-no',
michael@0 67 'VP9_DX_SRCS_REMOVE-yes',
michael@0 68 'VP9_DX_SRCS-yes',
michael@0 69 'API_DOC_SRCS-$(CONFIG_VP8_ENCODER)',
michael@0 70 'API_SRCS-$(BUILD_LIBVPX)',
michael@0 71 'API_SRCS-$(CONFIG_VP8_ENCODER)',
michael@0 72 'API_SRCS-$(CONFIG_VP9_ENCODER)',
michael@0 73 'VP8_CX_EXPORTS',
michael@0 74 'VP8_CX_SRCS-$(CONFIG_MULTI_RES_ENCODING)',
michael@0 75 'VP8_CX_SRCS-$(CONFIG_MULTITHREAD)',
michael@0 76 'VP8_CX_SRCS-$(CONFIG_TEMPORAL_DENOISING)',
michael@0 77 'VP8_CX_SRCS-no',
michael@0 78 'VP8_CX_SRCS_REMOVE-no',
michael@0 79 'VP8_CX_SRCS_REMOVE-yes',
michael@0 80 'VP8_CX_SRCS-yes',
michael@0 81 'VP9_CX_EXPORTS',
michael@0 82 'VP9_CX_SRCS-no',
michael@0 83 'VP9_CX_SRCS_REMOVE-no',
michael@0 84 'VP9_CX_SRCS_REMOVE-yes',
michael@0 85 'VP9_CX_SRCS-yes',
michael@0 86 ],
michael@0 87 'X86_ASM': [
michael@0 88 'PORTS_SRCS-$(BUILD_LIBVPX)',
michael@0 89 'VP8_COMMON_SRCS-$(ARCH_X86)$(ARCH_X86_64)',
michael@0 90 'VP8_COMMON_SRCS-$(HAVE_MMX)',
michael@0 91 'VP8_COMMON_SRCS-$(HAVE_SSE2)',
michael@0 92 'VP8_COMMON_SRCS-$(HAVE_SSE3)',
michael@0 93 'VP8_COMMON_SRCS-$(HAVE_SSE4_1)',
michael@0 94 'VP8_COMMON_SRCS-$(HAVE_SSSE3)',
michael@0 95 'VP9_COMMON_SRCS-$(ARCH_X86)$(ARCH_X86_64)',
michael@0 96 'VP9_COMMON_SRCS-$(HAVE_MMX)',
michael@0 97 'VP9_COMMON_SRCS-$(HAVE_SSE2)',
michael@0 98 'VP9_COMMON_SRCS-$(HAVE_SSSE3)',
michael@0 99 'VP8_CX_SRCS-$(ARCH_X86)$(ARCH_X86_64)',
michael@0 100 'VP8_CX_SRCS-$(HAVE_MMX)',
michael@0 101 'VP8_CX_SRCS-$(HAVE_SSE2)',
michael@0 102 'VP8_CX_SRCS-$(HAVE_SSE4_1)',
michael@0 103 'VP8_CX_SRCS-$(HAVE_SSSE3)',
michael@0 104 'VP8_CX_SRCS_REMOVE-$(HAVE_SSE2)',
michael@0 105 'VP9_CX_SRCS-$(ARCH_X86)$(ARCH_X86_64)',
michael@0 106 'VP9_CX_SRCS-$(HAVE_MMX)',
michael@0 107 'VP9_CX_SRCS-$(HAVE_SSE2)',
michael@0 108 'VP9_CX_SRCS-$(HAVE_SSE3)',
michael@0 109 'VP9_CX_SRCS-$(HAVE_SSE4_1)',
michael@0 110 'VP9_CX_SRCS-$(HAVE_SSSE3)',
michael@0 111 ],
michael@0 112 'X86-64_ASM': [
michael@0 113 'VP8_CX_SRCS-$(ARCH_X86_64)',
michael@0 114 'VP9_CX_SRCS-$(ARCH_X86_64)',
michael@0 115 ],
michael@0 116 'ARM_ASM': [
michael@0 117 'PORTS_SRCS-$(ARCH_ARM)',
michael@0 118 'SCALE_SRCS-$(HAVE_NEON)',
michael@0 119 'VP8_COMMON_SRCS-$(ARCH_ARM)',
michael@0 120 'VP8_COMMON_SRCS-$(HAVE_MEDIA)',
michael@0 121 'VP8_COMMON_SRCS-$(HAVE_NEON)',
michael@0 122 'VP9_COMMON_SRCS-$(HAVE_NEON)',
michael@0 123 'VP8_CX_SRCS-$(ARCH_ARM)',
michael@0 124 'VP8_CX_SRCS-$(HAVE_EDSP)',
michael@0 125 'VP8_CX_SRCS-$(HAVE_MEDIA)',
michael@0 126 'VP8_CX_SRCS-$(HAVE_NEON)',
michael@0 127 ],
michael@0 128 'ERROR_CONCEALMENT': [
michael@0 129 'VP8_DX_SRCS-$(CONFIG_ERROR_CONCEALMENT)',
michael@0 130 ],
michael@0 131 'AVX2': [
michael@0 132 'VP9_COMMON_SRCS-$(HAVE_AVX2)',
michael@0 133 ],
michael@0 134 'VP8_POSTPROC': [
michael@0 135 'VP8_COMMON_SRCS-$(CONFIG_POSTPROC)',
michael@0 136 ],
michael@0 137 'VP9_POSTPROC': [
michael@0 138 'VP9_COMMON_SRCS-$(CONFIG_VP9_POSTPROC)',
michael@0 139 ]
michael@0 140 }
michael@0 141
michael@0 142 DISABLED_MODULES = [
michael@0 143 'MEM_SRCS-$(CONFIG_MEM_MANAGER)',
michael@0 144 'MEM_SRCS-$(CONFIG_MEM_TRACKER)',
michael@0 145 'VP8_COMMON_SRCS-$(CONFIG_POSTPROC_VISUALIZER)',
michael@0 146 'VP9_COMMON_SRCS-$(CONFIG_POSTPROC_VISUALIZER)',
michael@0 147 'VP8_CX_SRCS-$(CONFIG_INTERNAL_STATS)',
michael@0 148 'VP9_CX_SRCS-$(CONFIG_INTERNAL_STATS)',
michael@0 149
michael@0 150 # mips files are also ignored via ignored_folders
michael@0 151 'SCALE_SRCS-$(HAVE_DSPR2)',
michael@0 152 'VP8_COMMON_SRCS-$(HAVE_DSPR2)',
michael@0 153 'VP9_COMMON_SRCS-$(HAVE_DSPR2)',
michael@0 154 'VP8_CX_SRCS_REMOVE-$(HAVE_EDSP)',
michael@0 155 ]
michael@0 156
michael@0 157 libvpx_files = [
michael@0 158 'build/make/obj_int_extract.c',
michael@0 159 'build/make/ads2gas.pl',
michael@0 160 'build/make/thumb.pm',
michael@0 161 'LICENSE',
michael@0 162 'PATENTS',
michael@0 163 ]
michael@0 164
michael@0 165 ignore_files = [
michael@0 166 'vp8/common/context.c',
michael@0 167 'vp8/common/textblit.c',
michael@0 168 'vp8/encoder/ssim.c',
michael@0 169 'vp8/encoder/x86/ssim_opt.asm',
michael@0 170 'vp9/common/vp9_textblit.c',
michael@0 171 'vp9/common/vp9_textblit.h',
michael@0 172 'vp9/encoder/vp9_ssim.c',
michael@0 173 'vp9/encoder/x86/vp9_ssim_opt.asm',
michael@0 174 'vpx_mem/vpx_mem_tracker.c',
michael@0 175 'vpx_scale/generic/bicubic_scaler.c',
michael@0 176 'vpx_scale/win32/scaleopt.c',
michael@0 177 'vpx_scale/win32/scalesystemdependent.c',
michael@0 178 ]
michael@0 179
michael@0 180 ignore_folders = [
michael@0 181 'examples/',
michael@0 182 'googletest/',
michael@0 183 'libmkv/',
michael@0 184 'libyuv/',
michael@0 185 'mips/',
michael@0 186 'nestegg/',
michael@0 187 'objdir/',
michael@0 188 'ppc/',
michael@0 189 'test/',
michael@0 190 'vpx_mem/memory_manager/',
michael@0 191 ]
michael@0 192 files = {
michael@0 193 'EXPORTS': [
michael@0 194 'vpx_mem/include/vpx_mem_intrnl.h',
michael@0 195 'vpx_mem/vpx_mem.h',
michael@0 196 'vpx_ports/arm.h',
michael@0 197 'vpx_ports/mem.h',
michael@0 198 'vpx_ports/vpx_timer.h',
michael@0 199 'vpx_ports/x86.h',
michael@0 200 'vpx_scale/vpx_scale.h',
michael@0 201 'vpx_scale/yv12config.h',
michael@0 202 'vpx/vp8cx.h',
michael@0 203 'vpx/vp8dx.h',
michael@0 204 'vpx/vp8.h',
michael@0 205 'vpx/vpx_codec.h',
michael@0 206 'vpx/vpx_decoder.h',
michael@0 207 'vpx/vpx_encoder.h',
michael@0 208 'vpx/vpx_image.h',
michael@0 209 'vpx/vpx_integer.h',
michael@0 210 ],
michael@0 211 'X86-64_ASM': [
michael@0 212 'third_party/x86inc/x86inc.asm',
michael@0 213 'vp8/common/x86/loopfilter_block_sse2.asm',
michael@0 214 'vp9/encoder/x86/vp9_quantize_ssse3.asm',
michael@0 215 ],
michael@0 216 'SOURCES': [
michael@0 217 'vp8/common/rtcd.c',
michael@0 218 'vp8/common/sad_c.c',
michael@0 219 'vp8/vp8_dx_iface.c',
michael@0 220 'vp9/common/vp9_entropymv.c',
michael@0 221 'vp9/common/vp9_rtcd.c',
michael@0 222 'vp9/encoder/vp9_bitstream.c',
michael@0 223 'vpx/src/svc_encodeframe.c',
michael@0 224 'vpx_mem/vpx_mem.c',
michael@0 225 ]
michael@0 226 }
michael@0 227
michael@0 228 manual = [
michael@0 229 # special case in moz.build
michael@0 230 'vp8/encoder/boolhuff.c',
michael@0 231
michael@0 232 # 64bit only
michael@0 233 'vp8/common/x86/loopfilter_block_sse2.asm',
michael@0 234 'vp9/encoder/x86/vp9_quantize_ssse3.asm',
michael@0 235
michael@0 236 # offsets are special cased in Makefile.in
michael@0 237 'vp8/encoder/vp8_asm_enc_offsets.c',
michael@0 238 'vpx_scale/vpx_scale_asm_offsets.c',
michael@0 239
michael@0 240 # ignore while vp9 postproc is not enabled
michael@0 241 'vp9/common/x86/vp9_postproc_mmx.asm',
michael@0 242 'vp9/common/x86/vp9_postproc_sse2.asm',
michael@0 243
michael@0 244 # ssim_opt is not enabled
michael@0 245 'vp8/encoder/x86/ssim_opt.asm',
michael@0 246 'vp9/encoder/x86/vp9_ssim_opt.asm',
michael@0 247
michael@0 248 # asm includes
michael@0 249 'vpx_ports/x86_abi_support.asm',
michael@0 250 ]
michael@0 251
michael@0 252 platform_files = [
michael@0 253 'vp8_rtcd.h',
michael@0 254 'vp9_rtcd.h',
michael@0 255 'vpx_config.asm',
michael@0 256 'vpx_config.h',
michael@0 257 'vpx_scale_rtcd.h',
michael@0 258 ]
michael@0 259
michael@0 260 def prepare_upstream(prefix, commit=None):
michael@0 261 if os.path.exists(prefix):
michael@0 262 print "Please remove '%s' folder before running %s" % (prefix, sys.argv[0])
michael@0 263 sys.exit(1)
michael@0 264
michael@0 265 upstream_url = 'https://gerrit.chromium.org/gerrit/webm/libvpx'
michael@0 266 subprocess.call(['git', 'clone', upstream_url, prefix])
michael@0 267 if commit:
michael@0 268 os.chdir(prefix)
michael@0 269 subprocess.call(['git', 'checkout', commit])
michael@0 270 else:
michael@0 271 os.chdir(prefix)
michael@0 272 p = subprocess.Popen(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE)
michael@0 273 stdout, stderr = p.communicate()
michael@0 274 commit = stdout.strip()
michael@0 275
michael@0 276 for target in PLATFORMS:
michael@0 277 target_objdir = os.path.join(prefix, 'objdir', target)
michael@0 278 os.makedirs(target_objdir)
michael@0 279 os.chdir(target_objdir)
michael@0 280 configure = ['../../configure', '--target=%s' % target,
michael@0 281 '--disable-examples', '--disable-install-docs',
michael@0 282 '--enable-multi-res-encoding',
michael@0 283 ]
michael@0 284
michael@0 285 if 'darwin9' in target:
michael@0 286 configure += ['--enable-pic']
michael@0 287 if 'linux' in target:
michael@0 288 configure += ['--enable-pic']
michael@0 289 # x86inc.asm is not compatible with pic 32bit builds
michael@0 290 if target == 'x86-linux-gcc':
michael@0 291 configure += ['--disable-use-x86inc']
michael@0 292
michael@0 293 if target == 'armv7-android-gcc':
michael@0 294 configure += ['--sdk-path=%s' % ndk_path]
michael@0 295
michael@0 296 subprocess.call(configure)
michael@0 297 make_targets = [f for f in platform_files if not os.path.exists(f)]
michael@0 298 if make_targets:
michael@0 299 subprocess.call(['make'] + make_targets)
michael@0 300 for f in make_targets:
michael@0 301 if not os.path.exists(f):
michael@0 302 print "%s missing from %s, check toolchain" % (f, target)
michael@0 303 sys.exit(1)
michael@0 304
michael@0 305 os.chdir(base)
michael@0 306 return commit
michael@0 307
michael@0 308 def cleanup_upstream():
michael@0 309 shutil.rmtree(os.path.join(base, 'upstream'))
michael@0 310
michael@0 311 def get_module(key):
michael@0 312 for module in MODULES:
michael@0 313 if key in MODULES[module]:
michael@0 314 return module
michael@0 315
michael@0 316 def get_libvpx_files(prefix):
michael@0 317 for root, folders, files in os.walk(prefix):
michael@0 318 for f in files:
michael@0 319 f = os.path.join(root, f)[len(prefix):]
michael@0 320 if os.path.splitext(f)[-1] in extensions \
michael@0 321 and os.sep in f \
michael@0 322 and f not in ignore_files \
michael@0 323 and not any(folder in f for folder in ignore_folders):
michael@0 324 libvpx_files.append(f)
michael@0 325 return libvpx_files
michael@0 326
michael@0 327 def get_sources(prefix):
michael@0 328 source = {}
michael@0 329 unknown = {}
michael@0 330 disabled = {}
michael@0 331
michael@0 332 for mk in mk_files:
michael@0 333 with open(os.path.join(prefix, mk)) as f:
michael@0 334 base = os.path.dirname(mk)
michael@0 335 for l in f:
michael@0 336 if '+=' in l:
michael@0 337 l = l.split('+=')
michael@0 338 key = l[0].strip()
michael@0 339 value = l[1].strip().replace('$(ASM)', '.asm')
michael@0 340 value = os.path.join(base, value)
michael@0 341 if not key.startswith('#') and os.path.splitext(value)[-1] in extensions:
michael@0 342 if key not in source:
michael@0 343 source[key] = []
michael@0 344 source[key].append(value)
michael@0 345
michael@0 346 for key in source:
michael@0 347 for f in source[key]:
michael@0 348 if key.endswith('EXPORTS') and f.endswith('.h'):
michael@0 349 files['EXPORTS'].append(f)
michael@0 350 if os.path.splitext(f)[-1] in ('.c', '.asm') and not f in manual:
michael@0 351 module = get_module(key)
michael@0 352 if module:
michael@0 353 if not module in files:
michael@0 354 files[module] = []
michael@0 355 t = files[module]
michael@0 356 elif key in DISABLED_MODULES:
michael@0 357 if not key in disabled:
michael@0 358 disabled[key] = []
michael@0 359 t = disabled[key]
michael@0 360 else:
michael@0 361 if not key in unknown:
michael@0 362 unknown[key] = []
michael@0 363 t = unknown[key]
michael@0 364 t.append(f)
michael@0 365
michael@0 366 files['UNIFIED_SOURCES'] = [f for f in files['UNIFIED_SOURCES'] if f not in files['SOURCES']]
michael@0 367
michael@0 368 for key in files:
michael@0 369 files[key] = list(sorted(set(files[key])))
michael@0 370
michael@0 371 return source, files, disabled, unknown
michael@0 372
michael@0 373 def update_sources_mozbuild(files, sources_mozbuild):
michael@0 374 f = StringIO()
michael@0 375 pprint(files, stream=f)
michael@0 376 sources_mozbuild_new = "files = {\n %s\n}\n" % f.getvalue().strip()[1:-1]
michael@0 377 if sources_mozbuild != sources_mozbuild_new:
michael@0 378 print 'updating sources.mozbuild'
michael@0 379 with open('sources.mozbuild', 'w') as f:
michael@0 380 f.write(sources_mozbuild_new)
michael@0 381
michael@0 382 def get_current_files():
michael@0 383 current_files = []
michael@0 384 for root, folders, files in os.walk('.'):
michael@0 385 for f in files:
michael@0 386 f = os.path.join(root, f)[len('.%s'%os.sep):]
michael@0 387 if 'upstream%s'%os.sep in f or not os.sep in f:
michael@0 388 continue
michael@0 389 if os.path.splitext(f)[-1] in extensions:
michael@0 390 current_files.append(f)
michael@0 391 return current_files
michael@0 392
michael@0 393 def is_new(a, b):
michael@0 394 return not os.path.exists(a) \
michael@0 395 or not os.path.exists(b) \
michael@0 396 or open(a).read() != open(b).read()
michael@0 397
michael@0 398 def get_sources_mozbuild():
michael@0 399 with open('sources.mozbuild') as f:
michael@0 400 sources_mozbuild = f.read()
michael@0 401 exec(sources_mozbuild)
michael@0 402 return sources_mozbuild, files
michael@0 403
michael@0 404 def update_and_remove_files(prefix, libvpx_files, files):
michael@0 405 current_files = get_current_files()
michael@0 406
michael@0 407 def copy(src, dst):
michael@0 408 print ' ', dst
michael@0 409 shutil.copy(src, dst)
michael@0 410
michael@0 411 # Update files
michael@0 412 first = True
michael@0 413 for f in libvpx_files:
michael@0 414 fdir = os.path.dirname(f)
michael@0 415 if fdir and not os.path.exists(fdir):
michael@0 416 os.makedirs(fdir)
michael@0 417 s = os.path.join(prefix, f)
michael@0 418 if is_new(f, s):
michael@0 419 if first:
michael@0 420 print "Copy files:"
michael@0 421 first = False
michael@0 422 copy(s, f)
michael@0 423
michael@0 424 # Copy configuration files for each platform
michael@0 425 for target in PLATFORMS:
michael@0 426 first = True
michael@0 427 for f in platform_files:
michael@0 428 t = os.path.splitext(f)
michael@0 429 t = '%s_%s%s' % (t[0], target, t[1])
michael@0 430 f = os.path.join(prefix, 'objdir', target, f)
michael@0 431 if is_new(f, t):
michael@0 432 if first:
michael@0 433 print "Copy files for %s:" % target
michael@0 434 first = False
michael@0 435 copy(f, t)
michael@0 436
michael@0 437 # Copy vpx_version.h from one of the build targets
michael@0 438 s = os.path.join(prefix, 'objdir/x86-linux-gcc/vpx_version.h')
michael@0 439 f = 'vpx_version.h'
michael@0 440 if is_new(s, f):
michael@0 441 copy(s, f)
michael@0 442
michael@0 443 # Remove unknown files from tree
michael@0 444 removed_files = [f for f in current_files if f not in libvpx_files]
michael@0 445 if removed_files:
michael@0 446 print "Remove files:"
michael@0 447 for f in removed_files:
michael@0 448 os.unlink(f)
michael@0 449 print ' ', f
michael@0 450
michael@0 451 def apply_patches():
michael@0 452 # Patch to permit vpx users to specify their own <stdint.h> types.
michael@0 453 os.system("patch -p3 < stdint.patch")
michael@0 454 os.system("patch -p3 < unified.patch")
michael@0 455 os.system("patch -p3 < mingw.patch")
michael@0 456
michael@0 457 def update_readme(commit):
michael@0 458 with open('README_MOZILLA') as f:
michael@0 459 readme = f.read()
michael@0 460
michael@0 461 if 'The git commit ID used was' in readme:
michael@0 462 new_readme = re.sub('The git commit ID used was [a-f0-9]+',
michael@0 463 'The git commit ID used was %s' % commit, readme)
michael@0 464 else:
michael@0 465 new_readme = "%s\n\nThe git commit ID used was %s\n" % (readme, commit)
michael@0 466
michael@0 467 if readme != new_readme:
michael@0 468 with open('README_MOZILLA', 'w') as f:
michael@0 469 f.write(new_readme)
michael@0 470
michael@0 471 def print_info(source, files, disabled, unknown, moz_build_files):
michael@0 472 for key in moz_build_files:
michael@0 473 if key not in files:
michael@0 474 print key, 'MISSING'
michael@0 475 else:
michael@0 476 gone = set(moz_build_files[key]) - set(files[key])
michael@0 477 new = set(files[key]) - set(moz_build_files[key])
michael@0 478 if gone:
michael@0 479 print key, 'GONE:'
michael@0 480 print ' '+ '\n '.join(gone)
michael@0 481 if new:
michael@0 482 print key, 'NEW:'
michael@0 483 print ' '+ '\n '.join(new)
michael@0 484
michael@0 485 if unknown:
michael@0 486 print "Please update this script, the following modules are unknown"
michael@0 487 pprint(unknown)
michael@0 488
michael@0 489 if DEBUG:
michael@0 490 print "===== SOURCE"
michael@0 491 pprint(source)
michael@0 492 print "===== FILES"
michael@0 493 pprint(files)
michael@0 494 print "===== DISABLED"
michael@0 495 pprint(disabled)
michael@0 496 print "===== UNKNOWN"
michael@0 497 pprint(unknown)
michael@0 498
michael@0 499
michael@0 500 if __name__ == '__main__':
michael@0 501 parser = argparse.ArgumentParser(description='''This script only works on Mac OS X since the OS X Toolchain is not available on other platforms.
michael@0 502 In addition you need XCode and the Android NDK installed.
michael@0 503 If commit hash is not provided, current git master is used.''')
michael@0 504 parser.add_argument('--debug', dest='debug', action="store_true")
michael@0 505 parser.add_argument('--ndk', dest='ndk', type=str)
michael@0 506 parser.add_argument('--commit', dest='commit', type=str, default=None)
michael@0 507
michael@0 508 args = parser.parse_args()
michael@0 509
michael@0 510 if sys.platform != 'darwin' or not args.ndk:
michael@0 511 parser.print_help()
michael@0 512 sys.exit(1)
michael@0 513
michael@0 514 ndk_path = args.ndk
michael@0 515 commit = args.commit
michael@0 516 DEBUG = args.debug
michael@0 517
michael@0 518 base = os.path.abspath(os.curdir)
michael@0 519 prefix = os.path.join(base, 'upstream/')
michael@0 520
michael@0 521 commit = prepare_upstream(prefix, commit)
michael@0 522
michael@0 523 libvpx_files = get_libvpx_files(prefix)
michael@0 524 source, files, disabled, unknown = get_sources(prefix)
michael@0 525
michael@0 526 sources_mozbuild, moz_build_files = get_sources_mozbuild()
michael@0 527
michael@0 528 print_info(source, files, disabled, unknown, moz_build_files)
michael@0 529 update_sources_mozbuild(files, sources_mozbuild)
michael@0 530 update_and_remove_files(prefix, libvpx_files, files)
michael@0 531 apply_patches()
michael@0 532 update_readme(commit)
michael@0 533
michael@0 534 cleanup_upstream()

mercurial