0

[sdk] Manage Android SDK CIPD dependencies into DEPS

Manage Android SDK binary deps via CIPD logic. Move CIPD dependencies
in DEPS.

Adding cipd_*.yaml files for SDK packages, which are used to create and
upload the CIPD packages to service url.

Changing config.gni to point the android sdk root to
//third_party/android_sdk/public.

Split package /sources out to third_party/android_sdk/sources due to
different gclient condition.

Modify update_sdk.py to
1) Support changing pkg version in DEPS
2) Change --sdk-root default path for sources
3) Fix bugs


Bug: 659808
Change-Id: Ia9bafae24a15d8b1c917cf8c0953eb74b8daa0db
Reviewed-on: https://chromium-review.googlesource.com/807594
Reviewed-by: Grace Kloba <klobag@chromium.org>
Reviewed-by: John Budorick <jbudorick@chromium.org>
Commit-Queue: Shenghua Zhang <shenghuazhang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#550297}
This commit is contained in:
Shenghua Zhang
2018-04-12 19:11:49 +00:00
committed by Commit Bot
parent 8d42e256c0
commit cbe64ba2cc
13 changed files with 509 additions and 33 deletions

74
DEPS

@ -41,6 +41,10 @@ vars = {
# purposes.
'checkout_configuration': 'default',
# By default, do not check out android sdk sources. This can be overridden
# e.g. with custom_vars.
'checkout_android_sdk_sources': False,
# Check out and download nacl by default. This can be disabled e.g. with
# custom_vars.
'checkout_nacl': True,
@ -159,6 +163,34 @@ vars = {
# the commit queue can handle CLs rolling feed
# and whatever else without interference from each other.
'feed_revision': '3a782b5dac6c8f2f927613d3f37b8cad72f934b2',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling android_sdk_build-tools_version
# and whatever else without interference from each other.
'android_sdk_build-tools_version': 'version:27.0.3-cr0',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling android_sdk_emulator_version
# and whatever else without interference from each other.
'android_sdk_emulator_version': 'version:27.1.12-cr0',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling android_sdk_extras_version
# and whatever else without interference from each other.
'android_sdk_extras_version': 'version:47.0.0-cr0',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling android_sdk_platform-tools_version
# and whatever else without interference from each other.
'android_sdk_platform-tools_version': 'version:27.0.1-cr0',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling android_sdk_platforms_version
# and whatever else without interference from each other.
'android_sdk_platforms_version': 'version:android-27-cr0',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling android_sdk_sources_version
# and whatever else without interference from each other.
'android_sdk_sources_version': 'version:android-27-cr1',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling android_sdk_tools_version
# and whatever else without interference from each other.
'android_sdk_tools_version': 'version:26.1.1-cr0',
}
# Only these hosts are allowed for dependencies in this DEPS file.
@ -332,6 +364,48 @@ deps = {
'condition': 'checkout_android',
},
'src/third_party/android_sdk/public': {
'packages': [
{
'package': 'chromium/third_party/android_sdk/public/build-tools',
'version': Var('android_sdk_build-tools_version'),
},
{
'package': 'chromium/third_party/android_sdk/public/emulator',
'version': Var('android_sdk_emulator_version'),
},
{
'package': 'chromium/third_party/android_sdk/public/extras',
'version': Var('android_sdk_extras_version'),
},
{
'package': 'chromium/third_party/android_sdk/public/platform-tools',
'version': Var('android_sdk_platform-tools_version'),
},
{
'package': 'chromium/third_party/android_sdk/public/platforms',
'version': Var('android_sdk_platforms_version'),
},
{
'package': 'chromium/third_party/android_sdk/public/tools',
'version': Var('android_sdk_tools_version'),
},
],
'condition': 'checkout_android',
'dep_type': 'cipd',
},
'src/third_party/android_sdk/sources': {
'packages': [
{
'package': 'chromium/third_party/android_sdk/sources',
'version': Var('android_sdk_sources_version'),
},
],
'condition': 'checkout_android_sdk_sources',
'dep_type': 'cipd',
},
'src/third_party/angle':
Var('chromium_git') + '/angle/angle.git' + '@' + Var('angle_revision'),

@ -7,6 +7,8 @@
/adobe/flash/symbols
/amd/
/android_ndk/
/android_sdk/public/
/android_sdk/sources/
/android_protobuf/src
/android_support_test_runner/lib/
/android_system_sdk/*.jar

217
third_party/android_sdk/LICENSE vendored Normal file

@ -0,0 +1,217 @@
Notice for all the files in this folder.
------------------------------------------------------------
Copyright (c) 2005-2008, The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2011 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

11
third_party/android_sdk/OWNERS vendored Normal file

@ -0,0 +1,11 @@
agrieve@chromium.org
jbudorick@chromium.org
kerz@chromium.org
michaelbai@chromium.org
primiano@chromium.org
rmcilroy@chromium.org
sgurun@chromium.org
shenghuazhang@chromium.org
wangxianzhu@chromium.org
wnwen@chromium.org
yfriedman@chromium.org

24
third_party/android_sdk/README.chromium vendored Normal file

@ -0,0 +1,24 @@
Name: Android SDK
URL: http://developer.android.com/sdk/index.html
Version: 27
Android SDK Build-tools 27.0.3
Android SDK Emulator 27.1.12
Android SDK Extras 47.0.0
Android SDK Platform-tools 27.0.1
Android SDK Platform API 27
Android SDK Sources 27
Android SDK Tools 26.1.1
Security Critical: no
License: Apache Version 2.0
Description:
The Android SDK provide API libraries and developer tools necessary to
build, test and debug for Android.
Local Modifications:
-In public/
- Included previous version of tools/emma_device.jar, tools/emma.jar.
- Included the Android support library and required extras packages.
- Added extras/chromium/.
No other modifications has been made to the public Android SDK/NDK.

@ -0,0 +1,10 @@
# Copyright 2017 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.
# To create CIPD package run the following command.
# cipd create --pkg-def cipd_build-tools.yaml -tag version:$version
package: chromium/third_party/android_sdk/public/build-tools
description: build-tools Android SDK Build Tools
data:
- dir: public/build-tools

@ -0,0 +1,10 @@
# Copyright 2017 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.
# To create CIPD package run the following command.
# cipd create --pkg-def cipd_emulator.yaml -tag version:$version
package: chromium/third_party/android_sdk/public/emulator
description: emulator Android SDK Emulator library
data:
- dir: public/emulator

@ -0,0 +1,10 @@
# Copyright 2017 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.
# To create CIPD package run the following command.
# cipd create --pkg-def cipd_extras.yaml -tag version:$version
package: chromium/third_party/android_sdk/public/extras
description: extras Android SDK Extras library
data:
- dir: public/extras

@ -0,0 +1,10 @@
# Copyright 2017 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.
# To create CIPD package run the following command.
# cipd create --pkg-def cipd_platform-tools.yaml -tag version:$version
package: chromium/third_party/android_sdk/public/platform-tools
description: platform-tools Android SDK Platform-tools library
data:
- dir: public/platform-tools

@ -0,0 +1,10 @@
# Copyright 2017 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.
# To create CIPD package run the following command.
# cipd create --pkg-def cipd_platform.yaml -tag version:$version
package: chromium/third_party/android_sdk/public/platforms
description: platforms Android SDK Platforms library
data:
- dir: public/platforms

@ -0,0 +1,10 @@
# Copyright 2017 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.
# To create CIPD package run the following command.
# cipd create --pkg-def cipd_sources.yaml -tag version:$version
package: chromium/third_party/android_sdk/sources
description: sources Android SDK Sources library
data:
- dir: sources/sources

10
third_party/android_sdk/cipd_tools.yaml vendored Normal file

@ -0,0 +1,10 @@
# Copyright 2017 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.
# To create CIPD package run the following command.
# cipd create --pkg-def cipd_tools.yaml -tag version:$version
package: chromium/third_party/android_sdk/public/tools
description: tools Android SDK Tools library
data:
- dir: public/tools

@ -35,6 +35,7 @@
"""
import argparse
import contextlib
import os
import re
import shutil
@ -46,7 +47,14 @@ import tempfile
_SRC_ROOT = os.path.realpath(
os.path.join(os.path.dirname(__file__), '..', '..', '..'))
_SDK_ROOT = os.path.join(_SRC_ROOT, 'third_party', 'android_sdk', 'public')
_SRC_DEPS_PATH = os.path.join(_SRC_ROOT, 'DEPS')
_SDK_PUBLIC_ROOT = os.path.join(_SRC_ROOT, 'third_party', 'android_sdk',
'public')
_SDK_SOURCES_ROOT = os.path.join(_SRC_ROOT, 'third_party', 'android_sdk',
'sources')
# TODO(shenghuazhang): Update sdkmanager path when gclient can download SDK
# via CIPD: crug/789809
@ -56,7 +64,7 @@ _SDKMANAGER_PATH = os.path.join(_SRC_ROOT, 'third_party', 'android_tools',
_ANDROID_CONFIG_GNI_PATH = os.path.join(_SRC_ROOT, 'build', 'config',
'android', 'config.gni')
_TOOLS_LIB_PATH = os.path.join(_SDK_ROOT, 'tools', 'lib')
_TOOLS_LIB_PATH = os.path.join(_SDK_PUBLIC_ROOT, 'tools', 'lib')
_DEFAULT_DOWNLOAD_PACKAGES = [
'build-tools',
@ -65,10 +73,12 @@ _DEFAULT_DOWNLOAD_PACKAGES = [
'tools'
]
# TODO(shenghuazhang): Search package versions from available packages through
# the sdkmanager, instead of hardcoding the package names w/ version.
_DEFAULT_PACKAGES_DICT = {
'build-tools': 'build-tools;27.0.3',
'platforms': 'platforms;android-27',
'sources': 'sources;android-26',
'sources': 'sources;android-27',
}
_GN_ARGUMENTS_TO_UPDATE = {
@ -90,7 +100,7 @@ def _DownloadSdk(arguments):
If package isn't provided, update build-tools, platform-tools, platforms,
and tools.
"""
for pkg in arguments.packages:
for pkg in arguments.package:
# If package is not a sdk-style path, try to match a default path to it.
if pkg in _DEFAULT_PACKAGES_DICT:
print 'Coercing %s to %s' % (pkg, _DEFAULT_PACKAGES_DICT[pkg])
@ -108,7 +118,7 @@ def _DownloadSdk(arguments):
subprocess.check_call(download_sdk_cmd)
def _FindPackageVersion(package):
def _FindPackageVersion(package, sdk_root):
"""Find sdk package version
Two options for package version:
@ -118,8 +128,10 @@ def _FindPackageVersion(package):
"""
sdkmanager_list_cmd = [
_SDKMANAGER_PATH,
'--list'
'--list',
'--sdk_root=%s' % sdk_root,
]
if package in _DEFAULT_PACKAGES_DICT:
# Get the version after ';' from package name
package = _DEFAULT_PACKAGES_DICT[package]
@ -143,14 +155,13 @@ def _FindPackageVersion(package):
# by the first new line, the check loop should be ended when reaches a '\n'.
output = subprocess.check_output(sdkmanager_list_cmd)
for line in output.splitlines():
if package in line:
if ' ' + package + ' ' in line:
# if found package path, catch its version which in the first '|...|'
return line.split('|')[1].strip()
if line == '\n': # Reaches the end of 'Installed packages' list
break
raise Exception('Cannot find the version of package %s' % package)
def _ReplaceVersionInFile(file_path, pattern, version, dry_run=False):
"""Replace the version of sdk package argument in file.
@ -165,21 +176,18 @@ def _ReplaceVersionInFile(file_path, pattern, version, dry_run=False):
dry_run: Bool. To show what packages would be created and packages, without
actually doing either.
"""
try:
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
with open(file_path) as f:
for line in f:
new_line = re.sub(pattern, r'\g<1>"%s"\n' % version, line)
if new_line != line:
print ' Note: file %s argument %s would be updated to "%s".' % (
file_path, line.strip(), version)
temp_file.write(new_line)
with tempfile.NamedTemporaryFile() as temp_file:
with open(file_path) as f:
for line in f:
new_line = re.sub(pattern, r'\g<1>"%s"\n' % version, line)
if new_line != line:
print (' Note: file "%s" argument ' % file_path +
'"%s" would be updated to "%s".' % (line.strip(), version))
temp_file.write(new_line)
if not dry_run:
temp_file.flush()
shutil.move(temp_file.name, file_path)
finally:
if os.path.exists(temp_file.name):
os.remove(temp_file.name)
temp_file.delete = False
def UploadSdkPackage(sdk_root, dry_run, service_url, package, yaml_file,
@ -205,8 +213,8 @@ def UploadSdkPackage(sdk_root, dry_run, service_url, package, yaml_file,
raise IOError('Cannot find .yaml file for package %s' % package)
if dry_run:
print 'This `package` command (without -n/--dry-run) would create and',
print 'upload the package %s version:%s to CIPD.' % (package, pkg_version)
print ('This `package` command (without -n/--dry-run) would create and ' +
'upload the package %s version:%s to CIPD.' % (package, pkg_version))
else:
upload_sdk_cmd = [
'cipd', 'create',
@ -220,6 +228,65 @@ def UploadSdkPackage(sdk_root, dry_run, service_url, package, yaml_file,
subprocess.check_call(upload_sdk_cmd)
@contextlib.contextmanager
def UpdateDepsFile(package, pkg_version, deps_path, dry_run,
release_version=None):
"""Find the sdk pkg version in DEPS and modify it as cipd uploading version.
TODO(shenghuazhang): use DEPS edition operations after issue crbug.com/760633
fixed.
DEPS file hooks sdk package with version with suffix -crX, e.g. '26.0.2-cr1'.
If pkg_version is the base number of the existing version in DEPS, e.g.
'26.0.2', return '26.0.2-cr2' as the version uploading to CIPD. If not the
base number, return ${pkg_version}-cr0.
Args:
package: The name of the package.
pkg_version: The new version of the package.
deps_path: Path to deps file which gclient hooks sdk pkg w/ versions.
dry_run: Bool. To show what packages would be created and packages, without
actually doing either.
release_version: Android sdk release version e.g. 'o_mr1', 'p'.
"""
var_package = package
if release_version:
var_package = release_version + '_' + var_package
package_var_pattern = re.compile(
# Match the argument with "'sdk_*_version': 'version:" with whitespaces.
r'(^\s*\'android_sdk_%s_version\'\s*:\s*\'version:)' % var_package +
# version number with right single quote. E.g. 27.0.1-cr0.
r'([-\w\s.]+)'
# End of string
r'(\',?$)'
)
with tempfile.NamedTemporaryFile() as temp_file:
with open(deps_path) as f:
for line in f:
new_line = line
found = re.match(package_var_pattern, line)
if found:
# Check if pkg_version as base version already exists in deps
deps_version = found.group(2)
match = re.match(r'%s-cr([\d+])' % pkg_version, deps_version)
suffix_number = 0
if match:
suffix_number = 1 + int(match.group(1))
version = '%s-cr%d' % (pkg_version, suffix_number)
new_line = re.sub(package_var_pattern, r'\g<1>%s\g<3>' % version,
line)
print (' Note: deps file "%s" argument ' % deps_path +
'"%s" would be updated to "%s".' % (line.strip(), version))
temp_file.write(new_line)
yield version
if not dry_run:
temp_file.flush()
shutil.move(temp_file.name, deps_path)
temp_file.delete = False
def ChangeVersionInGNI(package, arg_version, gn_args_dict, gni_file_path,
dry_run):
@ -278,14 +345,21 @@ def _UploadSdkPackage(arguments):
for package in packages:
pkg_version = arguments.version
if not pkg_version:
pkg_version = _FindPackageVersion(package)
UploadSdkPackage(arguments.sdk_root, arguments.dry_run,
arguments.service_url, package, arguments.yaml_file,
pkg_version, arguments.verbose)
pkg_version = _FindPackageVersion(package, arguments.sdk_root)
# Upload SDK package to cipd, and update the package version hooking
# in DEPS file.
with UpdateDepsFile(package, pkg_version, _SRC_DEPS_PATH,
arguments.dry_run) as deps_pkg_version:
UploadSdkPackage(os.path.join(arguments.sdk_root, '..'),
arguments.dry_run, arguments.service_url, package,
arguments.yaml_file, deps_pkg_version,
arguments.verbose)
if package in _GN_ARGUMENTS_TO_UPDATE:
# Update the package version config in gn file
arg_version = _GetArgVersion(pkg_version, package)
ChangeVersionInGNI(package, pkg_version, _GN_ARGUMENTS_TO_UPDATE,
ChangeVersionInGNI(package, arg_version, _GN_ARGUMENTS_TO_UPDATE,
_ANDROID_CONFIG_GNI_PATH, arguments.dry_run)
@ -302,16 +376,15 @@ def main():
download_parser.set_defaults(func=_DownloadSdk)
download_parser.add_argument(
'-p',
'--packages',
nargs='+',
'--package',
nargs=1,
default=_DEFAULT_DOWNLOAD_PACKAGES,
help='The packages of the SDK needs to be installed/updated. ' +
help='The package of the SDK needs to be installed/updated. ' +
'Note that package name should be a sdk-style path e.g. ' +
'"platforms;android-27" or "platform-tools". If package ' +
'is not specified, update "build-tools;27.0.3", "tools" ' +
'"platform-tools" and "platforms;android-27" by default.')
download_parser.add_argument('--sdk-root',
default=_SDK_ROOT,
help='base path to the Android SDK root')
download_parser.add_argument('-v', '--verbose',
action='store_true',
@ -346,7 +419,6 @@ def main():
help='The url of the CIPD service.',
default='https://chrome-infra-packages.appspot.com')
package_parser.add_argument('--sdk-root',
default=_SDK_ROOT,
help='base path to the Android SDK root')
package_parser.add_argument('-v', '--verbose',
action='store_true',
@ -354,6 +426,12 @@ def main():
args = parser.parse_args()
if not args.sdk_root:
if args.package and 'sources' in args.package:
args.sdk_root = _SDK_SOURCES_ROOT
else:
args.sdk_root = _SDK_PUBLIC_ROOT
args.func(args)