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

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

Issue 13891010: [Android] Only write the ordered libraries file when it changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | build/android/gyp/write_ordered_libraries.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 fnmatch 5 import fnmatch
6 import json 6 import json
7 import os 7 import os
8 import pipes 8 import pipes
9 import shlex 9 import shlex
10 import shutil 10 import shutil
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 # is addressed. 54 # is addressed.
55 gyp_string = gyp_string.replace('##', '$') 55 gyp_string = gyp_string.replace('##', '$')
56 return shlex.split(gyp_string) 56 return shlex.split(gyp_string)
57 57
58 58
59 def CheckOptions(options, parser, required=[]): 59 def CheckOptions(options, parser, required=[]):
60 for option_name in required: 60 for option_name in required:
61 if not getattr(options, option_name): 61 if not getattr(options, option_name):
62 parser.error('--%s is required' % option_name.replace('_', '-')) 62 parser.error('--%s is required' % option_name.replace('_', '-'))
63 63
64 def WriteJson(obj, path, only_if_changed=False):
65 old_dump = None
66 if os.path.exists(path):
67 with open(path, 'r') as oldfile:
68 old_dump = oldfile.read()
69
70 new_dump = json.dumps(obj)
71
72 if not only_if_changed or old_dump != new_dump:
73 with open(path, 'w') as outfile:
74 outfile.write(new_dump)
64 75
65 def ReadJson(path): 76 def ReadJson(path):
66 with open(path, 'r') as jsonfile: 77 with open(path, 'r') as jsonfile:
67 return json.load(jsonfile) 78 return json.load(jsonfile)
68 79
69 80
70 # This can be used in most cases like subprocess.check_call. The output, 81 # This can be used in most cases like subprocess.check_call. The output,
71 # particularly when the command fails, better highlights the command's failure. 82 # particularly when the command fails, better highlights the command's failure.
72 # This call will directly exit on a failure in the subprocess so that no python 83 # This call will directly exit on a failure in the subprocess so that no python
73 # stacktrace is printed after the output of the failed command. 84 # stacktrace is printed after the output of the failed command.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 121
111 def IsTimeStale(output, inputs): 122 def IsTimeStale(output, inputs):
112 if not os.path.exists(output): 123 if not os.path.exists(output):
113 return True 124 return True
114 125
115 output_time = GetModifiedTime(output) 126 output_time = GetModifiedTime(output)
116 for input in inputs: 127 for input in inputs:
117 if GetModifiedTime(input) > output_time: 128 if GetModifiedTime(input) > output_time:
118 return True 129 return True
119 return False 130 return False
OLDNEW
« no previous file with comments | « no previous file | build/android/gyp/write_ordered_libraries.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698