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

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

Issue 1324203002: Reland of Fix javac command never caching input .md5s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@md5-extra
Patch Set: fixed empty jars Created 5 years, 3 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
« no previous file with comments | « build/android/gyp/javac.py ('k') | build/android/rezip.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 def ZipDir(output, base_dir): 228 def ZipDir(output, base_dir):
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 MatchesGlob(path, filters):
239 """Returns whether the given path matches any of the given glob patterns."""
240 return filters and any(fnmatch.fnmatch(path, f) for f in filters)
241
242
238 def MergeZips(output, inputs, exclude_patterns=None): 243 def MergeZips(output, inputs, exclude_patterns=None):
239 added_names = set() 244 added_names = set()
240 def Allow(name):
241 if exclude_patterns is not None:
242 for p in exclude_patterns:
243 if fnmatch.fnmatch(name, p):
244 return False
245 return True
246 245
247 with zipfile.ZipFile(output, 'w') as out_zip: 246 with zipfile.ZipFile(output, 'w') as out_zip:
248 for in_file in inputs: 247 for in_file in inputs:
249 with zipfile.ZipFile(in_file, 'r') as in_zip: 248 with zipfile.ZipFile(in_file, 'r') as in_zip:
250 for name in in_zip.namelist(): 249 for name in in_zip.namelist():
251 if name not in added_names and Allow(name): 250 if not (name in added_names or MatchesGlob(name, exclude_patterns)):
252 out_zip.writestr(name, in_zip.read(name)) 251 out_zip.writestr(name, in_zip.read(name))
253 added_names.add(name) 252 added_names.add(name)
254 253
255 254
256 def PrintWarning(message): 255 def PrintWarning(message):
257 print 'WARNING: ' + message 256 print 'WARNING: ' + message
258 257
259 258
260 def PrintBigWarning(message): 259 def PrintBigWarning(message):
261 print '***** ' * 8 260 print '***** ' * 8
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 file_jsons[file_path] = ReadJson(file_path) 370 file_jsons[file_path] = ReadJson(file_path)
372 371
373 expansion = file_jsons[file_path] 372 expansion = file_jsons[file_path]
374 for k in lookup_path[1:]: 373 for k in lookup_path[1:]:
375 expansion = expansion[k] 374 expansion = expansion[k]
376 375
377 new_args[i] = arg[:match.start()] + str(expansion) 376 new_args[i] = arg[:match.start()] + str(expansion)
378 377
379 return new_args 378 return new_args
380 379
OLDNEW
« no previous file with comments | « build/android/gyp/javac.py ('k') | build/android/rezip.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698