xref: /aosp_15_r20/build/make/tools/finalization/finalize-sdk-rel.sh (revision 9e94795a3d4ef5c1d47486f9a02bb378756cea8a)
1#!/bin/bash
2
3set -ex
4
5function revert_droidstubs_hack() {
6    if grep -q 'STOPSHIP: RESTORE THIS LOGIC WHEN DECLARING "REL" BUILD' "$top/build/soong/java/droidstubs.go" ; then
7        patch --strip=1 --no-backup-if-mismatch --directory="$top/build/soong" --input=../../build/make/tools/finalization/build_soong_java_droidstubs.go.revert_hack.diff
8    fi
9}
10
11function apply_prerelease_sdk_hack() {
12    if ! grep -q 'STOPSHIP: hack for the pre-release SDK' "$top/frameworks/base/core/java/android/content/pm/parsing/FrameworkParsingPackageUtils.java" ; then
13        patch --strip=1 --no-backup-if-mismatch --directory="$top/frameworks/base" --input=../../build/make/tools/finalization/frameworks_base.apply_hack.diff
14    fi
15}
16
17function finalize_sdk_rel() {
18    local top="$(dirname "$0")"/../../../..
19    source $top/build/make/tools/finalization/environment.sh
20
21    # revert droidstubs hack now we are switching to REL
22    revert_droidstubs_hack
23
24    # let the apps built with pre-release SDK parse
25    apply_prerelease_sdk_hack
26
27    # cts
28    if ! grep -q "${FINAL_PLATFORM_VERSION}" "$top/cts/tests/tests/os/assets/platform_versions.txt" ; then
29        echo ${FINAL_PLATFORM_VERSION} >> "$top/cts/tests/tests/os/assets/platform_versions.txt"
30    fi
31    if [ "$FINAL_PLATFORM_CODENAME" != "$CURRENT_PLATFORM_CODENAME" ]; then
32        echo "$CURRENT_PLATFORM_CODENAME" >> "./cts/tests/tests/os/assets/platform_versions.txt"
33    fi
34    git -C "$top/cts" mv hostsidetests/theme/assets/${FINAL_PLATFORM_CODENAME} hostsidetests/theme/assets/${FINAL_PLATFORM_SDK_VERSION}
35
36    # prebuilts/abi-dumps/platform
37    "$top/build/soong/soong_ui.bash" --make-mode TARGET_RELEASE=next TARGET_PRODUCT=aosp_arm64 TARGET_BUILD_VARIANT=userdebug create_reference_dumps
38    ANDROID_BUILD_TOP="$top" "$top/out/host/linux-x86/bin/create_reference_dumps" -release next --build-variant userdebug --lib-variant APEX
39}
40
41finalize_sdk_rel
42
43