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 """Tool to roll Mojo into Chromium. See: | 6 """Tool to roll Mojo into Chromium. See: |
7 https://github.com/domokit/mojo/wiki/Rolling-code-between-chromium-and-mojo#mojo
---chromium-updates-sdk--edk | 7 https://github.com/domokit/mojo/wiki/Rolling-code-between-chromium-and-mojo#mojo
---chromium-updates-sdk--edk |
8 """ | 8 """ |
9 | 9 |
10 import os | 10 import os |
11 import sys | 11 import sys |
12 from utils import commit | 12 from utils import commit |
13 from utils import chromium_root_dir | 13 from utils import chromium_root_dir |
14 from utils import system | 14 from utils import system |
15 | 15 |
16 sdk_prefix_in_chromium = "third_party/mojo/src" | 16 sdk_prefix_in_chromium = "third_party/mojo/src" |
17 sdk_dirs_to_clone = [ | 17 sdk_dirs_to_clone = [ |
18 "mojo/edk", | 18 "mojo/edk", |
19 "mojo/public", | 19 "mojo/public", |
20 "nacl_bindings", | 20 "nacl_bindings", |
21 ] | 21 ] |
22 | 22 |
23 sdk_dirs_to_not_clone = [ | 23 sdk_dirs_to_not_clone = [ |
24 "mojo/public/cpp/application", | 24 "mojo/public/cpp/application", |
25 "mojo/public/interfaces/application", | 25 "mojo/public/interfaces/application", |
26 "mojo/public/java/application", | 26 "third_party/mojo/src/mojo/public/java/application", |
27 ] | 27 ] |
28 | 28 |
29 # Individual files to preserve within the target repository during roll. These | 29 # Individual files to preserve within the target repository during roll. These |
30 # are relative to |sdk_prefix_in_chromium| but are not maintained in the mojo | 30 # are relative to |sdk_prefix_in_chromium| but are not maintained in the mojo |
31 # repository. | 31 # repository. |
32 preserved_chromium_files = [ | 32 preserved_chromium_files = [ |
33 "mojo/edk/DEPS", | 33 "mojo/edk/DEPS", |
34 "mojo/public/DEPS", | 34 "mojo/public/DEPS", |
35 "mojo/public/platform/nacl/DEPS", | 35 "mojo/public/platform/nacl/DEPS", |
36 "nacl_bindings/DEPS", | 36 "nacl_bindings/DEPS", |
37 ] | 37 ] |
38 | 38 |
39 # A dictionary mapping dirs to clone to their destination locations in Chromium. | 39 # A dictionary mapping dirs to clone to their destination locations in Chromium. |
40 dirs_to_clone = {} | 40 dirs_to_clone = {} |
41 | 41 |
42 for sdk_dir in sdk_dirs_to_clone: | 42 for sdk_dir in sdk_dirs_to_clone: |
43 sdk_dir_in_chromium = os.path.join(sdk_prefix_in_chromium, sdk_dir) | 43 sdk_dir_in_chromium = os.path.join(sdk_prefix_in_chromium, sdk_dir) |
44 dirs_to_clone[sdk_dir] = sdk_dir_in_chromium | 44 dirs_to_clone[sdk_dir] = sdk_dir_in_chromium |
45 | 45 |
46 def rev(source_dir, chromium_dir, mojo_revision): | 46 def rev(source_dir, chromium_dir): |
47 src_commit = system(["git", "rev-parse", mojo_revision], | 47 src_commit = system(["git", "show-ref", "HEAD", "-s"], cwd=source_dir).strip() |
48 cwd=source_dir).strip() | |
49 | 48 |
50 for input_dir, dest_dir in dirs_to_clone.iteritems(): | 49 for input_dir, dest_dir in dirs_to_clone.iteritems(): |
51 if os.path.exists(os.path.join(chromium_dir, dest_dir)): | 50 if os.path.exists(os.path.join(chromium_dir, dest_dir)): |
52 print "removing directory %s" % dest_dir | 51 print "removing directory %s" % dest_dir |
53 system(["git", "rm", "-r", dest_dir], cwd=chromium_dir) | 52 system(["git", "rm", "-r", dest_dir], cwd=chromium_dir) |
54 print "cloning directory %s into %s" % (input_dir, dest_dir) | 53 print "cloning directory %s into %s" % (input_dir, dest_dir) |
55 files = system(["git", "ls-files", input_dir], cwd=source_dir) | 54 files = system(["git", "ls-files", input_dir], cwd=source_dir) |
56 for f in files.splitlines(): | 55 for f in files.splitlines(): |
57 # Don't copy presubmit files over since the code is read-only on the | 56 # Don't copy presubmit files over since the code is read-only on the |
58 # chromium side. | 57 # chromium side. |
(...skipping 24 matching lines...) Expand all Loading... |
83 system(["git", "add", version_filename], cwd=chromium_dir) | 82 system(["git", "add", version_filename], cwd=chromium_dir) |
84 | 83 |
85 # Reset preserved files that were blown away. | 84 # Reset preserved files that were blown away. |
86 for rel_path in preserved_chromium_files: | 85 for rel_path in preserved_chromium_files: |
87 preserved_path = os.path.join(sdk_prefix_in_chromium, rel_path) | 86 preserved_path = os.path.join(sdk_prefix_in_chromium, rel_path) |
88 system(["git", "reset", "--", preserved_path]) | 87 system(["git", "reset", "--", preserved_path]) |
89 system(["git", "checkout", preserved_path]) | 88 system(["git", "checkout", preserved_path]) |
90 | 89 |
91 commit("Update mojo sdk to rev " + src_commit, cwd=chromium_dir) | 90 commit("Update mojo sdk to rev " + src_commit, cwd=chromium_dir) |
92 | 91 |
93 if len(sys.argv) < 2: | 92 if len(sys.argv) != 2: |
94 print "usage: rev_sdk.py <mojo source dir> [<mojo revision>]" | 93 print "usage: rev_sdk.py <mojo source dir>" |
95 sys.exit(1) | 94 sys.exit(1) |
96 | 95 |
97 # Allow override of the roll revision. | 96 rev(sys.argv[1], chromium_root_dir) |
98 if len(sys.argv) == 3: | |
99 mojo_revision = sys.argv[2] | |
100 else: | |
101 mojo_revision = 'origin/HEAD' | |
102 | |
103 rev(sys.argv[1], chromium_root_dir, mojo_revision) | |
104 | |
OLD | NEW |