Index: build/android/gyp/util/build_utils.py |
diff --git a/build/android/gyp/util/build_utils.py b/build/android/gyp/util/build_utils.py |
index 1fac120658f9ee621fecbad02bce8733d5a109f6..b8b94622d910ef41ea998567d3c10416b8fcf264 100644 |
--- a/build/android/gyp/util/build_utils.py |
+++ b/build/android/gyp/util/build_utils.py |
@@ -61,6 +61,17 @@ def CheckOptions(options, parser, required=[]): |
if not getattr(options, option_name): |
parser.error('--%s is required' % option_name.replace('_', '-')) |
+def WriteJson(obj, path, only_if_changed=False): |
+ old_dump = None |
+ if os.path.exists(path): |
+ with open(path, 'r') as oldfile: |
+ old_dump = oldfile.read() |
+ |
+ new_dump = json.dumps(obj) |
+ |
+ if not only_if_changed or old_dump != new_dump: |
+ with open(path, 'w') as outfile: |
+ outfile.write(new_dump) |
def ReadJson(path): |
with open(path, 'r') as jsonfile: |