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

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

Issue 1361733002: Make javac invocations incremental when possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@apkbuilder
Patch Set: add flag and disable by default Created 5 years, 2 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/gyp/util/md5_check.py » ('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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return device_state.strip() == 'device' 189 return device_state.strip() == 'device'
190 190
191 191
192 def CheckZipPath(name): 192 def CheckZipPath(name):
193 if os.path.normpath(name) != name: 193 if os.path.normpath(name) != name:
194 raise Exception('Non-canonical zip path: %s' % name) 194 raise Exception('Non-canonical zip path: %s' % name)
195 if os.path.isabs(name): 195 if os.path.isabs(name):
196 raise Exception('Absolute zip path: %s' % name) 196 raise Exception('Absolute zip path: %s' % name)
197 197
198 198
199 def ExtractAll(zip_path, path=None, no_clobber=True, pattern=None): 199 def ExtractAll(zip_path, path=None, no_clobber=True, pattern=None,
200 predicate=None):
200 if path is None: 201 if path is None:
201 path = os.getcwd() 202 path = os.getcwd()
202 elif not os.path.exists(path): 203 elif not os.path.exists(path):
203 MakeDirectory(path) 204 MakeDirectory(path)
204 205
205 with zipfile.ZipFile(zip_path) as z: 206 with zipfile.ZipFile(zip_path) as z:
206 for name in z.namelist(): 207 for name in z.namelist():
207 if name.endswith('/'): 208 if name.endswith('/'):
208 continue 209 continue
209 if pattern is not None: 210 if pattern is not None:
210 if not fnmatch.fnmatch(name, pattern): 211 if not fnmatch.fnmatch(name, pattern):
211 continue 212 continue
213 if predicate and not predicate(name):
214 continue
212 CheckZipPath(name) 215 CheckZipPath(name)
213 if no_clobber: 216 if no_clobber:
214 output_path = os.path.join(path, name) 217 output_path = os.path.join(path, name)
215 if os.path.exists(output_path): 218 if os.path.exists(output_path):
216 raise Exception( 219 raise Exception(
217 'Path already exists from zip: %s %s %s' 220 'Path already exists from zip: %s %s %s'
218 % (zip_path, name, output_path)) 221 % (zip_path, name, output_path))
219 z.extract(name, path) 222 z.extract(name, path)
220 223
221 224
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 for k in lookup_path[1:]: 399 for k in lookup_path[1:]:
397 expansion = expansion[k] 400 expansion = expansion[k]
398 401
399 new_args[i] = arg[:match.start()] + str(expansion) 402 new_args[i] = arg[:match.start()] + str(expansion)
400 403
401 return new_args 404 return new_args
402 405
403 406
404 def CallAndWriteDepfileIfStale(function, options, record_path=None, 407 def CallAndWriteDepfileIfStale(function, options, record_path=None,
405 input_paths=None, input_strings=None, 408 input_paths=None, input_strings=None,
406 output_paths=None, force=False): 409 output_paths=None, force=False,
410 pass_changes=False):
407 """Wraps md5_check.CallAndRecordIfStale() and also writes dep & stamp files. 411 """Wraps md5_check.CallAndRecordIfStale() and also writes dep & stamp files.
408 412
409 Depfiles and stamp files are automatically added to output_paths when present 413 Depfiles and stamp files are automatically added to output_paths when present
410 in the |options| argument. They are then created after |function| is called. 414 in the |options| argument. They are then created after |function| is called.
411 """ 415 """
412 if not output_paths: 416 if not output_paths:
413 raise Exception('At least one output_path must be specified.') 417 raise Exception('At least one output_path must be specified.')
414 input_paths = list(input_paths or []) 418 input_paths = list(input_paths or [])
415 input_strings = list(input_strings or []) 419 input_strings = list(input_strings or [])
416 output_paths = list(output_paths or []) 420 output_paths = list(output_paths or [])
417 421
418 python_deps = None 422 python_deps = None
419 if hasattr(options, 'depfile') and options.depfile: 423 if hasattr(options, 'depfile') and options.depfile:
420 python_deps = GetPythonDependencies() 424 python_deps = GetPythonDependencies()
421 # List python deps in input_strings rather than input_paths since the 425 # List python deps in input_strings rather than input_paths since the
422 # contents of them does not change what gets written to the depfile. 426 # contents of them does not change what gets written to the depfile.
423 input_strings += python_deps 427 input_strings += python_deps
424 output_paths += [options.depfile] 428 output_paths += [options.depfile]
425 429
426 stamp_file = hasattr(options, 'stamp') and options.stamp 430 stamp_file = hasattr(options, 'stamp') and options.stamp
427 if stamp_file: 431 if stamp_file:
428 output_paths += [stamp_file] 432 output_paths += [stamp_file]
429 433
430 def on_stale_md5(): 434 def on_stale_md5(changes):
431 function() 435 args = (changes,) if pass_changes else ()
436 function(*args)
432 if python_deps is not None: 437 if python_deps is not None:
433 WriteDepfile(options.depfile, python_deps + input_paths) 438 WriteDepfile(options.depfile, python_deps + input_paths)
434 if stamp_file: 439 if stamp_file:
435 Touch(stamp_file) 440 Touch(stamp_file)
436 441
437 md5_check.CallAndRecordIfStale( 442 md5_check.CallAndRecordIfStale(
438 on_stale_md5, 443 on_stale_md5,
439 record_path=record_path, 444 record_path=record_path,
440 input_paths=input_paths, 445 input_paths=input_paths,
441 input_strings=input_strings, 446 input_strings=input_strings,
442 output_paths=output_paths, 447 output_paths=output_paths,
443 force=force) 448 force=force,
449 pass_changes=True)
444 450
OLDNEW
« no previous file with comments | « build/android/gyp/javac.py ('k') | build/android/gyp/util/md5_check.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698