diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2022-09-15 18:50:33 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2022-09-16 15:35:22 +0000 |
commit | ce01b29551fd88399b659794a786db9f0e314172 (patch) | |
tree | 7e593081f890582cd16d7960257fb51e14036254 | |
parent | 76d07d67d20c60e0f441637d7db980c616a4ca3e (diff) |
tcwg_aosp-build.sh: WIP improvements
Change-Id: I8ffa5ea039eab0a25f432dc5d511c48fa60ac64c
-rwxr-xr-x | tcwg_aosp-build.sh | 122 |
1 files changed, 111 insertions, 11 deletions
diff --git a/tcwg_aosp-build.sh b/tcwg_aosp-build.sh index 1914823f..f9c0418b 100755 --- a/tcwg_aosp-build.sh +++ b/tcwg_aosp-build.sh @@ -23,6 +23,9 @@ rr[baseline_branch]="${rr[baseline_branch]-linaro-local/ci/${rr[ci_project]}/${r rr[update_baseline]="${rr[update_baseline]-ignore}" rr[top_artifacts]="${rr[top_artifacts]-$(pwd)/artifacts}" +# store date of the run +rr[run_date]="$(date --utc --iso-8601=seconds)" + # {toolchain}-{toolchain_ver}-{target}-{aosp_module}-{aosp_ver} IFS=- read -a ci_config <<EOF ${rr[ci_config]} @@ -31,7 +34,7 @@ rr[toolchain]=${rr[toolchain]-${ci_config[0]}} rr[target]=${rr[target]-${ci_config[2]}} aosp_module=${aosp_module-${ci_config[3]}} -rr[components]="llvm manifest" +rr[components]="llvm toolchain-manifest aosp-manifest" # Use baseline branches by default. for c in ${rr[components]}; do @@ -53,8 +56,9 @@ default_finish_at="" case "${rr[mode]}" in "bisect") case "$(print_single_updated_component)" in - llvm) default_start_at="build_llvm" ;; - manifest) default_start_at="build_aosp" ;; + llvm) default_start_at="build_llvm_android" ;; + toolchain-manifest) default_start_at="build_llvm_android" ;; + aosp-manifest) default_start_at="build_aosp" ;; *) assert false ;; esac ;; @@ -68,22 +72,115 @@ fi run_step_init "$start_at" "$finish_at" "${rr[top_artifacts]}" "$verbose" +# Build LLVM +build_llvm_android () +{ + ( + set -euf -o pipefail + + clone_repo llvm + + clone_repo toolchain-manifest + + mkdir -p llvm-toolchain + cd llvm-toolchain + + repo init --partial-clone --clone-filter=blob:limit=10M \ + -u "$(get_current_git toolchain-manifest_url)" \ + -b "$(get_current_git toolchain-manifest_rev)" + + repo sync -c -j"$(nproc --all)" -q + + python toolchain/llvm_android/build.py \ + --no-build lldb,windows --skip-runtimes --skip-tests --skip-package + + local cc cxx ninja + cc=$(cat out/stage2/cmake_invocation.sh \ + | grep -e " -DCMAKE_C_COMPILER=" \ + | sed -e "s/.* -DCMAKE_C_COMPILER=\([^ ]*\).*/\1/") + cxx=$(cat out/stage2/cmake_invocation.sh \ + | grep -e " -DCMAKE_CXX_COMPILER=" \ + | sed -e "s/.* -DCMAKE_CXX_COMPILER=\([^ ]*\).*/\1/") + ninja=$(cat out/stage2/cmake_invocation.sh \ + | grep -e " -DCMAKE_MAKE_PROGRAM=" \ + | sed -e "s/.* -DCMAKE_MAKE_PROGRAM=\([^ ]*\).*/\1/") + cd .. + + local workspace + workspace=$(pwd) + + rm -rf "${workspace:?}/bin" + mkdir "$workspace/bin" + + cat > "$workspace/bin/cc" <<EOF +#!/bin/sh +CCACHE_BASEDIR=$workspace exec ccache $cc "\$@" +EOF + chmod +x "$workspace/bin/cc" + + cat > "$workspace/bin/c++" <<EOF +#!/bin/sh +CCACHE_BASEDIR=$workspace exec ccache $cxx "\$@" +EOF + chmod +x "$workspace/bin/c++" + + rm -rf llvm-install + + cd llvm-toolchain/out + + mkdir -p stage3 + cp stage2/cmake_invocation.sh stage3/ + + cd stage3 + + sed -i \ + -e "s#/llvm-toolchain/out/llvm-project/#/llvm/#" \ + -e "s#/llvm-toolchain/out/stage2-install#/llvm-install#" \ + -e "s# -DCMAKE_C_COMPILER=[^ ]* # -DCMAKE_C_COMPILER=$workspace/bin/cc #" \ + -e "s# -DCMAKE_CXX_COMPILER=[^ ]* # -DCMAKE_CXX_COMPILER=$workspace/bin/c++ #" \ + cmake_invocation.sh + + source ./cmake_invocation.sh + ccache -z + $ninja + $ninja install + ccache -s + ) +} + +install_shadow_cc () +{ + ( + set -euf -o pipefail + + ) +} + # Build AOSP build_aosp () { ( set -euf -o pipefail - clone_repo manifest + clone_repo aosp-manifest mkdir -p aosp cd aosp repo init --partial-clone --clone-filter=blob:limit=10M \ - -u "$(get_current_git manifest_url)" \ - -b "$(get_current_git manifest_rev)" + -u "$(get_current_git aosp-manifest_url)" \ + -b "$(get_current_git aosp-manifest_rev)" repo sync -c -j"$(nproc --all)" -q + + install_shadow_cc "aosp" "$(cd $scripts; pwd)/shadow-cc.sh" + + set -e +uf +o pipefail + source build/envsetup.sh + + lunch aosp_arm64-user + m clean + m ) } @@ -96,15 +193,18 @@ no_regression_p () local -a changed_components IFS=" " read -r -a changed_components <<< "$(print_changed_components)" - if [ x"${changed_components[*]}" = x"manifest" ]; then - # Builds with only AOSP changed we declare as non-regressing - return 0 - fi + case " ${changed_components[*]} " in + *" llvm "*) ;; + *) + # Builds without changed LLVM we declare as non-regressing. + return 0 + ;; + esac ) } run_step stop_on_fail -10 reset_artifacts -run_step skip_on_fail 0 build_llvm +run_step skip_on_fail 0 build_llvm_android run_step skip_on_fail 1 build_aosp run_step reset_on_fail x check_regression run_step stop_on_fail x update_baseline |