Commit a45bdf09 authored by cjhopman@chromium.org's avatar cjhopman@chromium.org

[Android] Only write the ordered libraries file when it changes

This action is triggered whenever the top-level library is re-linked. This file
being touched then triggers generating a Java file, and then
rebuilding/installing the APK. This is all unnecessary.

Instead, only write this file if the output has changed. Then, since the ninja
generator uses restat=1, dependent actions will only be retriggered when this
actual changes (almost never).

BUG=158821

Review URL: https://chromiumcodereview.appspot.com/13891010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194780 0039d316-1c4b-4281-b951-d872f2087c98
parent 147938bf
......@@ -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:
......
......@@ -107,8 +107,7 @@ def main(argv):
libraries = GetSortedTransitiveDependencies(libraries)
with open(_options.output, 'w') as outfile:
json.dump(libraries, outfile)
build_utils.WriteJson(libraries, _options.output, only_if_changed=True)
if _options.stamp:
build_utils.Touch(_options.stamp)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment