Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1019)

Side by Side Diff: build/android/gyp/util/build_utils.py

Issue 1124763003: Update from https://crrev.com/327068 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: update nacl, buildtools, fix display_change_notifier_unittest Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import ast 5 import ast
6 import contextlib 6 import contextlib
7 import fnmatch 7 import fnmatch
8 import json 8 import json
9 import os 9 import os
10 import pipes 10 import pipes
11 import re 11 import re
12 import shlex 12 import shlex
13 import shutil 13 import shutil
14 import subprocess 14 import subprocess
15 import sys 15 import sys
16 import tempfile 16 import tempfile
17 import zipfile 17 import zipfile
18 18
19 19
20 CHROMIUM_SRC = os.path.normpath( 20 CHROMIUM_SRC = os.path.normpath(
21 os.path.join(os.path.dirname(__file__), 21 os.path.join(os.path.dirname(__file__),
22 os.pardir, os.pardir, os.pardir, os.pardir)) 22 os.pardir, os.pardir, os.pardir, os.pardir))
23 COLORAMA_ROOT = os.path.join(CHROMIUM_SRC, 23 COLORAMA_ROOT = os.path.join(CHROMIUM_SRC,
24 'third_party', 'colorama', 'src') 24 'third_party', 'colorama', 'src')
25 # aapt should ignore OWNERS files in addition the default ignore pattern. 25 # aapt should ignore OWNERS files in addition the default ignore pattern.
26 AAPT_IGNORE_PATTERN = ('!OWNERS:!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:' + 26 AAPT_IGNORE_PATTERN = ('!OWNERS:!.svn:!.git:!.ds_store:!*.scc:.*:<dir>_*:' +
27 '!CVS:!thumbs.db:!picasa.ini:!*~') 27 '!CVS:!thumbs.db:!picasa.ini:!*~:!*.d.stamp')
28 28
29 29
30 @contextlib.contextmanager 30 @contextlib.contextmanager
31 def TempDir(): 31 def TempDir():
32 dirname = tempfile.mkdtemp() 32 dirname = tempfile.mkdtemp()
33 try: 33 try:
34 yield dirname 34 yield dirname
35 finally: 35 finally:
36 shutil.rmtree(dirname) 36 shutil.rmtree(dirname)
37 37
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 with zipfile.ZipFile(output, 'w') as outfile: 229 with zipfile.ZipFile(output, 'w') as outfile:
230 for root, _, files in os.walk(base_dir): 230 for root, _, files in os.walk(base_dir):
231 for f in files: 231 for f in files:
232 path = os.path.join(root, f) 232 path = os.path.join(root, f)
233 archive_path = os.path.relpath(path, base_dir) 233 archive_path = os.path.relpath(path, base_dir)
234 CheckZipPath(archive_path) 234 CheckZipPath(archive_path)
235 outfile.write(path, archive_path) 235 outfile.write(path, archive_path)
236 236
237 237
238 def MergeZips(output, inputs, exclude_patterns=None): 238 def MergeZips(output, inputs, exclude_patterns=None):
239 added_names = set()
239 def Allow(name): 240 def Allow(name):
240 if exclude_patterns is not None: 241 if exclude_patterns is not None:
241 for p in exclude_patterns: 242 for p in exclude_patterns:
242 if fnmatch.fnmatch(name, p): 243 if fnmatch.fnmatch(name, p):
243 return False 244 return False
244 return True 245 return True
245 246
246 with zipfile.ZipFile(output, 'w') as out_zip: 247 with zipfile.ZipFile(output, 'w') as out_zip:
247 for in_file in inputs: 248 for in_file in inputs:
248 with zipfile.ZipFile(in_file, 'r') as in_zip: 249 with zipfile.ZipFile(in_file, 'r') as in_zip:
249 for name in in_zip.namelist(): 250 for name in in_zip.namelist():
250 if Allow(name): 251 if name not in added_names and Allow(name):
251 out_zip.writestr(name, in_zip.read(name)) 252 out_zip.writestr(name, in_zip.read(name))
253 added_names.add(name)
252 254
253 255
254 def PrintWarning(message): 256 def PrintWarning(message):
255 print 'WARNING: ' + message 257 print 'WARNING: ' + message
256 258
257 259
258 def PrintBigWarning(message): 260 def PrintBigWarning(message):
259 print '***** ' * 8 261 print '***** ' * 8
260 PrintWarning(message) 262 PrintWarning(message)
261 print '***** ' * 8 263 print '***** ' * 8
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 file_jsons[file_path] = ReadJson(file_path) 367 file_jsons[file_path] = ReadJson(file_path)
366 368
367 expansion = file_jsons[file_path] 369 expansion = file_jsons[file_path]
368 for k in lookup_path[1:]: 370 for k in lookup_path[1:]:
369 expansion = expansion[k] 371 expansion = expansion[k]
370 372
371 new_args[i] = arg[:match.start()] + str(expansion) 373 new_args[i] = arg[:match.start()] + str(expansion)
372 374
373 return new_args 375 return new_args
374 376
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698