| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import argparse | 6 import argparse |
| 7 import json | 7 import json |
| 8 import os | 8 import os |
| 9 import subprocess | 9 import subprocess |
| 10 import sys | 10 import sys |
| 11 import urllib2 | 11 import urllib2 |
| 12 from utils import commit | 12 from utils import commit |
| 13 from utils import mojo_root_dir | 13 from utils import mojo_root_dir |
| 14 from utils import system | 14 from utils import system |
| 15 from utils import temp_dir |
| 15 | 16 |
| 16 import patch | 17 import patch |
| 17 | 18 |
| 18 # These directories are snapshotted from chromium without modifications. | 19 # These directories are snapshotted from chromium without modifications. |
| 19 dirs_to_snapshot = [ | 20 dirs_to_snapshot = [ |
| 20 "base", | 21 "base", |
| 21 "build", | 22 "build", |
| 22 "cc", | 23 "cc", |
| 23 "gin", | 24 "gin", |
| 24 "gpu", | 25 "gpu", |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 # These directories are temporarily cloned in order to support the network | 82 # These directories are temporarily cloned in order to support the network |
| 82 # bootstrap library until we get that sorted out. | 83 # bootstrap library until we get that sorted out. |
| 83 net_dirs = [ | 84 net_dirs = [ |
| 84 "crypto", | 85 "crypto", |
| 85 "net", | 86 "net", |
| 86 "mojo/services/network"] | 87 "mojo/services/network"] |
| 87 | 88 |
| 88 files_to_copy = ["sandbox/sandbox_export.h", | 89 files_to_copy = ["sandbox/sandbox_export.h", |
| 89 ".clang-format"] | 90 ".clang-format"] |
| 90 | 91 |
| 92 # The contents of these files before the roll will be preserved after the roll, |
| 93 # even though they live in directories rolled in from Chromium. |
| 94 files_not_to_roll = [ "build/config/mojo.gni" ] |
| 95 |
| 91 dirs = dirs_to_snapshot + net_dirs | 96 dirs = dirs_to_snapshot + net_dirs |
| 92 | 97 |
| 93 def chromium_rev_number(src_commit): | 98 def chromium_rev_number(src_commit): |
| 94 base_url = "https://cr-rev.appspot.com/_ah/api/crrev/v1/commit/" | 99 base_url = "https://cr-rev.appspot.com/_ah/api/crrev/v1/commit/" |
| 95 commit_info = json.load(urllib2.urlopen(base_url + src_commit)) | 100 commit_info = json.load(urllib2.urlopen(base_url + src_commit)) |
| 96 return commit_info["numberings"][0]["number"] | 101 return commit_info["numberings"][0]["number"] |
| 97 | 102 |
| 98 def rev(source_dir): | 103 def rev(source_dir): |
| 99 for d in dirs: | 104 for d in dirs: |
| 100 print "removing directory %s" % d | 105 print "removing directory %s" % d |
| (...skipping 15 matching lines...) Expand all Loading... |
| 116 system(["git", "add", "."], cwd=mojo_root_dir) | 121 system(["git", "add", "."], cwd=mojo_root_dir) |
| 117 src_commit = system(["git", "rev-parse", "HEAD"], cwd=source_dir).strip() | 122 src_commit = system(["git", "rev-parse", "HEAD"], cwd=source_dir).strip() |
| 118 src_rev = chromium_rev_number(src_commit) | 123 src_rev = chromium_rev_number(src_commit) |
| 119 commit("Update from https://crrev.com/" + src_rev, cwd=mojo_root_dir) | 124 commit("Update from https://crrev.com/" + src_rev, cwd=mojo_root_dir) |
| 120 | 125 |
| 121 def main(): | 126 def main(): |
| 122 parser = argparse.ArgumentParser(description="Update the mojo repo's " + | 127 parser = argparse.ArgumentParser(description="Update the mojo repo's " + |
| 123 "snapshot of things imported from chromium.") | 128 "snapshot of things imported from chromium.") |
| 124 parser.add_argument("chromium_dir", help="chromium source dir") | 129 parser.add_argument("chromium_dir", help="chromium source dir") |
| 125 args = parser.parse_args() | 130 args = parser.parse_args() |
| 126 rev(args.chromium_dir) | 131 with temp_dir() as tempd: |
| 127 patch.patch() | 132 for f in files_not_to_roll: |
| 133 system(["mkdir", "-p", os.path.dirname(f)], cwd=tempd) |
| 134 system(["cp", os.path.join(mojo_root_dir, f), os.path.join(tempd, f)]) |
| 135 |
| 136 rev(args.chromium_dir) |
| 137 patch.patch() |
| 138 |
| 139 print "Restoring files whose contents don't track Chromium" |
| 140 for f in files_not_to_roll: |
| 141 system(["mkdir", "-p", os.path.dirname(f)], cwd=mojo_root_dir) |
| 142 system(["cp", os.path.join(tempd, f), os.path.join(mojo_root_dir, f)]) |
| 143 system(["git", "add", "."], cwd=mojo_root_dir) |
| 144 commit("Restored pre-roll versions of files that don't get rolled") |
| 128 return 0 | 145 return 0 |
| 129 | 146 |
| 130 if __name__ == "__main__": | 147 if __name__ == "__main__": |
| 131 sys.exit(main()) | 148 sys.exit(main()) |
| OLD | NEW |