summaryrefslogtreecommitdiff
path: root/tcwg_aosp-build.sh
blob: 1914823f4b46c0762da1fa4e2a1d8b9acd03815b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash

set -euf -o pipefail

scripts=$(dirname $0)
# shellcheck source=jenkins-helpers.sh
. $scripts/jenkins-helpers.sh
# shellcheck source=round-robin.sh
. $scripts/round-robin.sh

convert_args_to_variables "$@"

obligatory_variables rr[ci_config]
declare -A rr

# Execution mode: build or bisect
rr[mode]="${rr[mode]-build}"

# Set custom revision for one of the projects, and use baseline revisions
# for all other projects.
rr[ci_project]="${rr[ci_project]-tcwg_aosp}"
rr[baseline_branch]="${rr[baseline_branch]-linaro-local/ci/${rr[ci_project]}/${rr[ci_config]}}"
rr[update_baseline]="${rr[update_baseline]-ignore}"
rr[top_artifacts]="${rr[top_artifacts]-$(pwd)/artifacts}"

# {toolchain}-{toolchain_ver}-{target}-{aosp_module}-{aosp_ver}
IFS=- read -a ci_config <<EOF
${rr[ci_config]}
EOF
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"

# Use baseline branches by default.
for c in ${rr[components]}; do
    rr[${c}_git]=${rr[${c}_git]-baseline}
done

start_at="${start_at-default}"
finish_at="${finish_at-default}"
verbose="${verbose-true}"
verbose2="${verbose2-false}"

if $verbose2; then set -x; fi

trap print_traceback EXIT

# Set start and finish steps for different modes.
default_start_at=""
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" ;;
	    *) assert false ;;
	esac
	;;
esac
if [ x"$start_at" = x"default" ]; then
    start_at="$default_start_at"
fi
if [ x"$finish_at" = x"default" ]; then
    finish_at="$default_finish_at"
fi

run_step_init "$start_at" "$finish_at" "${rr[top_artifacts]}" "$verbose"

# Build AOSP
build_aosp ()
{
    (
    set -euf -o pipefail

    clone_repo 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)"

    repo sync -c -j"$(nproc --all)" -q
    )
}

# Exit with code 0 if no regression compared to base-artifacts/results.
no_regression_p ()
{
    (
    set -euf -o pipefail

    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
    )
}

run_step stop_on_fail -10 reset_artifacts
run_step skip_on_fail 0 build_llvm
run_step skip_on_fail 1 build_aosp
run_step reset_on_fail x check_regression
run_step stop_on_fail x update_baseline

trap "" EXIT