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 = {
},
# === 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': {
'packages': [
{
......
.gradle/
.idea/
.settings/
local.properties
buildSrc/.gradle/
buildSrc/build/
# JAR and AAR files will be fetched via CIPD.
libs/*/*.jar
libs/*/*.aar
This diff is collapsed.
Name: Android Deps Repository
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
License: Refer to additional_readme_paths.json
License Android Compatible: yes
......@@ -35,4 +35,4 @@ third_party/android_deps
```
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:
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
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
via cipd.
......@@ -51,7 +51,7 @@ Full steps to add a new third party library:
5. Thoroughly test your change on a clean checkout.
- 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
commands printed out in this step.
......@@ -74,7 +74,7 @@ date is at the bottom.
[owners_link]: http://go/android-deps-owners
[docs_link]: ../../../../docs/adding_to_third_party.md
[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:
The script invokes a Gradle plugin to leverage its dependency resolution
......
......@@ -151,7 +151,7 @@ task setUpRepository(type: BuildConfigGenerator) {
// Paths are relative to the chromium source root.
repositoryPath 'third_party/android_deps'
depsPath 'DEPS'
chromiumSourceRoot '../../../..'
chromiumSourceRoot '../..'
cipdBucket 'chromium'
}
......
......@@ -207,7 +207,7 @@ class BuildConfigGenerator extends DefaultTask {
if (!dependency.visible) {
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")
}
if (dependency.testOnly) sb.append(" testonly = true\n")
......@@ -355,7 +355,7 @@ class BuildConfigGenerator extends DefaultTask {
def sb = new StringBuilder()
// Note: The string we're inserting is nested 1 level, hence the 2 leading spaces. Same
// 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.
def dependencyComparator = { dependency1, dependency2 ->
......
......@@ -3,7 +3,6 @@
# Copyright 2018 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.
"""A script used to manage Google Maven dependencies for Chromium.
This script creates a temporary build directory, where it will, for each
......@@ -43,9 +42,8 @@ import shutil
import subprocess
import zipfile
# Assume this script is stored under tools/android/roll/android_deps/
_CHROMIUM_SRC = os.path.abspath(
os.path.join(__file__, '..', '..', '..', '..', '..'))
# Assume this script is stored under third_party/android_deps/
_CHROMIUM_SRC = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
# Location of the android_deps directory from a root checkout.
_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/
_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/
_ANDROID_DEPS_LICENSE_SUBDIR = _ANDROID_DEPS_SUBDIR + '/licenses'
......@@ -64,18 +65,19 @@ _ANDROID_DEPS_ADDITIONAL_README_PATHS = (
_ANDROID_DEPS_LIBS_SUBDIR = _ANDROID_DEPS_SUBDIR + '/libs'
# 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.
_UPDATED_GIT_FILES = [
'DEPS',
_ANDROID_DEPS_BUILD_GN,
_ANDROID_DEPS_ADDITIONAL_README_PATHS,
'DEPS',
_ANDROID_DEPS_BUILD_GN,
_ANDROID_DEPS_ADDITIONAL_README_PATHS,
]
# If this file exists in an aar file then it is appended to LICENSE
_THIRD_PARTY_LICENSE_FILENAME = 'third_party_licenses.txt'
@contextlib.contextmanager
def BuildDir(dirname=None):
"""Helper function used to manage a build directory.
......@@ -230,8 +232,8 @@ def FindInDirectory(directory, filename_filter):
# - path: Path to cipd.yaml file.
# - name: cipd package name.
# - tag: cipd tag.
CipdPackageInfo = collections.namedtuple(
'CipdPackageInfo', ['path', 'name', 'tag'])
CipdPackageInfo = collections.namedtuple('CipdPackageInfo',
['path', 'name', 'tag'])
# Regular expressions used to extract useful info from cipd.yaml files
# generated by Gradle. See BuildConfigGenerator.groovy:makeCipdYaml()
......@@ -308,39 +310,42 @@ def GenerateCipdUploadCommand(cipd_pkg_info):
A string holding a shell command to upload the package through cipd.
"""
pkg_path, pkg_name, pkg_tag = cipd_pkg_info
return ('(cd "{0}"; '
# Need to skip create step if an instance already exists with the
# same package name and version tag (thus the use of ||).
'cipd describe "{1}" -version "{2}" || '
'cipd create --pkg-def cipd.yaml -tag "{2}")').format(
pkg_path, pkg_name, pkg_tag)
return (
'(cd "{0}"; '
# Need to skip create step if an instance already exists with the
# same package name and version tag (thus the use of ||).
'cipd describe "{1}" -version "{2}" || '
'cipd create --pkg-def cipd.yaml -tag "{2}")').format(
pkg_path, pkg_name, pkg_tag)
def main():
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('--build-dir',
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument(
'--build-dir',
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).')
parser.add_argument('--gradle-wrapper',
help='Path to custom gradle wrapper (auto-detect by default).')
parser.add_argument(
'--build-gradle',
help='Path to build.gradle relative to src/.',
default='tools/android/roll/android_deps/build.gradle')
'--gradle-wrapper',
help='Path to custom gradle wrapper (auto-detect by default).')
parser.add_argument(
'--git-dir', help='Path to git subdir from chromium-dir.', default='.')
parser.add_argument(
'--ignore-licenses',
help='Ignores licenses for these deps.',
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.'
'This will also print a list of commands to upload new and updated '
'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 '
'build.gradle changes. Use this to undo previous --update-all changes.')
parser.add_argument(
......@@ -350,7 +355,7 @@ def main():
# Determine Chromium source tree.
chromium_src = args.chromium_dir
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 = os.path.abspath(chromium_src)
......@@ -362,13 +367,15 @@ def main():
if not os.path.isdir(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
# script. Should not include _UPDATED_GIT_FILES.
copied_paths = {
args.build_gradle:
args.build_gradle,
build_gradle_path:
build_gradle_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:
......@@ -387,15 +394,14 @@ def main():
RunCommand(['rm', '-rf', cipd_dir])
print('# Saving build.gradle content')
build_gradle_path = os.path.join(chromium_src, args.build_gradle)
build_gradle = ReadFile(build_gradle_path)
build_gradle = ReadFile(build_gradle_abs_path)
print('# Resetting and re-syncing workspace. (may take a while).')
RunCommand(['gclient', 'sync', '--reset', '--nohooks', '-r', 'src@HEAD'],
print_stdout=args.debug)
print('# Restoring build.gradle.')
WriteFile(build_gradle_path, build_gradle)
WriteFile(build_gradle_abs_path, build_gradle)
return
missing_files = []
......@@ -410,7 +416,7 @@ def main():
# Path to the gradlew script used to run build.gradle.
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.
aar_py = os.path.join(chromium_src, 'build', 'android', 'gyp', 'aar.py')
......@@ -435,7 +441,7 @@ def main():
gradle_cmd = [
gradle_wrapper_path,
'-b',
os.path.join(build_dir, args.build_gradle),
os.path.join(build_dir, build_gradle_path),
'setupRepository',
'--stacktrace',
]
......@@ -470,7 +476,6 @@ def main():
with open(license_path, 'a') as f:
f.write(z.read(_THIRD_PARTY_LICENSE_FILENAME))
print('# Compare CIPD packages.')
existing_packages = ParseDeps(abs_git_dir, _ANDROID_DEPS_LIBS_SUBDIR)
build_packages = ParseDeps(
......@@ -487,7 +492,7 @@ def main():
build_info = build_packages[pkg]
if existing_info.tag != build_info.tag:
logging.info('U %s (%s -> %s)', pkg, existing_info.tag,
build_info.tag)
build_info.tag)
updated_packages.append(pkg)
else:
logging.info('= %s', pkg) # Unchanged.
......@@ -501,11 +506,12 @@ def main():
if cipd_packages_to_upload:
# TODO(wnwen): Check CIPD to make sure that no other package with the
# same tag exists, print error otherwise.
cipd_commands = [GenerateCipdUploadCommand(build_packages[pkg])
for pkg in cipd_packages_to_upload]
cipd_commands = [
GenerateCipdUploadCommand(build_packages[pkg])
for pkg in cipd_packages_to_upload
]
# Print them to the log for debugging.
logging.info('CIPD update commands\n%s\n',
'\n'.join(cipd_commands))
logging.info('CIPD update commands\n%s\n', '\n'.join(cipd_commands))
if not args.update_all:
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