Commit beef9987 authored by Sam Maier's avatar Sam Maier Committed by Commit Bot

Moved all android_deps scripts into third_party/android_deps

This results in deleting tools/android/roll/android_deps

Change-Id: I701f7621e44630eac87c54b1b790598e09cf3dc9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1985814
Commit-Queue: Sam Maier <smaier@chromium.org>
Reviewed-by: default avatarPeter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728558}
parent 2dfd8cca
...@@ -1580,7 +1580,7 @@ deps = { ...@@ -1580,7 +1580,7 @@ deps = {
}, },
# === ANDROID_DEPS Generated Code Start === # === ANDROID_DEPS Generated Code Start ===
# Generated by //tools/android/roll/android_deps/fetch_all.py # Generated by //third_party/android_deps/fetch_all.py
'src/third_party/android_deps/libs/android_arch_core_common': { 'src/third_party/android_deps/libs/android_arch_core_common': {
'packages': [ 'packages': [
{ {
......
.gradle/
.idea/
.settings/
local.properties
buildSrc/.gradle/
buildSrc/build/
# JAR and AAR files will be fetched via CIPD. # JAR and AAR files will be fetched via CIPD.
libs/*/*.jar libs/*/*.jar
libs/*/*.aar libs/*/*.aar
This diff is collapsed.
Name: Android Deps Repository Name: Android Deps Repository
Short Name: android_deps Short Name: android_deps
URL: https://chromium.googlesource.com/chromium/src/+/master/tools/android/roll/android_deps/README.md URL: https://chromium.googlesource.com/chromium/src/+/master/third_party/android_deps/README.md
Version: 1 Version: 1
License: Refer to additional_readme_paths.json License: Refer to additional_readme_paths.json
License Android Compatible: yes License Android Compatible: yes
...@@ -35,4 +35,4 @@ third_party/android_deps ...@@ -35,4 +35,4 @@ third_party/android_deps
``` ```
Instructions for adding/updating dependencies are in: Instructions for adding/updating dependencies are in:
//tools/android/roll/android_deps/README.md //third_party/android_deps/README.md
...@@ -38,7 +38,7 @@ Full steps to add a new third party library: ...@@ -38,7 +38,7 @@ Full steps to add a new third party library:
problems. The cipd commands output by `fetch_all.py --update-all` already problems. The cipd commands output by `fetch_all.py --update-all` already
check for uniqueness of the tag before uploading a new version. You can check for uniqueness of the tag before uploading a new version. You can
also supply a new suffix in your package using FALLBACK_PROPERTIES in also supply a new suffix in your package using FALLBACK_PROPERTIES in
tools/android/roll/android_deps/buildSrc/src/main/groovy/ChromiumDepGraph.goovy third_party/android_deps/buildSrc/src/main/groovy/ChromiumDepGraph.goovy
4. Run the commands printed at step 3 to create new and updated packages 4. Run the commands printed at step 3 to create new and updated packages
via cipd. via cipd.
...@@ -51,7 +51,7 @@ Full steps to add a new third party library: ...@@ -51,7 +51,7 @@ Full steps to add a new third party library:
5. Thoroughly test your change on a clean checkout. 5. Thoroughly test your change on a clean checkout.
- Run the following command: - Run the following command:
`rm -rf third_party/android_deps/libs/[!O]* && tools/android/roll/android_deps/fetch_all.py --update-all`. `rm -rf third_party/android_deps/libs/[!O]* && third_party/android_deps/fetch_all.py --update-all`.
- This ensures that all your deps are fresh. You do not need to run the - This ensures that all your deps are fresh. You do not need to run the
commands printed out in this step. commands printed out in this step.
...@@ -74,7 +74,7 @@ date is at the bottom. ...@@ -74,7 +74,7 @@ date is at the bottom.
[owners_link]: http://go/android-deps-owners [owners_link]: http://go/android-deps-owners
[docs_link]: ../../../../docs/adding_to_third_party.md [docs_link]: ../../../../docs/adding_to_third_party.md
[android_sdk_link]: https://developer.android.com/studio/terms [android_sdk_link]: https://developer.android.com/studio/terms
[readme_chromium_link]: ../../../../third_party/android_deps/README.chromium [readme_chromium_link]: third_party/android_deps/README.chromium
### Implementation notes: ### Implementation notes:
The script invokes a Gradle plugin to leverage its dependency resolution The script invokes a Gradle plugin to leverage its dependency resolution
......
...@@ -151,7 +151,7 @@ task setUpRepository(type: BuildConfigGenerator) { ...@@ -151,7 +151,7 @@ task setUpRepository(type: BuildConfigGenerator) {
// Paths are relative to the chromium source root. // Paths are relative to the chromium source root.
repositoryPath 'third_party/android_deps' repositoryPath 'third_party/android_deps'
depsPath 'DEPS' depsPath 'DEPS'
chromiumSourceRoot '../../../..' chromiumSourceRoot '../..'
cipdBucket 'chromium' cipdBucket 'chromium'
} }
......
...@@ -207,7 +207,7 @@ class BuildConfigGenerator extends DefaultTask { ...@@ -207,7 +207,7 @@ class BuildConfigGenerator extends DefaultTask {
if (!dependency.visible) { if (!dependency.visible) {
sb.append(" # To remove visibility constraint, add this dependency to\n") sb.append(" # To remove visibility constraint, add this dependency to\n")
sb.append(" # //tools/android/roll/android_deps/build.gradle.\n") sb.append(" # //third_party/android_deps/build.gradle.\n")
sb.append(" visibility = [ \":*\" ]\n") sb.append(" visibility = [ \":*\" ]\n")
} }
if (dependency.testOnly) sb.append(" testonly = true\n") if (dependency.testOnly) sb.append(" testonly = true\n")
...@@ -355,7 +355,7 @@ class BuildConfigGenerator extends DefaultTask { ...@@ -355,7 +355,7 @@ class BuildConfigGenerator extends DefaultTask {
def sb = new StringBuilder() def sb = new StringBuilder()
// Note: The string we're inserting is nested 1 level, hence the 2 leading spaces. Same // Note: The string we're inserting is nested 1 level, hence the 2 leading spaces. Same
// applies to the multiline package declaration string below. // applies to the multiline package declaration string below.
sb.append(" # Generated by //tools/android/roll/android_deps/fetch_all.py") sb.append(" # Generated by //third_party/android_deps/fetch_all.py")
// Comparator to sort the dependencies in alphabetical order. // Comparator to sort the dependencies in alphabetical order.
def dependencyComparator = { dependency1, dependency2 -> def dependencyComparator = { dependency1, dependency2 ->
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
# Copyright 2018 The Chromium Authors. All rights reserved. # Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
"""A script used to manage Google Maven dependencies for Chromium. """A script used to manage Google Maven dependencies for Chromium.
This script creates a temporary build directory, where it will, for each This script creates a temporary build directory, where it will, for each
...@@ -43,9 +42,8 @@ import shutil ...@@ -43,9 +42,8 @@ import shutil
import subprocess import subprocess
import zipfile import zipfile
# Assume this script is stored under tools/android/roll/android_deps/ # Assume this script is stored under third_party/android_deps/
_CHROMIUM_SRC = os.path.abspath( _CHROMIUM_SRC = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
os.path.join(__file__, '..', '..', '..', '..', '..'))
# Location of the android_deps directory from a root checkout. # Location of the android_deps directory from a root checkout.
_ANDROID_DEPS_SUBDIR = 'third_party/android_deps' _ANDROID_DEPS_SUBDIR = 'third_party/android_deps'
...@@ -53,6 +51,9 @@ _ANDROID_DEPS_SUBDIR = 'third_party/android_deps' ...@@ -53,6 +51,9 @@ _ANDROID_DEPS_SUBDIR = 'third_party/android_deps'
# Path to BUILD.gn file under android_deps/ # Path to BUILD.gn file under android_deps/
_ANDROID_DEPS_BUILD_GN = _ANDROID_DEPS_SUBDIR + '/BUILD.gn' _ANDROID_DEPS_BUILD_GN = _ANDROID_DEPS_SUBDIR + '/BUILD.gn'
# Path to build.gradle file under android_deps/
_ANDROID_DEPS_BUILD_GRADLE = _ANDROID_DEPS_SUBDIR + '/build.gradle'
# Path to custom licenses under android_deps/ # Path to custom licenses under android_deps/
_ANDROID_DEPS_LICENSE_SUBDIR = _ANDROID_DEPS_SUBDIR + '/licenses' _ANDROID_DEPS_LICENSE_SUBDIR = _ANDROID_DEPS_SUBDIR + '/licenses'
...@@ -64,18 +65,19 @@ _ANDROID_DEPS_ADDITIONAL_README_PATHS = ( ...@@ -64,18 +65,19 @@ _ANDROID_DEPS_ADDITIONAL_README_PATHS = (
_ANDROID_DEPS_LIBS_SUBDIR = _ANDROID_DEPS_SUBDIR + '/libs' _ANDROID_DEPS_LIBS_SUBDIR = _ANDROID_DEPS_SUBDIR + '/libs'
# Location of the buildSrc directory used implement our gradle task. # Location of the buildSrc directory used implement our gradle task.
_GRADLE_BUILDSRC_PATH = 'tools/android/roll/android_deps/buildSrc' _GRADLE_BUILDSRC_PATH = _ANDROID_DEPS_SUBDIR + '/buildSrc'
# The list of git-controlled files that are checked or updated by this tool. # The list of git-controlled files that are checked or updated by this tool.
_UPDATED_GIT_FILES = [ _UPDATED_GIT_FILES = [
'DEPS', 'DEPS',
_ANDROID_DEPS_BUILD_GN, _ANDROID_DEPS_BUILD_GN,
_ANDROID_DEPS_ADDITIONAL_README_PATHS, _ANDROID_DEPS_ADDITIONAL_README_PATHS,
] ]
# If this file exists in an aar file then it is appended to LICENSE # If this file exists in an aar file then it is appended to LICENSE
_THIRD_PARTY_LICENSE_FILENAME = 'third_party_licenses.txt' _THIRD_PARTY_LICENSE_FILENAME = 'third_party_licenses.txt'
@contextlib.contextmanager @contextlib.contextmanager
def BuildDir(dirname=None): def BuildDir(dirname=None):
"""Helper function used to manage a build directory. """Helper function used to manage a build directory.
...@@ -230,8 +232,8 @@ def FindInDirectory(directory, filename_filter): ...@@ -230,8 +232,8 @@ def FindInDirectory(directory, filename_filter):
# - path: Path to cipd.yaml file. # - path: Path to cipd.yaml file.
# - name: cipd package name. # - name: cipd package name.
# - tag: cipd tag. # - tag: cipd tag.
CipdPackageInfo = collections.namedtuple( CipdPackageInfo = collections.namedtuple('CipdPackageInfo',
'CipdPackageInfo', ['path', 'name', 'tag']) ['path', 'name', 'tag'])
# Regular expressions used to extract useful info from cipd.yaml files # Regular expressions used to extract useful info from cipd.yaml files
# generated by Gradle. See BuildConfigGenerator.groovy:makeCipdYaml() # generated by Gradle. See BuildConfigGenerator.groovy:makeCipdYaml()
...@@ -308,39 +310,42 @@ def GenerateCipdUploadCommand(cipd_pkg_info): ...@@ -308,39 +310,42 @@ def GenerateCipdUploadCommand(cipd_pkg_info):
A string holding a shell command to upload the package through cipd. A string holding a shell command to upload the package through cipd.
""" """
pkg_path, pkg_name, pkg_tag = cipd_pkg_info pkg_path, pkg_name, pkg_tag = cipd_pkg_info
return ('(cd "{0}"; ' return (
# Need to skip create step if an instance already exists with the '(cd "{0}"; '
# same package name and version tag (thus the use of ||). # Need to skip create step if an instance already exists with the
'cipd describe "{1}" -version "{2}" || ' # same package name and version tag (thus the use of ||).
'cipd create --pkg-def cipd.yaml -tag "{2}")').format( 'cipd describe "{1}" -version "{2}" || '
pkg_path, pkg_name, pkg_tag) 'cipd create --pkg-def cipd.yaml -tag "{2}")').format(
pkg_path, pkg_name, pkg_tag)
def main(): def main():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description=__doc__, description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument(
parser.add_argument('--build-dir', '--build-dir',
help='Path to build directory (default is temporary directory).') help='Path to build directory (default is temporary directory).')
parser.add_argument('--chromium-dir', parser.add_argument(
'--chromium-dir',
help='Path to Chromium source tree (auto-detect by default).') help='Path to Chromium source tree (auto-detect by default).')
parser.add_argument('--gradle-wrapper',
help='Path to custom gradle wrapper (auto-detect by default).')
parser.add_argument( parser.add_argument(
'--build-gradle', '--gradle-wrapper',
help='Path to build.gradle relative to src/.', help='Path to custom gradle wrapper (auto-detect by default).')
default='tools/android/roll/android_deps/build.gradle')
parser.add_argument( parser.add_argument(
'--git-dir', help='Path to git subdir from chromium-dir.', default='.') '--git-dir', help='Path to git subdir from chromium-dir.', default='.')
parser.add_argument( parser.add_argument(
'--ignore-licenses', '--ignore-licenses',
help='Ignores licenses for these deps.', help='Ignores licenses for these deps.',
action='store_true') action='store_true')
parser.add_argument('--update-all', action='store_true', parser.add_argument(
'--update-all',
action='store_true',
help='Update current checkout in case of build.gradle changes.' help='Update current checkout in case of build.gradle changes.'
'This will also print a list of commands to upload new and updated ' 'This will also print a list of commands to upload new and updated '
'packages through cipd, if needed.') 'packages through cipd, if needed.')
parser.add_argument('--reset-workspace', action='store_true', parser.add_argument(
'--reset-workspace',
action='store_true',
help='Reset your Chromium workspace to its HEAD state, but preserves ' help='Reset your Chromium workspace to its HEAD state, but preserves '
'build.gradle changes. Use this to undo previous --update-all changes.') 'build.gradle changes. Use this to undo previous --update-all changes.')
parser.add_argument( parser.add_argument(
...@@ -350,7 +355,7 @@ def main(): ...@@ -350,7 +355,7 @@ def main():
# Determine Chromium source tree. # Determine Chromium source tree.
chromium_src = args.chromium_dir chromium_src = args.chromium_dir
if not chromium_src: if not chromium_src:
# Assume this script is stored under tools/android/roll/android_deps/ # Assume this script is stored under third_party/android_deps/
chromium_src = _CHROMIUM_SRC chromium_src = _CHROMIUM_SRC
chromium_src = os.path.abspath(chromium_src) chromium_src = os.path.abspath(chromium_src)
...@@ -362,13 +367,15 @@ def main(): ...@@ -362,13 +367,15 @@ def main():
if not os.path.isdir(abs_git_dir): if not os.path.isdir(abs_git_dir):
raise Exception('Not a directory: ' + abs_git_dir) raise Exception('Not a directory: ' + abs_git_dir)
build_gradle_path = os.path.join(args.git_dir, _ANDROID_DEPS_BUILD_GRADLE)
build_gradle_abs_path = os.path.join(abs_git_dir, _ANDROID_DEPS_BUILD_GRADLE)
# The list of files and dirs that are copied to the build directory by this # The list of files and dirs that are copied to the build directory by this
# script. Should not include _UPDATED_GIT_FILES. # script. Should not include _UPDATED_GIT_FILES.
copied_paths = { copied_paths = {
args.build_gradle: build_gradle_path:
args.build_gradle, build_gradle_path,
_GRADLE_BUILDSRC_PATH: _GRADLE_BUILDSRC_PATH:
os.path.join(os.path.dirname(args.build_gradle), "buildSrc"), os.path.join(args.git_dir, _ANDROID_DEPS_SUBDIR, "buildSrc"),
} }
if not args.ignore_licenses: if not args.ignore_licenses:
...@@ -387,15 +394,14 @@ def main(): ...@@ -387,15 +394,14 @@ def main():
RunCommand(['rm', '-rf', cipd_dir]) RunCommand(['rm', '-rf', cipd_dir])
print('# Saving build.gradle content') print('# Saving build.gradle content')
build_gradle_path = os.path.join(chromium_src, args.build_gradle) build_gradle = ReadFile(build_gradle_abs_path)
build_gradle = ReadFile(build_gradle_path)
print('# Resetting and re-syncing workspace. (may take a while).') print('# Resetting and re-syncing workspace. (may take a while).')
RunCommand(['gclient', 'sync', '--reset', '--nohooks', '-r', 'src@HEAD'], RunCommand(['gclient', 'sync', '--reset', '--nohooks', '-r', 'src@HEAD'],
print_stdout=args.debug) print_stdout=args.debug)
print('# Restoring build.gradle.') print('# Restoring build.gradle.')
WriteFile(build_gradle_path, build_gradle) WriteFile(build_gradle_abs_path, build_gradle)
return return
missing_files = [] missing_files = []
...@@ -410,7 +416,7 @@ def main(): ...@@ -410,7 +416,7 @@ def main():
# Path to the gradlew script used to run build.gradle. # Path to the gradlew script used to run build.gradle.
gradle_wrapper_path = args.gradle_wrapper or os.path.join( gradle_wrapper_path = args.gradle_wrapper or os.path.join(
chromium_src, 'third_party', 'gradle_wrapper', 'gradlew') chromium_src, 'third_party', 'gradle_wrapper', 'gradlew')
# Path to the aar.py script used to generate .info files. # Path to the aar.py script used to generate .info files.
aar_py = os.path.join(chromium_src, 'build', 'android', 'gyp', 'aar.py') aar_py = os.path.join(chromium_src, 'build', 'android', 'gyp', 'aar.py')
...@@ -435,7 +441,7 @@ def main(): ...@@ -435,7 +441,7 @@ def main():
gradle_cmd = [ gradle_cmd = [
gradle_wrapper_path, gradle_wrapper_path,
'-b', '-b',
os.path.join(build_dir, args.build_gradle), os.path.join(build_dir, build_gradle_path),
'setupRepository', 'setupRepository',
'--stacktrace', '--stacktrace',
] ]
...@@ -470,7 +476,6 @@ def main(): ...@@ -470,7 +476,6 @@ def main():
with open(license_path, 'a') as f: with open(license_path, 'a') as f:
f.write(z.read(_THIRD_PARTY_LICENSE_FILENAME)) f.write(z.read(_THIRD_PARTY_LICENSE_FILENAME))
print('# Compare CIPD packages.') print('# Compare CIPD packages.')
existing_packages = ParseDeps(abs_git_dir, _ANDROID_DEPS_LIBS_SUBDIR) existing_packages = ParseDeps(abs_git_dir, _ANDROID_DEPS_LIBS_SUBDIR)
build_packages = ParseDeps( build_packages = ParseDeps(
...@@ -487,7 +492,7 @@ def main(): ...@@ -487,7 +492,7 @@ def main():
build_info = build_packages[pkg] build_info = build_packages[pkg]
if existing_info.tag != build_info.tag: if existing_info.tag != build_info.tag:
logging.info('U %s (%s -> %s)', pkg, existing_info.tag, logging.info('U %s (%s -> %s)', pkg, existing_info.tag,
build_info.tag) build_info.tag)
updated_packages.append(pkg) updated_packages.append(pkg)
else: else:
logging.info('= %s', pkg) # Unchanged. logging.info('= %s', pkg) # Unchanged.
...@@ -501,11 +506,12 @@ def main(): ...@@ -501,11 +506,12 @@ def main():
if cipd_packages_to_upload: if cipd_packages_to_upload:
# TODO(wnwen): Check CIPD to make sure that no other package with the # TODO(wnwen): Check CIPD to make sure that no other package with the
# same tag exists, print error otherwise. # same tag exists, print error otherwise.
cipd_commands = [GenerateCipdUploadCommand(build_packages[pkg]) cipd_commands = [
for pkg in cipd_packages_to_upload] GenerateCipdUploadCommand(build_packages[pkg])
for pkg in cipd_packages_to_upload
]
# Print them to the log for debugging. # Print them to the log for debugging.
logging.info('CIPD update commands\n%s\n', logging.info('CIPD update commands\n%s\n', '\n'.join(cipd_commands))
'\n'.join(cipd_commands))
if not args.update_all: if not args.update_all:
if not (deleted_packages or new_packages or updated_packages): if not (deleted_packages or new_packages or updated_packages):
......
.gradle/
.idea/
.settings/
local.properties
buildSrc/.gradle/
buildSrc/build/
agrieve@chromium.org
jbudorick@chromium.org
smaier@chromium.org
wnwen@chromium.org
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment