Skip to content

Commit

Permalink
Android aosp: refactor roll_aosp.sh, add docs
Browse files Browse the repository at this point in the history
A few minor simplifications and documenting some caveats.

Bug: b/279980674
Change-Id: I895721a97f9aa849a2cd6a67fe3a76098c10e9e9
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5845911
Reviewed-by: Yuxin Hu <[email protected]>
Reviewed-by: Cody Northrop <[email protected]>
  • Loading branch information
romanl-g committed Sep 16, 2024
1 parent ca2e588 commit 44a8184
Showing 1 changed file with 74 additions and 52 deletions.
126 changes: 74 additions & 52 deletions scripts/roll_aosp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,37 @@ rm -rf ${DEPOT_TOOLS_DIR}
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git ${DEPOT_TOOLS_DIR}
export PATH=`pwd`/${DEPOT_TOOLS_DIR}:$PATH

third_party_deps=(

# This script is executed by the Skia roller in *AOSP* checkout (with new ANGLE changes merged into it by git merge).
# The Skia roller merges ANGLE changes and also has code to remove submodules and extra files.
# For local setup including the additional Skia roller actions see go/angle-skia-roller-local
#
# Some caveats due to the way this is set up:
# * If a file is deleted from AOSP by a previous commit to AOSP *and* is changed upstream in ANGLE,
# git merge will fail in Skia roller before even reaching this script. This sometimes happens with e.g. .gitmodules
#
# * If a file is needed to run gn gen (commonly BUILD.gn) it might need to take a different path:
#
# * If this file comes from ANGLE, it is already git-merged into AOSP by Skia roller by the time we get to this script
# - example: ANGLE source files, but also e.g. third_party/jdk/BUILD.gn (see note below)
#
# * If this file comes from a third_party dep (pulled by gclient in generate_Android_bp_file), it is either:
# 1. deleted after the codegen ensuring it is *not* in AOSP (delete_after_codegen_paths)
# 2. automatically ignored due to it being part of a sub-repo not this repo (.git subdirs in git deps but not cipd)
# 3. copied to AOSP intentionally by this script (copy_to_aosp_paths, which deletes .git subdirs to avoid the case 2)
# 4. copied to AOSP implicitly, without being in copy_to_aosp_paths:
# - dep does not have a .git subdir (dep_type cipd in DEPS)
# - not listed in delete_after_codegen_paths
# - example: files under third_party/r8
#
# Note: a file being under third_party/ does *not* necessarily imply it comes from a dep. For example third_party/jdk/BUILD.gn
# comes from the ANGLE repo, not from the upstream Chromium third_pary/jdk repo.. but it can be different in other cases.
# In cases like third_party/jdk/BUILD.gn, we need to make sure it is *not* part of delete_after_codegen_paths as
# this script would delete this file from AOSP after one roll and the next roll would fail gn gen.

# Deps copied to AOSP by having .git removed from them then git add (via git_add_paths)
# .git removed so that it's not an "embedded repository" https://gist.github.com/claraj/e5563befe6c2fb108ad0efb6de47f265
copy_to_aosp_paths=(
"build"
"third_party/abseil-cpp"
"third_party/glslang/src"
Expand All @@ -142,28 +172,49 @@ third_party_deps=(
"third_party/vulkan_memory_allocator"
)

root_add_deps=(
# Dirs and files deleted after codegen so that they don't get added to AOSP.
# We don't need this for dirs with .git in them as those are already ignored by git.
delete_after_codegen_paths=(
"third_party/android_build_tools"
"third_party/android_sdk"
"third_party/android_toolchain"
"third_party/jdk/current" # subdirs only to keep third_party/jdk/BUILD.gn (not pulled by gclient as it comes from ANGLE repo)
"third_party/jdk/extras"
"third_party/llvm-build"
"third_party/rust-toolchain"
"third_party/zlib" # Replaced by Android's zlib

# build/linux is hundreds of megs that aren't needed.
"build/linux"
# Debuggable APKs cannot be merged into AOSP as a prebuilt
"build/android/CheckInstallApk-debug.apk"
# Remove Android.mk files to prevent automated CLs:
# "[LSC] Add LOCAL_LICENSE_KINDS to external/angle"
"Android.mk"
"third_party/glslang/src/Android.mk"
"third_party/glslang/src/ndk_test/Android.mk"
"third_party/spirv-tools/src/Android.mk"
"third_party/spirv-tools/src/android_test/Android.mk"
"third_party/siso" # Not needed
)

# Dirs added to the commit with `git add -f`. Applies to both copy_to_aosp_paths and delete_after_codegen_paths.
git_add_paths=(
"build"
"third_party"
)

delete_only_deps=(
"third_party/zlib" # Replaced by Android's zlib; delete for gclient to work https://crbug.com/skia/14155#c3
)

# Delete dep directories so that gclient can check them out
for dep in "${third_party_deps[@]}" "${delete_only_deps[@]}"; do
rm -rf "$dep"
# Delete first to get a clean checkout by gclient
for path in "${copy_to_aosp_paths[@]}"; do
rm -rf "$path"
done

# Remove cruft from any previous bad rolls (https://anglebug.com/42266781)
extra_third_party_removal_patterns=(
"*/_gclient_*"
)
find third_party -wholename "*/_gclient_*" -delete

for removal_dir in "${extra_third_party_removal_patterns[@]}"; do
find third_party -wholename "$removal_dir" -delete
done
# Workaround to avoid gclient errors https://crbug.com/skia/14155#c3
rm -rf "third_party/zlib"

# Sync all of ANGLE's deps so that 'gn gen' works
python3 scripts/bootstrap.py
Expand All @@ -181,53 +232,24 @@ git add angle_commit.h
# Delete outdir to cleanup after gn.
rm -rf ${GN_OUTPUT_DIRECTORY}

# Delete all unsupported 3rd party dependencies. Do this after generate_Android_bp_file, so
# it has access to all of the necessary BUILD.gn files.
unsupported_third_party_deps=(
"third_party/android_build_tools"
"third_party/android_sdk"
"third_party/android_toolchain"
"third_party/jdk/current" # subdirs only to keep third_party/jdk/BUILD.gn (not pulled by gclient as it comes from ANGLE repo)
"third_party/jdk/extras"
"third_party/llvm-build"
"third_party/rust-toolchain"
"third_party/zlib" # Replaced by Android's zlib
)
for unsupported_third_party_dep in "${unsupported_third_party_deps[@]}"; do
rm -rf "$unsupported_third_party_dep"
# Delete files that we do not want in AOSP.
# Some of them are needed for codegen so this happens after generate_Android_bp_file.
for path in "${delete_after_codegen_paths[@]}"; do
rm -rf "$path"
done

# Delete the .git files in each dep so that it can be added to this repo. Some deps like jsoncpp
# Delete the .git files in each dep so that it can be copied to this repo. Some deps like jsoncpp
# have multiple layers of deps so delete everything before adding them.
for dep in "${third_party_deps[@]}"; do
for dep in "${copy_to_aosp_paths[@]}"; do
rm -rf "$dep"/.git
done

# Delete all the .gitmodules files, since they are not allowed in AOSP external projects.
find . -name \.gitmodules -exec rm {} \;

extra_removal_files=(
# build/linux is hundreds of megs that aren't needed.
"build/linux"
# Debuggable APKs cannot be merged into AOSP as a prebuilt
"build/android/CheckInstallApk-debug.apk"
# Remove Android.mk files to prevent automated CLs:
# "[LSC] Add LOCAL_LICENSE_KINDS to external/angle"
"Android.mk"
"third_party/glslang/src/Android.mk"
"third_party/glslang/src/ndk_test/Android.mk"
"third_party/spirv-tools/src/Android.mk"
"third_party/spirv-tools/src/android_test/Android.mk"
"third_party/siso" # Not needed
)

for removal_file in "${extra_removal_files[@]}"; do
rm -rf "$removal_file"
done

# Add all changes under $root_add_deps so we delete everything not explicitly allowed.
for root_add_dep in "${root_add_deps[@]}"; do
git add -f $root_add_dep
# Add all changes under git_add_paths to sync changes (including deletion) in those dirs to AOSP.
for path in "${git_add_paths[@]}"; do
git add -f $path
done

# Done with depot_tools
Expand Down

0 comments on commit 44a8184

Please sign in to comment.