Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit d1789ee

Browse files
committed
Merge pull request #73 from abarth/improve_roll_tools
Improve roll.py to work with HEAD Chromium
2 parents e69b3d7 + 5b96c69 commit d1789ee

File tree

3 files changed

+116
-26
lines changed

3 files changed

+116
-26
lines changed

sky/tools/roll/android_build.patch

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--- a/build/android/pylib/constants/__init__.py
2+
+++ b/build/android/pylib/constants/__init__.py
3+
@@ -184,7 +184,7 @@ class ANDROID_SDK_VERSION_CODES(object):
4+
LOLLIPOP_MR1 = 22
5+
6+
ANDROID_SDK_VERSION = ANDROID_SDK_VERSION_CODES.LOLLIPOP_MR1
7+
-ANDROID_SDK_BUILD_TOOLS_VERSION = '22.0.0'
8+
+ANDROID_SDK_BUILD_TOOLS_VERSION = '22.0.1'
9+
ANDROID_SDK_ROOT = os.path.join(DIR_SOURCE_ROOT,
10+
'third_party/android_tools/sdk')
11+
ANDROID_SDK_TOOLS = os.path.join(ANDROID_SDK_ROOT,
12+
--- a/build/common.gypi
13+
+++ b/build/common.gypi
14+
@@ -1682,7 +1682,7 @@
15+
'android_host_arch%': '<!(uname -m)',
16+
# Android API-level of the SDK used for compilation.
17+
'android_sdk_version%': '22',
18+
- 'android_sdk_build_tools_version%': '22.0.0',
19+
+ 'android_sdk_build_tools_version%': '22.0.1',
20+
'host_os%': "<!(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')",
21+
},
22+
# Copy conditionally-set variables out one scope.
23+
--- a/build/config/android/config.gni
24+
+++ b/build/config/android/config.gni
25+
@@ -17,7 +17,7 @@ if (is_android) {
26+
if (!defined(default_android_sdk_root)) {
27+
default_android_sdk_root = "//third_party/android_tools/sdk"
28+
default_android_sdk_version = "22"
29+
- default_android_sdk_build_tools_version = "22.0.0"
30+
+ default_android_sdk_build_tools_version = "22.0.1"
31+
}
32+
33+
if (!defined(google_play_services_library)) {

sky/tools/roll/patch.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
import os
7+
import subprocess
8+
import utils
9+
10+
def patch_and_filter():
11+
"""Applies the *.patch files in the current dir and some hardcoded filters."""
12+
os.chdir(utils.mojo_root_dir)
13+
14+
utils.filter_file("build/landmines.py",
15+
lambda line: not "gyp_environment" in line)
16+
utils.commit("filter gyp_environment out of build/landmines.py")
17+
18+
patch()
19+
20+
21+
def patch(relative_patches_dir=os.curdir):
22+
"""Applies the *.patch files in |relative_patches_dir|.
23+
24+
Args:
25+
relative_patches_dir: A directory path relative to the current directory.
26+
Defaults to the directory of this file.
27+
28+
Raises:
29+
subprocess.CalledProcessError if the patch couldn't be applied.
30+
"""
31+
patches_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
32+
relative_patches_dir)
33+
assert os.path.isdir(patches_dir)
34+
35+
os.chdir(utils.mojo_root_dir)
36+
for p in utils.find(["*.patch"], patches_dir):
37+
print "applying patch %s" % os.path.basename(p)
38+
try:
39+
utils.system(["git", "apply", p])
40+
utils.commit("applied patch %s" % os.path.basename(p))
41+
except subprocess.CalledProcessError:
42+
print "ERROR: patch %s failed to apply" % os.path.basename(p)
43+
raise

sky/tools/roll/roll.py

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import urllib2
1212
from utils import commit
1313
from utils import system
14+
import patch
1415

1516
# //base and its dependencies
1617
_base_deps = [
@@ -95,33 +96,39 @@
9596
'build/config/ui.gni',
9697
'build/ls.py',
9798
'build/module_args/mojo.gni',
99+
'build/symlink.py',
100+
'tools/android/VERSION_LINUX_NDK',
101+
'tools/android/VERSION_LINUX_SDK',
102+
'tools/android/VERSION_MACOSX_NDK',
103+
'tools/android/VERSION_MACOSX_SDK',
104+
'tools/android/download_android_tools.py',
98105
]
99106

100107

101-
def rev(source_dir, dest_dir, dirs_to_rev):
102-
for d in dirs_to_rev:
103-
print "removing directory %s" % d
104-
try:
105-
system(["git", "rm", "-r", d], cwd=dest_dir)
106-
except subprocess.CalledProcessError:
107-
print "Could not remove %s" % d
108-
print "cloning directory %s" % d
109-
files = system(["git", "ls-files", d], cwd=source_dir)
110-
for f in files.splitlines():
111-
source_path = os.path.join(source_dir, f)
112-
if not os.path.isfile(source_path):
113-
continue
114-
dest_path = os.path.join(dest_dir, f)
115-
system(["mkdir", "-p", os.path.dirname(dest_path)], cwd=source_dir)
116-
system(["cp", source_path, dest_path], cwd=source_dir)
117-
system(["git", "add", d], cwd=dest_dir)
118-
119-
for f in files_not_to_roll:
120-
system(["git", "checkout", "HEAD", f], cwd=dest_dir)
121-
122-
system(["git", "add", "."], cwd=dest_dir)
123-
src_commit = system(["git", "rev-parse", "HEAD"], cwd=source_dir).strip()
124-
commit("Update to mojo %s" % src_commit, cwd=dest_dir)
108+
def rev(source_dir, dest_dir, dirs_to_rev, name):
109+
for d in dirs_to_rev:
110+
print "removing directory %s" % d
111+
try:
112+
system(["git", "rm", "-r", d], cwd=dest_dir)
113+
except subprocess.CalledProcessError:
114+
print "Could not remove %s" % d
115+
print "cloning directory %s" % d
116+
files = system(["git", "ls-files", d], cwd=source_dir)
117+
for f in files.splitlines():
118+
source_path = os.path.join(source_dir, f)
119+
if not os.path.isfile(source_path):
120+
continue
121+
dest_path = os.path.join(dest_dir, f)
122+
system(["mkdir", "-p", os.path.dirname(dest_path)], cwd=source_dir)
123+
system(["cp", source_path, dest_path], cwd=source_dir)
124+
system(["git", "add", d], cwd=dest_dir)
125+
126+
for f in files_not_to_roll:
127+
system(["git", "checkout", "HEAD", f], cwd=dest_dir)
128+
129+
system(["git", "add", "."], cwd=dest_dir)
130+
src_commit = system(["git", "rev-parse", "HEAD"], cwd=source_dir).strip()
131+
commit("Update to %s %s" % (name, src_commit), cwd=dest_dir)
125132

126133

127134
def main():
@@ -134,10 +141,17 @@ def main():
134141
args = parser.parse_args()
135142

136143
if args.mojo_dir:
137-
rev(args.mojo_dir, args.dest_dir, dirs_from_mojo)
144+
rev(args.mojo_dir, args.dest_dir, dirs_from_mojo, 'mojo')
138145

139146
if args.chromium_dir:
140-
rev(args.chromium_dir, args.dest_dir, dirs_from_chromium)
147+
rev(args.chromium_dir, args.dest_dir, dirs_from_chromium, 'chromium')
148+
149+
try:
150+
patch.patch_and_filter()
151+
except subprocess.CalledProcessError:
152+
print "ERROR: Roll failed due to a patch not applying"
153+
print "Fix the patch to apply, commit the result, and re-run this script"
154+
return 1
141155

142156
return 0
143157

0 commit comments

Comments
 (0)