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

Side by Side Diff: mojo/tools/rev_sdk.py

Issue 1338793003: third_party/mojo: stop syncing from the Mojo repository. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | mojo/tools/utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
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
8 '''
9
10 import os
11 import sys
12 from utils import commit
13 from utils import chromium_root_dir
14 from utils import system
15
16 sdk_prefix_in_chromium = 'third_party/mojo/src'
17 sdk_dirs_to_clone = [
18 'mojo/edk',
19 'mojo/public',
20 'nacl_bindings',
21 ]
22
23 sdk_dirs_to_not_clone = [
24 'mojo/public/cpp/application',
25 'mojo/public/interfaces/application',
26 'mojo/public/interfaces/network',
27 'mojo/public/java/application',
28 ]
29
30 # Individual files to preserve within the target repository during roll. These
31 # are relative to |sdk_prefix_in_chromium| but are not maintained in the mojo
32 # repository.
33 preserved_chromium_files = [
34 'mojo/edk/DEPS',
35 'mojo/public/DEPS',
36 'mojo/public/c/gpu/DEPS',
37 'mojo/public/platform/nacl/DEPS',
38 'nacl_bindings/DEPS',
39 ]
40
41 # A dictionary mapping dirs to clone to their destination locations in Chromium.
42 dirs_to_clone = {}
43
44 for sdk_dir in sdk_dirs_to_clone:
45 sdk_dir_in_chromium = os.path.join(sdk_prefix_in_chromium, sdk_dir)
46 dirs_to_clone[sdk_dir] = sdk_dir_in_chromium
47
48 def rev(source_dir, chromium_dir, mojo_revision):
49 src_commit = system(['git', 'rev-parse', mojo_revision],
50 cwd=source_dir).strip()
51
52 for input_dir, dest_dir in dirs_to_clone.iteritems():
53 if os.path.exists(os.path.join(chromium_dir, dest_dir)):
54 print 'removing directory %s' % dest_dir
55 system(['git', 'rm', '-r', dest_dir], cwd=chromium_dir)
56 print 'cloning directory %s into %s' % (input_dir, dest_dir)
57 files = system(['git', 'ls-files', input_dir], cwd=source_dir)
58 for f in files.splitlines():
59 # Don't copy presubmit files over since the code is read-only on the
60 # chromium side.
61 if os.path.basename(f) == 'PRESUBMIT.py':
62 continue
63
64 exclude = False
65 for excluded in sdk_dirs_to_not_clone:
66 if f.startswith(excluded):
67 exclude = True
68 break
69 if exclude:
70 continue
71
72 # Clone |f| into Chromium under |dest_dir| at its location relative to
73 # |input_dir|.
74 f_relpath = os.path.relpath(f, input_dir)
75 dest_path = os.path.join(chromium_dir, dest_dir, f_relpath)
76 system(['mkdir', '-p', os.path.dirname(dest_path)])
77 system(['cp', os.path.join(source_dir, f), dest_path])
78 os.chdir(chromium_dir)
79 system(['git', 'add', dest_dir], cwd=chromium_dir)
80
81 mojo_public_dest_dir = os.path.join(sdk_prefix_in_chromium, 'mojo/public')
82 version_filename = os.path.join(mojo_public_dest_dir, 'VERSION')
83 with open(version_filename, 'w') as version_file:
84 version_file.write(src_commit)
85 system(['git', 'add', version_filename], cwd=chromium_dir)
86
87 # Reset preserved files that were blown away.
88 for rel_path in preserved_chromium_files:
89 preserved_path = os.path.join(sdk_prefix_in_chromium, rel_path)
90 system(['git', 'reset', '--', preserved_path])
91 system(['git', 'checkout', preserved_path])
92
93 commit('Update mojo sdk to rev ' + src_commit, cwd=chromium_dir)
94
95 if len(sys.argv) < 2:
96 print 'usage: rev_sdk.py <mojo source dir> [<mojo revision>]'
97 sys.exit(1)
98
99 # Allow override of the roll revision.
100 revision = sys.argv[2] if len(sys.argv) == 3 else 'origin/HEAD'
101 rev(sys.argv[1], chromium_root_dir, revision)
OLDNEW
« no previous file with comments | « no previous file | mojo/tools/utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698