summaryrefslogtreecommitdiff
path: root/tcwg_chromium-build.sh
blob: 72174cfe5e35a8d9507965b7da5fd13c264e6e49 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/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
# shellcheck source=ci-autotest.sh
. $scripts/ci-autotest.sh

workspace="${workspace-$(pwd)}"

convert_args_to_variables "$@"

obligatory_variables rr[ci_project] 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[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}"

# FIXME : Disable ci_autotest when ready
rr[ci_autotest]="${rr[ci_autotest]-test}"

# This project uses a dynamic component list
rr[dynamic_components_list]="${rr[dynamic_components_list]-}"

declare -A deps_dir=(
  ["dawn"]="third_party/dawn"
  ["chromium_variations"]="third_party/chromium-variations"
  ["catapult"]="third_party/catapult"
  ["perfetto"]="third_party/perfetto"
  ["vulkan-deps"]="third_party/vulkan-deps"
  ["angle"]="third_party/angle"
  ["skia"]="third_party/skia"
  ["v8"]="v8"
)

if [ x"${rr[dynamic_components_list]}" == x"*" ]; then
    dynamic_components_list="${!deps_dir[*]}"
else
    dynamic_components_list="${rr[dynamic_components_list]}"
fi

rr[components]="${rr[components]-}"
for dep in $dynamic_components_list; do
    if [ -f ${rr[top_artifacts]}/git/${dep}_rev ]; then
	rr[components]="${rr[components]} ${dep}"
	rr[${dep}_git]=$(get_current_git ${dep}_rev)
    fi
done

verbose="${verbose-true}"
verbose2="${verbose2-false}"

if $verbose2; then set -x; fi

trap print_traceback EXIT

# Set start and finish steps for different modes.
start_at="${start_at-default}"
finish_at="${finish_at-default}"
default_start_at=""
default_finish_at=""
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"
#
get_sources()
{
    cd $workspace

    echo "# RUN_STEP: get_sources"

    /bin/rm -fr $PWD/depot_tools

    git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

    export PATH="$PWD/depot_tools:$PATH"

    force_fetch=false

    if [ ! -d $PWD/src ] || $force_fetch; then
        /bin/rm -fr $PWD/src $PWD/.gclient $PWD/.gclient_entries $PWD/.gclient_previous_sync_commits

        fetch --nohooks --no-history chromium
    fi


    cd $workspace/src

    #

    # FIXME : Temporarily disabled to make it faster
    # gclient revinfo > REVINFO.BEF

    # Updating individual components
    (
    cd $workspace

    echo "components=${rr[components]}"

    # update the rev
    for depfile in ${rr[components]}; do
        dep=${depfile#${rr[top_artifacts]}/git/}
        dep=${dep%_rev}

	rev_or_branch=$(get_current_git ${dep}_rev)
	git -C "src/${deps_dir[$dep]}" fetch origin "$rev_or_branch"
	git -C "src/${deps_dir[$dep]}" checkout FETCH_HEAD
        rev=$(git -C "src/${deps_dir[$dep]}" rev-parse HEAD)

        echo "UPDATING [$dep] : $rev_or_branch -> $rev"
        echo "$rev" | set_current_git ${dep}_rev

        echo "src/${deps_dir[$dep]}" | set_current_git ${dep}_dir
    done
    )

    # FIXME : Temporarily return here to make it faster
    return
    
    gclient revinfo > REVINFO.AFT

    #
    sudo apt-get update
    sudo env DEBIAN_FRONTEND=noninteractive apt-get install keyboard-configuration

    ./build/install-build-deps.sh

    ./build/linux/sysroot_scripts/install-sysroot.py --arch=arm64

    #gclient sync --nohooks

    gclient runhooks

    gn gen out/Default

    [ "$(grep target_cpu out/Default/args.gn | wc -l)" -ne 0 ] \
        || echo 'target_cpu = "arm64"' >> out/Default/args.gn

}

#
build_chromium()
{
    echo "# RUN_STEP: build_chromium"
    export PATH="$PWD/depot_tools:$PATH"
    if [ ${rr[ci_autotest]} == "build" ]; then
        ci_autotest_check_guilty_commit "build"
	return
    fi

    # autoninja -C out/Default chrome
    true
}

#
test_chromium()
{
    echo "# RUN_STEP: test_chromium"
    if [ ${rr[ci_autotest]} == "test" ]; then
        ci_autotest_check_guilty_commit "test"
	return
    fi
    
    # test it
    true
}

# Exit with code 0 if no regression compared to base-artifacts/results.
no_regression_p ()
{
    # check score-based regression
    no_build_regression_p "$@"

    # Regression detecvtion can be more precise :
    # - same "build" score : we could check the number of objects
    # - etc..

    return 0
}

run_step stop_on_fail  -1 reset_artifacts
run_step skip_on_fail  0 get_sources
run_step skip_on_fail   1 build_chromium
run_step skip_on_fail   2 test_chromium
run_step reset_on_fail  x check_regression

trap "" EXIT