diff options
author | rockot <rockot@chromium.org> | 2015-04-24 08:59:32 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-24 16:00:34 +0000 |
commit | aea10852fd84b7b22473aeef85f8adeac6771e56 (patch) | |
tree | c317428bea37075e6160d52a15a0ab61911a97ee /mojo | |
parent | 70d2cd67184a81c7c8207de3dc0a58a2dcee2a30 (diff) | |
download | chromium_src-aea10852fd84b7b22473aeef85f8adeac6771e56.zip chromium_src-aea10852fd84b7b22473aeef85f8adeac6771e56.tar.gz chromium_src-aea10852fd84b7b22473aeef85f8adeac6771e56.tar.bz2 |
Preserve embedded DEPS files during mojo roll
These are no longer part of the mojo repo, but we want to persist them
when rolling to chromium.
This also brings over the small utils module that the script
depends on, with some minor adjustments. Rather than taking
the chromium path as an arg and inferring the mojo path, we
now do the reverse.
BUG=None
R=jam@chromium.org
Review URL: https://codereview.chromium.org/1102043002
Cr-Commit-Position: refs/heads/master@{#326809}
Diffstat (limited to 'mojo')
-rwxr-xr-x | mojo/tools/rev_sdk.py | 25 | ||||
-rwxr-xr-x | mojo/tools/utils.py | 32 |
2 files changed, 51 insertions, 6 deletions
diff --git a/mojo/tools/rev_sdk.py b/mojo/tools/rev_sdk.py index c750868..c5cefbc 100755 --- a/mojo/tools/rev_sdk.py +++ b/mojo/tools/rev_sdk.py @@ -10,7 +10,7 @@ https://github.com/domokit/mojo/wiki/Rolling-code-between-chromium-and-mojo#mojo import os import sys from utils import commit -from utils import mojo_root_dir +from utils import chromium_root_dir from utils import system sdk_prefix_in_chromium = "third_party/mojo/src" @@ -20,9 +20,15 @@ sdk_dirs_to_clone = [ "nacl_bindings", ] - -services_prefix_in_mojo = "mojo/services" -services_prefix_in_chromium = "third_party/mojo_services/src" +# Individual files to preserve within the target repository during roll. These +# are relative to |sdk_prefix_in_chromium| but are not maintained in the mojo +# repository. +preserved_chromium_files = [ + "mojo/edk/DEPS", + "mojo/public/DEPS", + "mojo/public/platform/nacl/DEPS", + "nacl_bindings/DEPS", +] # A dictionary mapping dirs to clone to their destination locations in Chromium. dirs_to_clone = {} @@ -60,10 +66,17 @@ def rev(source_dir, chromium_dir): with open(version_filename, "w") as version_file: version_file.write(src_commit) system(["git", "add", version_filename], cwd=chromium_dir) + + # Reset preserved files that were blown away. + for rel_path in preserved_chromium_files: + preserved_path = os.path.join(sdk_prefix_in_chromium, rel_path) + system(["git", "reset", "--", preserved_path]) + system(["git", "checkout", preserved_path]) + commit("Update mojo sdk to rev " + src_commit, cwd=chromium_dir) if len(sys.argv) != 2: - print "usage: rev_sdk.py <chromium source dir>" + print "usage: rev_sdk.py <mojo source dir>" sys.exit(1) -rev(mojo_root_dir, sys.argv[1]) +rev(sys.argv[1], chromium_root_dir) diff --git a/mojo/tools/utils.py b/mojo/tools/utils.py new file mode 100755 index 0000000..740b363 --- /dev/null +++ b/mojo/tools/utils.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import fnmatch +import os +import subprocess + +chromium_root_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), + os.pardir, os.pardir) + +def commit(message, cwd=None): + subprocess.call(['git', 'commit', '-a', '-m', message], cwd=cwd) + +def system(command, cwd=None): + return subprocess.check_output(command, cwd=cwd) + +def find(patterns, start='.'): + for path, dirs, files in os.walk(start): + for basename in files + dirs: + if any([fnmatch.fnmatch(basename, pattern) for pattern in patterns]): + filename = os.path.join(path, basename) + yield filename + +def filter_file(path, predicate): + with open(path, 'r+') as f: + lines = f.readlines() + new_lines = [line for line in lines if predicate(line)] + f.seek(0) + f.truncate() + f.write(''.join(new_lines)) |