diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-01-10 18:46:37 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-01-10 18:46:37 +0000 |
commit | 6ec24e7254be757c4c01190a0e0ec57545dd421f (patch) | |
tree | 2860459c37374e449cee13ad20d0821073324604 | |
parent | 43fda90c548a6572170b0758c2af40b8f7e2948e (diff) | |
parent | 6deded3e5b416638a9356ae530102f4377827f70 (diff) | |
download | cronet-aml_tz5_341510010.tar.gz |
Snap for 11296156 from 6deded3e5b416638a9356ae530102f4377827f70 to mainline-tzdata5-releaseaml_tz5_341510070aml_tz5_341510050aml_tz5_341510010aml_tz5_341510010
Change-Id: I6bde4d9ed2420c6e4eb645c01b6f052c633fb579
-rw-r--r-- | android/tools/import/copy.bara.sky | 132 | ||||
-rwxr-xr-x | android/tools/import/import_cronet.sh | 146 |
2 files changed, 278 insertions, 0 deletions
diff --git a/android/tools/import/copy.bara.sky b/android/tools/import/copy.bara.sky new file mode 100644 index 000000000..42dd40273 --- /dev/null +++ b/android/tools/import/copy.bara.sky @@ -0,0 +1,132 @@ +# Copyright 2023 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. + +common_excludes = [ + # Exclude all Android build files + "**/Android.bp", + "**/Android.mk", + + # Exclude existing *OWNERS files + "**/*OWNERS", + "**/.git/**", + "**/.gitignore", +] + +cronet_origin_files = glob( + include = [ + "base/**", + "build/**", + "build/buildflag.h", + "chrome/VERSION", + "components/cronet/**", + "components/metrics/**", + # See https://chromium-review.googlesource.com/c/chromium/src/+/4896104 + "components/miracle_parameter/**", + "components/nacl/**", + "components/prefs/**", + "crypto/**", + "ipc/**", + "net/**", + # Note: Only used for tests. + "testing/**", + "url/**", + "LICENSE", + ], + exclude = common_excludes + [ + # Per aosp/2367109 + "build/android/CheckInstallApk-debug.apk", + "build/android/unused_resources/**", + "build/linux/**", + + # Per aosp/2374766 + "components/cronet/ios/**", + "components/cronet/native/**", + + # Per aosp/2399270 + "testing/buildbot/**", + + # Exclude all third-party directories. Those are specified explicitly + # below, so no dependency can accidentally creep in. + "**/third_party/**", + ], +) + glob( + # Explicitly include third-party dependencies. + # Note: some third-party dependencies include a third_party folder within + # them. So far, this has not become a problem. + include = [ + "base/third_party/cityhash/**", + "base/third_party/cityhash_v103/**", + "base/third_party/double_conversion/**", + "base/third_party/dynamic_annotations/**", + "base/third_party/icu/**", + "base/third_party/nspr/**", + "base/third_party/superfasthash/**", + "base/third_party/valgrind/**", + # Those are temporarily needed until Chromium finish the migration + # of libc++[abi] + "buildtools/third_party/libc++/**", + "buildtools/third_party/libc++abi/**", + # Note: Only used for tests. + "net/third_party/nist-pkits/**", + "net/third_party/quiche/**", + "net/third_party/uri_template/**", + "third_party/abseil-cpp/**", + "third_party/android_ndk/sources/android/cpufeatures/**", + # See https://chromium-review.googlesource.com/c/chromium/src/+/4885470 + # Note: Only used for tests. + "third_party/anonymous_tokens/**", + "third_party/ashmem/**", + "third_party/boringssl/**", + "third_party/brotli/**", + # Note: Only used for tests. + "third_party/ced/**", + "third_party/cpu_features/**", + # Note: Only used for tests. + "third_party/google_benchmark/**", + # Note: Only used for tests. + "third_party/googletest/**", + "third_party/icu/**", + "third_party/jni_zero/**", + "third_party/libc++/**", + "third_party/libc++abi/**", + "third_party/libevent/**", + # Note: Only used for tests. + "third_party/libxml/**", + # Note: Only used for tests. + "third_party/lss/**", + "third_party/metrics_proto/**", + "third_party/modp_b64/**", + "third_party/protobuf/**", + # Note: Only used for tests. + "third_party/quic_trace/**", + # Note: Cronet currently uses Android's zlib + # "third_party/zlib/**", + "url/third_party/mozilla/**", + ], + exclude = common_excludes, +) + +core.workflow( + name = "import_cronet", + authoring = authoring.overwrite("Cronet Mainline Eng <cronet-mainline-eng+copybara@google.com>"), + # Origin folder is specified via source_ref argument, see import_cronet.sh + origin = folder.origin(), + origin_files = cronet_origin_files, + destination = git.destination( + # The destination URL is set by the invoking script. + url = "overwritten/by/script", + push = "upstream-import", + ), + mode = "SQUASH", +) diff --git a/android/tools/import/import_cronet.sh b/android/tools/import/import_cronet.sh new file mode 100755 index 000000000..0f04af741 --- /dev/null +++ b/android/tools/import/import_cronet.sh @@ -0,0 +1,146 @@ +#!/bin/bash + +# Copyright 2023 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. + +# Script to invoke copybara locally to import Cronet into Android. +# Inputs: +# Environment: +# ANDROID_BUILD_TOP: path the root of the current Android directory. +# Arguments: +# -l rev: The last revision that was imported. +# Optional Arguments: +# -n rev: The new revision to import. +# -f: Force copybara to ignore a failure to find the last imported revision. + +set -e -x + +OPTSTRING=fl:n: + +usage() { + cat <<EOF +Usage: import_cronet.sh -n new-rev [-l last-rev] [-f] +EOF + exit 1 +} + +COPYBARA_FOLDER_ORIGIN="/tmp/copybara-origin" + +####################################### +# Create local upstream-import branch in external/cronet. +# Globals: +# ANDROID_BUILD_TOP +# Arguments: +# none +####################################### +setup_upstream_import_branch() { + local git_dir="${ANDROID_BUILD_TOP}/external/cronet" + + (cd "${git_dir}" && git fetch aosp upstream-import:upstream-import) +} + +####################################### +# Setup folder.origin for copybara inside /tmp +# Globals: +# COPYBARA_FOLDER_ORIGIN +# Arguments: +# new_rev, string +####################################### +setup_folder_origin() ( + local _new_rev=$1 + mkdir -p "${COPYBARA_FOLDER_ORIGIN}" + cd "${COPYBARA_FOLDER_ORIGIN}" + + if [ -d src ]; then + (cd src && git fetch --tags && git checkout "${_new_rev}") + else + # For this to work _new_rev must be a branch or a tag. + git clone --depth=1 --branch "${_new_rev}" https://chromium.googlesource.com/chromium/src.git + fi + + + cat <<EOF >.gclient +solutions = [ + { + "name": "src", + "url": "https://chromium.googlesource.com/chromium/src.git", + "managed": False, + "custom_deps": {}, + "custom_vars": {}, + }, +] +target_os = ["android"] +EOF + cd src + # Set appropriate gclient flags to speed up syncing. + gclient sync \ + --no-history \ + --shallow \ + --delete_unversioned_trees +) + +####################################### +# Runs the copybara import of Chromium +# Globals: +# ANDROID_BUILD_TOP +# COPYBARA_FOLDER_ORIGIN +# Arguments: +# last_rev, string or empty +# force, string or empty +####################################### +do_run_copybara() { + local _last_rev=$1 + local _force=$2 + + local -a flags + flags+=(--git-destination-url="file://${ANDROID_BUILD_TOP}/external/cronet") + flags+=(--repo-timeout 3m) + + # buildtools/third_party/libc++ contains an invalid symlink + flags+=(--folder-origin-ignore-invalid-symlinks) + flags+=(--git-no-verify) + + if [ ! -z "${_force}" ]; then + flags+=(--force) + fi + + if [ ! -z "${_last_rev}" ]; then + flags+=(--last-rev "${_last_rev}") + fi + + /google/bin/releases/copybara/public/copybara/copybara \ + "${flags[@]}" \ + "${ANDROID_BUILD_TOP}/packages/modules/Connectivity/Cronet/tools/import/copy.bara.sky" \ + import_cronet "${COPYBARA_FOLDER_ORIGIN}/src" +} + +while getopts $OPTSTRING opt; do + case "${opt}" in + f) force=true ;; + l) last_rev="${OPTARG}" ;; + n) new_rev="${OPTARG}" ;; + ?) usage ;; + *) echo "'${opt}' '${OPTARG}'" + esac +done + +if [ -z "${new_rev}" ]; then + echo "-n argument required" + usage +fi + +setup_upstream_import_branch +setup_folder_origin "${new_rev}" +do_run_copybara "${last_rev}" "${force}" + |