Leonardo Sandoval | 9dfdd1b | 2020-08-06 17:08:11 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 2 | # |
David Vincze | 82db693 | 2024-02-21 12:05:50 +0100 | [diff] [blame] | 3 | # Copyright (c) 2019-2024 Arm Limited. All rights reserved. |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
| 8 | # Builds a package with Trusted Firwmare and other payload binaries. The package |
| 9 | # is meant to be executed by run_package.sh |
| 10 | |
| 11 | set -e |
| 12 | |
| 13 | ci_root="$(readlink -f "$(dirname "$0")/..")" |
| 14 | source "$ci_root/utils.sh" |
| 15 | |
| 16 | if [ ! -d "$workspace" ]; then |
| 17 | die "Directory $workspace doesn't exist" |
| 18 | fi |
| 19 | |
| 20 | # Directory to where the source code e.g. for Trusted Firmware is checked out. |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 21 | export tf_root="${tf_root:-$workspace/trusted_firmware}" |
| 22 | export tftf_root="${tftf_root:-$workspace/trusted_firmware_tf}" |
| 23 | export scp_root="${scp_root:-$workspace/scp}" |
| 24 | scp_tools_root="${scp_tools_root:-$workspace/scp_tools}" |
| 25 | cc_root="${cc_root:-$ccpathspec}" |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 26 | spm_root="${spm_root:-$workspace/spm}" |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 27 | rmm_root="${rmm_root:-$workspace/tf-rmm}" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 28 | |
| 29 | scp_tf_tools_root="$scp_tools_root/scp_tf_tools" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 30 | |
| 31 | # Refspecs |
| 32 | tf_refspec="$TF_REFSPEC" |
| 33 | tftf_refspec="$TFTF_REFSPEC" |
| 34 | scp_refspec="$SCP_REFSPEC" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 35 | scp_tools_commit="${SCP_TOOLS_COMMIT:-master}" |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 36 | spm_refspec="$SPM_REFSPEC" |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 37 | rmm_refspec="$RMM_REFSPEC" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 38 | |
| 39 | test_config="${TEST_CONFIG:?}" |
| 40 | test_group="${TEST_GROUP:?}" |
| 41 | build_configs="${BUILD_CONFIG:?}" |
| 42 | run_config="${RUN_CONFIG:?}" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 43 | cc_config="${CC_ENABLE:-}" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 44 | |
| 45 | archive="$artefacts" |
| 46 | build_log="$artefacts/build.log" |
| 47 | fiptool="$tf_root/tools/fiptool/fiptool" |
| 48 | cert_create="$tf_root/tools/cert_create/cert_create" |
| 49 | |
| 50 | # Validate $bin_mode |
| 51 | case "$bin_mode" in |
| 52 | "" | debug | release) |
| 53 | ;; |
| 54 | *) |
| 55 | die "Invalid value for bin_mode: $bin_mode" |
| 56 | ;; |
| 57 | esac |
| 58 | |
| 59 | # File to save any environem |
| 60 | hook_env_file="$(mktempfile)" |
| 61 | |
| 62 | # Check if a config is valid |
| 63 | config_valid() { |
| 64 | local config="${1?}" |
| 65 | if [ -z "$config" ] || [ "$(basename "$config")" = "nil" ]; then |
| 66 | return 1 |
| 67 | fi |
| 68 | |
| 69 | return 0 |
| 70 | } |
| 71 | |
| 72 | # Echo from a build wrapper. Print to descriptor 3 that's opened by the build |
| 73 | # function. |
| 74 | echo_w() { |
| 75 | echo $echo_flags "$@" >&3 |
| 76 | } |
| 77 | |
| 78 | # Print a separator to the log file. Intended to be used at the tail end of a pipe |
| 79 | log_separator() { |
| 80 | { |
| 81 | echo |
| 82 | echo "----------" |
| 83 | } >> "$build_log" |
| 84 | |
| 85 | tee -a "$build_log" |
| 86 | |
| 87 | { |
| 88 | echo "----------" |
| 89 | echo |
| 90 | } >> "$build_log" |
| 91 | } |
| 92 | |
| 93 | # Call function $1 if it's defined |
| 94 | call_func() { |
| 95 | if type "${1:?}" &>/dev/null; then |
| 96 | echo |
| 97 | echo "> ${2:?}:$1()" |
| 98 | eval "$1" |
| 99 | echo "< $2:$1()" |
| 100 | fi |
| 101 | } |
| 102 | |
Paul Sokolovsky | be6510c | 2024-08-15 21:54:00 +0300 | [diff] [blame] | 103 | # Retry a command a number of times if it fails. Intended for I/O commands |
| 104 | # in a CI environment which may be flaky. |
| 105 | function retry() { |
| 106 | for i in $(seq 1 3); do |
| 107 | if "$@"; then |
| 108 | return 0 |
| 109 | fi |
| 110 | sleep $(( i * 5 )) |
| 111 | done |
| 112 | return 1 |
| 113 | } |
| 114 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 115 | # Call hook $1 in all chosen fragments if it's defined. Hooks are invoked from |
| 116 | # within a subshell, so any variables set within a hook are lost. Should a |
| 117 | # variable needs to be set from within a hook, the function 'set_hook_var' |
| 118 | # should be used |
| 119 | call_hook() { |
| 120 | local func="$1" |
| 121 | local config_fragment |
| 122 | |
| 123 | [ -z "$func" ] && return 0 |
| 124 | |
Paul Sokolovsky | e9962cd | 2021-12-17 18:39:40 +0300 | [diff] [blame] | 125 | echo "=== Calling hooks: $1 ===" |
| 126 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 127 | : >"$hook_env_file" |
| 128 | |
Nicola Mazzucato | 7fc5abd | 2024-02-23 21:32:48 +0000 | [diff] [blame] | 129 | if [ "$run_config_candidates" ]; then |
| 130 | for config_fragment in $run_config_candidates; do |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 131 | ( |
| 132 | source "$ci_root/run_config/$config_fragment" |
| 133 | call_func "$func" "$config_fragment" |
| 134 | ) |
| 135 | done |
| 136 | fi |
| 137 | |
| 138 | # Also source test config file |
| 139 | ( |
| 140 | unset "$func" |
| 141 | source "$test_config_file" |
| 142 | call_func "$func" "$(basename $test_config_file)" |
| 143 | ) |
| 144 | |
| 145 | # Have any variables set take effect |
| 146 | source "$hook_env_file" |
Paul Sokolovsky | e9962cd | 2021-12-17 18:39:40 +0300 | [diff] [blame] | 147 | |
| 148 | echo "=== End calling hooks: $1 ===" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | # Set a variable from within a hook |
| 152 | set_hook_var() { |
| 153 | echo "export $1=\"${2?}\"" >> "$hook_env_file" |
| 154 | } |
| 155 | |
| 156 | # Append to an array from within a hook |
| 157 | append_hook_var() { |
| 158 | echo "export $1+=\"${2?}\"" >> "$hook_env_file" |
| 159 | } |
| 160 | |
| 161 | # Have the main build script source a file |
| 162 | source_later() { |
| 163 | echo "source ${1?}" >> "$hook_env_file" |
| 164 | } |
| 165 | |
| 166 | # Setup TF build wrapper function by pointing to a script containing a function |
| 167 | # that will be called with the TF build commands. |
| 168 | setup_tf_build_wrapper() { |
| 169 | source_later "$ci_root/script/${wrapper?}_wrapper.sh" |
| 170 | set_hook_var "tf_build_wrapper" "${wrapper}_wrapper" |
| 171 | echo "Setup $wrapper build wrapper." |
| 172 | } |
| 173 | |
| 174 | # Collect .bin files for archiving |
| 175 | collect_build_artefacts() { |
| 176 | if [ ! -d "${from:?}" ]; then |
| 177 | return |
| 178 | fi |
| 179 | |
Yann Gautier | 7e9d6cf | 2023-03-08 14:24:38 +0100 | [diff] [blame] | 180 | if ! find "$from" \( -name "*.bin" -o -name '*.elf' -o -name '*.dtb' -o -name '*.axf' -o -name '*.stm32' \) -exec cp -t "${to:?}" '{}' +; then |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 181 | echo "You probably are running local CI on local repositories." |
| 182 | echo "Did you set 'dont_clean' but forgot to run 'distclean'?" |
| 183 | die |
| 184 | fi |
| 185 | } |
| 186 | |
| 187 | # SCP and MCP binaries are named firmware.{bin,elf}, and are placed under |
| 188 | # scp/mcp_ramfw and scp/mcp_romfw directories, so can't be collected by |
| 189 | # collect_build_artefacts function. |
| 190 | collect_scp_artefacts() { |
| 191 | to="${to:?}" \ |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 192 | find "$scp_root" \( \( -name "*.bin" -o -name '*.elf' \) -and ! -name 'CMake*' \) -exec bash -c ' |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 193 | for file; do |
| 194 | ext="$(echo $file | awk -F. "{print \$NF}")" |
| 195 | case $file in |
Anurag Koul | baedf93 | 2021-12-09 12:49:56 +0000 | [diff] [blame] | 196 | */firmware-scp_ramfw/bin/*|*/firmware-scp_ramfw_fvp/bin/*) |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 197 | cp $file $to/scp_ram.$ext |
| 198 | ;; |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 199 | */firmware-scp_romfw/bin/*) |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 200 | cp $file $to/scp_rom.$ext |
| 201 | ;; |
Anurag Koul | baedf93 | 2021-12-09 12:49:56 +0000 | [diff] [blame] | 202 | */firmware-mcp_ramfw/bin/*|*/firmware-mcp_ramfw_fvp/bin/*) |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 203 | cp $file $to/mcp_ram.$ext |
| 204 | ;; |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 205 | */firmware-mcp_romfw/bin/*) |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 206 | cp $file $to/mcp_rom.$ext |
| 207 | ;; |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 208 | */firmware-scp_romfw_bypass/bin/*) |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 209 | cp $file $to/scp_rom_bypass.$ext |
| 210 | ;; |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 211 | *) |
| 212 | echo "Unknown SCP binary: $file" >&2 |
| 213 | ;; |
| 214 | esac |
| 215 | done |
| 216 | ' bash '{}' + |
| 217 | } |
| 218 | |
Manish Pandey | 1e7be85 | 2020-11-09 16:04:48 +0000 | [diff] [blame] | 219 | # Collect SPM/hafnium artefacts with "secure_" appended to the files |
| 220 | # generated for SPM(secure hafnium). |
| 221 | collect_spm_artefacts() { |
Madhukar Pappireddy | c683cf6 | 2021-11-01 14:38:32 -0500 | [diff] [blame] | 222 | if [ -d "${non_secure_from:?}" ]; then |
| 223 | find "$non_secure_from" \( -name "*.bin" -o -name '*.elf' \) -exec cp -t "${to:?}" '{}' + |
Manish Pandey | 1e7be85 | 2020-11-09 16:04:48 +0000 | [diff] [blame] | 224 | fi |
| 225 | |
Madhukar Pappireddy | c683cf6 | 2021-11-01 14:38:32 -0500 | [diff] [blame] | 226 | if [ -d "${secure_from:?}" ]; then |
| 227 | for f in $(find "$secure_from" \( -name "*.bin" -o -name '*.elf' \)); do cp -- "$f" "${to:?}"/secure_$(basename $f); done |
| 228 | fi |
Manish Pandey | 1e7be85 | 2020-11-09 16:04:48 +0000 | [diff] [blame] | 229 | } |
| 230 | |
Javier Almansa Sobrino | 412d361 | 2020-05-22 17:53:12 +0100 | [diff] [blame] | 231 | # Map the UART ID used for expect with the UART descriptor and port |
| 232 | # used by the FPGA automation tools. |
| 233 | map_uart() { |
| 234 | local port="${port:?}" |
| 235 | local descriptor="${descriptor:?}" |
| 236 | local baudrate="${baudrate:?}" |
| 237 | local run_root="${archive:?}/run" |
| 238 | |
| 239 | local uart_dir="$run_root/uart${uart:?}" |
| 240 | mkdir -p "$uart_dir" |
| 241 | |
| 242 | echo "$port" > "$uart_dir/port" |
| 243 | echo "$descriptor" > "$uart_dir/descriptor" |
| 244 | echo "$baudrate" > "$uart_dir/baudrate" |
| 245 | |
| 246 | echo "UART${uart} mapped to port ${port} with descriptor ${descriptor} and baudrate ${baudrate}" |
| 247 | } |
| 248 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 249 | # Arrange environment varibles to be set when expect scripts are launched |
| 250 | set_expect_variable() { |
| 251 | local var="${1:?}" |
| 252 | local val="${2?}" |
| 253 | |
| 254 | local run_root="${archive:?}/run" |
| 255 | local uart_dir="$run_root/uart${uart:?}" |
| 256 | mkdir -p "$uart_dir" |
| 257 | |
| 258 | env_file="$uart_dir/env" quote="1" emit_env "$var" "$val" |
| 259 | echo "UART$uart: env has $@" |
| 260 | } |
| 261 | |
| 262 | # Place the binary package a pointer to expect script, and its parameters |
| 263 | track_expect() { |
| 264 | local file="${file:?}" |
| 265 | local timeout="${timeout-600}" |
| 266 | local run_root="${archive:?}/run" |
| 267 | |
| 268 | local uart_dir="$run_root/uart${uart:?}" |
| 269 | mkdir -p "$uart_dir" |
| 270 | |
| 271 | echo "$file" > "$uart_dir/expect" |
| 272 | echo "$timeout" > "$uart_dir/timeout" |
Paul Sokolovsky | bfa8bab | 2023-01-25 19:34:51 +0700 | [diff] [blame] | 273 | if [ -n "$lava_timeout" ]; then |
| 274 | set_run_env "lava_timeout" "$lava_timeout" |
| 275 | fi |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 276 | |
Paul Sokolovsky | bfa8bab | 2023-01-25 19:34:51 +0700 | [diff] [blame] | 277 | echo "UART$uart to be tracked with $file; timeout ${timeout}s; lava_timeout ${lava_timeout:-N/A}s" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 278 | |
Chris Kay | fab6edc | 2022-11-17 19:18:32 +0000 | [diff] [blame] | 279 | if [ ! -z "${port}" ]; then |
| 280 | echo "${port}" > "$uart_dir/port" |
| 281 | fi |
| 282 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 283 | # The run script assumes UART0 to be primary. If we're asked to set any |
| 284 | # other UART to be primary, set a run environment variable to signal |
| 285 | # that to the run script |
| 286 | if upon "$set_primary"; then |
| 287 | echo "Primary UART set to UART$uart." |
| 288 | set_run_env "primary_uart" "$uart" |
| 289 | fi |
Madhukar Pappireddy | 1e95372 | 2021-11-08 15:23:02 -0600 | [diff] [blame] | 290 | |
| 291 | # UART used by payload(such as tftf, Linux) may not be the same as the |
| 292 | # primary UART. Set a run environment variable to track the payload |
| 293 | # UART which is tracked to check if the test has finished sucessfully. |
| 294 | if upon "$set_payload_uart"; then |
| 295 | echo "Payload uses UART$uart." |
| 296 | set_run_env "payload_uart" "$uart" |
| 297 | fi |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | # Extract a FIP in $1 using fiptool |
| 301 | extract_fip() { |
| 302 | local fip="$1" |
| 303 | |
| 304 | if is_url "$1"; then |
| 305 | url="$1" fetch_file |
| 306 | fip="$(basename "$1")" |
| 307 | fi |
| 308 | |
| 309 | "$fiptool" unpack "$fip" |
| 310 | echo "Extracted FIP: $fip" |
| 311 | } |
| 312 | |
| 313 | # Report build failure by printing a the tail end of build log. Archive the |
| 314 | # build log for later inspection |
| 315 | fail_build() { |
| 316 | local log_path |
| 317 | |
| 318 | if upon "$jenkins_run"; then |
| 319 | log_path="$BUILD_URL/artifact/artefacts/build.log" |
| 320 | else |
| 321 | log_path="$build_log" |
| 322 | fi |
| 323 | |
| 324 | echo |
Leonardo Sandoval | ae97eda | 2020-11-12 10:07:03 -0600 | [diff] [blame] | 325 | echo "Build failed! Full build log below:" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 326 | echo "[...]" |
| 327 | echo |
Leonardo Sandoval | ae97eda | 2020-11-12 10:07:03 -0600 | [diff] [blame] | 328 | cat "$build_log" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 329 | echo |
| 330 | echo "See $log_path for full output" |
| 331 | echo |
| 332 | cp -t "$archive" "$build_log" |
| 333 | exit 1; |
| 334 | } |
| 335 | |
| 336 | # Build a FIP with supplied arguments |
| 337 | build_fip() { |
| 338 | ( |
| 339 | echo "Building FIP with arguments: $@" |
| 340 | local tf_env="$workspace/tf.env" |
| 341 | |
| 342 | if [ -f "$tf_env" ]; then |
| 343 | set -a |
| 344 | source "$tf_env" |
| 345 | set +a |
| 346 | fi |
| 347 | |
| 348 | make -C "$tf_root" $(cat "$tf_config_file") DEBUG="$DEBUG" V=1 "$@" \ |
| 349 | ${fip_targets:-fip} &>>"$build_log" || fail_build |
| 350 | ) |
| 351 | } |
| 352 | |
Sandrine Bailleux | 189fdb3 | 2023-10-20 13:41:22 +0200 | [diff] [blame] | 353 | # Build any extra rule from TF-A makefile with supplied arguments. |
| 354 | # |
| 355 | # This is useful in case you need to build something else than firmware binaries |
| 356 | # or the FIP. |
| 357 | build_tf_extra() { |
| 358 | ( |
| 359 | tf_extra_rules=${tf_extra_rules:?} |
| 360 | echo "Building extra TF rule(s): $tf_extra_rules" |
| 361 | echo " Arguments: $@" |
| 362 | |
| 363 | local tf_env="$workspace/tf.env" |
| 364 | |
| 365 | if [ -f "$tf_env" ]; then |
| 366 | set -a |
| 367 | source "$tf_env" |
| 368 | set +a |
| 369 | fi |
| 370 | |
| 371 | make -C "$tf_root" $(cat "$tf_config_file") DEBUG="$DEBUG" V=1 "$@" \ |
| 372 | ${tf_extra_rules} &>>"$build_log" || fail_build |
| 373 | ) |
| 374 | } |
| 375 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 376 | fip_update() { |
| 377 | # Before the update process, check if the given image is supported by |
| 378 | # the fiptool. It's assumed that both fiptool and cert_create move in |
Chris Kay | 197b102 | 2023-08-16 21:31:41 +0100 | [diff] [blame] | 379 | # tandem, and therefore, if one has support, the other has it too. |
| 380 | if ! ("$fiptool" update 2>&1 || true) | grep -qe "\s\+--${bin_name:?}"; then |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 381 | return 1 |
| 382 | fi |
| 383 | |
| 384 | if not_upon "$(get_tf_opt TRUSTED_BOARD_BOOT)"; then |
| 385 | echo "Updating FIP image: $bin_name" |
| 386 | # Update HW config. Without TBBR, it's only a matter of using |
| 387 | # the update sub-command of fiptool |
| 388 | "$fiptool" update "--$bin_name" "${src:-}" \ |
| 389 | "$archive/fip.bin" |
| 390 | else |
| 391 | echo "Updating FIP image (TBBR): $bin_name" |
| 392 | # With TBBR, we need to unpack, re-create certificates, and then |
| 393 | # recreate the FIP. |
| 394 | local fip_dir="$(mktempdir)" |
| 395 | local bin common_args stem |
| 396 | local rot_key="$(get_tf_opt ROT_KEY)" |
| 397 | |
| 398 | rot_key="${rot_key:?}" |
| 399 | if ! is_abs "$rot_key"; then |
| 400 | rot_key="$tf_root/$rot_key" |
| 401 | fi |
| 402 | |
| 403 | # Arguments only for cert_create |
| 404 | local cert_args="-n" |
| 405 | cert_args+=" --tfw-nvctr ${nvctr:-31}" |
| 406 | cert_args+=" --ntfw-nvctr ${nvctr:-223}" |
| 407 | cert_args+=" --key-alg ${KEY_ALG:-rsa}" |
| 408 | cert_args+=" --rot-key $rot_key" |
| 409 | |
| 410 | local dyn_config_opts=( |
Zelalem | 1af7a7b | 2020-08-04 17:34:32 -0500 | [diff] [blame] | 411 | "fw-config" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 412 | "hw-config" |
| 413 | "tb-fw-config" |
| 414 | "nt-fw-config" |
| 415 | "soc-fw-config" |
| 416 | "tos-fw-config" |
| 417 | ) |
| 418 | |
| 419 | # Binaries without key certificates |
| 420 | declare -A has_no_key_cert |
| 421 | for bin in "tb-fw" "${dyn_config_opts[@]}"; do |
| 422 | has_no_key_cert["$bin"]="1" |
| 423 | done |
| 424 | |
| 425 | # Binaries without certificates |
| 426 | declare -A has_no_cert |
| 427 | for bin in "hw-config" "${dyn_config_opts[@]}"; do |
| 428 | has_no_cert["$bin"]="1" |
| 429 | done |
| 430 | |
| 431 | pushd "$fip_dir" |
| 432 | |
| 433 | # Unpack FIP |
| 434 | "$fiptool" unpack "$archive/fip.bin" &>>"$build_log" |
| 435 | |
| 436 | # Remove all existing certificates |
| 437 | rm -f *-cert.bin |
| 438 | |
| 439 | # Copy the binary to be updated |
| 440 | cp -f "$src" "${bin_name}.bin" |
| 441 | |
| 442 | # FIP unpack dumps binaries with the same name as the option |
| 443 | # used to pack it; likewise for certificates. Reverse-engineer |
| 444 | # the command line from the binary output. |
| 445 | common_args="--trusted-key-cert trusted_key.crt" |
| 446 | for bin in *.bin; do |
| 447 | stem="${bin%%.bin}" |
| 448 | common_args+=" --$stem $bin" |
| 449 | if not_upon "${has_no_cert[$stem]}"; then |
| 450 | common_args+=" --$stem-cert $stem.crt" |
| 451 | fi |
| 452 | if not_upon "${has_no_key_cert[$stem]}"; then |
| 453 | common_args+=" --$stem-key-cert $stem-key.crt" |
| 454 | fi |
| 455 | done |
| 456 | |
| 457 | # Create certificates |
| 458 | "$cert_create" $cert_args $common_args &>>"$build_log" |
| 459 | |
| 460 | # Recreate and archive FIP |
| 461 | "$fiptool" create $common_args "fip.bin" &>>"$build_log" |
| 462 | archive_file "fip.bin" |
| 463 | |
| 464 | popd |
| 465 | fi |
| 466 | } |
| 467 | |
| 468 | # Update hw-config in FIP, and remove the original DTB afterwards. |
| 469 | update_fip_hw_config() { |
| 470 | # The DTB needs to be loaded by the model (and not updated in the FIP) |
Madhukar Pappireddy | 9062ebf | 2021-03-02 17:07:06 -0600 | [diff] [blame] | 471 | # in configs: |
| 472 | # 1. Where BL2 isn't present |
| 473 | # 2. Where we boot to Linux directly as BL33 |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 474 | case "1" in |
| 475 | "$(get_tf_opt RESET_TO_BL31)" | \ |
Madhukar Pappireddy | 9062ebf | 2021-03-02 17:07:06 -0600 | [diff] [blame] | 476 | "$(get_tf_opt ARM_LINUX_KERNEL_AS_BL33)" | \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 477 | "$(get_tf_opt RESET_TO_SP_MIN)" | \ |
Maksims Svecovs | 7a0da52 | 2023-03-06 16:28:27 +0000 | [diff] [blame] | 478 | "$(get_tf_opt RESET_TO_BL2)") |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 479 | return 0;; |
| 480 | esac |
| 481 | |
| 482 | if bin_name="hw-config" src="$archive/dtb.bin" fip_update; then |
| 483 | # Remove the DTB so that model won't load it |
| 484 | rm -f "$archive/dtb.bin" |
| 485 | fi |
| 486 | } |
| 487 | |
| 488 | get_scp_opt() { |
| 489 | ( |
| 490 | name="${1:?}" |
| 491 | if config_valid "$scp_config_file"; then |
| 492 | source "$scp_config_file" |
| 493 | echo "${!name}" |
| 494 | fi |
| 495 | ) |
| 496 | } |
| 497 | |
| 498 | get_tftf_opt() { |
| 499 | ( |
| 500 | name="${1:?}" |
| 501 | if config_valid "$tftf_config_file"; then |
| 502 | source "$tftf_config_file" |
| 503 | echo "${!name}" |
| 504 | fi |
| 505 | ) |
| 506 | } |
| 507 | |
| 508 | get_tf_opt() { |
| 509 | ( |
| 510 | name="${1:?}" |
| 511 | if config_valid "$tf_config_file"; then |
| 512 | source "$tf_config_file" |
| 513 | echo "${!name}" |
| 514 | fi |
| 515 | ) |
| 516 | } |
| 517 | |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 518 | get_rmm_opt() { |
| 519 | ( |
| 520 | name="${1:?}" |
| 521 | if config_valid "$rmm_config_file"; then |
| 522 | source "$rmm_config_file" |
| 523 | echo "${!name}" |
| 524 | fi |
| 525 | ) |
| 526 | } |
| 527 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 528 | build_tf() { |
| 529 | ( |
| 530 | env_file="$workspace/tf.env" |
| 531 | config_file="${tf_build_config:-$tf_config_file}" |
| 532 | |
| 533 | # Build fiptool and all targets by default |
Harrison Mutai | 32de9d0 | 2023-06-12 14:23:37 +0100 | [diff] [blame] | 534 | build_targets="${tf_build_targets:-fiptool all}" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 535 | |
| 536 | source "$config_file" |
| 537 | |
| 538 | # If it is a TBBR build, extract the MBED TLS library from archive |
Manish V Badarkhe | 8f12501 | 2021-12-21 05:47:52 +0000 | [diff] [blame] | 539 | if [ "$(get_tf_opt TRUSTED_BOARD_BOOT)" = 1 ] || |
Manish V Badarkhe | f43e3f5 | 2022-06-21 20:37:25 +0100 | [diff] [blame] | 540 | [ "$(get_tf_opt MEASURED_BOOT)" = 1 ] || |
| 541 | [ "$(get_tf_opt DRTM_SUPPORT)" = 1 ]; then |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 542 | mbedtls_dir="$workspace/mbedtls" |
| 543 | if [ ! -d "$mbedtls_dir" ]; then |
| 544 | mbedtls_ar="$workspace/mbedtls.tar.gz" |
| 545 | |
| 546 | url="$mbedtls_archive" saveas="$mbedtls_ar" fetch_file |
| 547 | mkdir "$mbedtls_dir" |
Leonardo Sandoval | ec9e16c | 2020-09-09 14:32:40 -0500 | [diff] [blame] | 548 | extract_tarball $mbedtls_ar $mbedtls_dir --strip-components=1 |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 549 | fi |
| 550 | |
| 551 | emit_env "MBEDTLS_DIR" "$mbedtls_dir" |
| 552 | fi |
Jimmy Brisson | 0d5e12c | 2023-05-16 14:51:51 -0500 | [diff] [blame] | 553 | if [ "$(get_tf_opt PLATFORM_TEST)" = "tfm-testsuite" ] && |
| 554 | not_upon "${TF_M_TESTS_PATH}"; then |
| 555 | emit_env "TF_M_TESTS_PATH" "$WORKSPACE/tf-m-tests" |
| 556 | fi |
| 557 | if [ "$(get_tf_opt PLATFORM_TEST)" = "tfm-testsuite" ] && |
| 558 | not_upon "${TF_M_EXTRAS_PATH}"; then |
| 559 | emit_env "TF_M_EXTRAS_PATH" "$WORKSPACE/tf-m-extras" |
| 560 | fi |
David Vincze | 82db693 | 2024-02-21 12:05:50 +0100 | [diff] [blame] | 561 | if [ "$(get_tf_opt DICE_PROTECTION_ENVIRONMENT)" = 1 ] && |
| 562 | not_upon "${QCBOR_DIR}"; then |
| 563 | emit_env "QCBOR_DIR" "$WORKSPACE/qcbor" |
| 564 | fi |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 565 | if [ -f "$env_file" ]; then |
| 566 | set -a |
| 567 | source "$env_file" |
| 568 | set +a |
| 569 | fi |
| 570 | |
Harrison Mutai | 013f633 | 2022-02-16 16:06:33 +0000 | [diff] [blame] | 571 | if is_arm_jenkins_env || upon "$local_ci"; then |
| 572 | path_list=( |
| 573 | "$llvm_dir/bin" |
| 574 | ) |
| 575 | extend_path "PATH" "path_list" |
| 576 | fi |
| 577 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 578 | cd "$tf_root" |
| 579 | |
| 580 | # Always distclean when running on Jenkins. Skip distclean when running |
| 581 | # locally and explicitly requested. |
| 582 | if upon "$jenkins_run" || not_upon "$dont_clean"; then |
| 583 | make distclean &>>"$build_log" || fail_build |
| 584 | fi |
| 585 | |
| 586 | # Log build command line. It is left unfolded on purpose to assist |
| 587 | # copying to clipboard. |
| 588 | cat <<EOF | log_separator >/dev/null |
| 589 | |
| 590 | Build command line: |
| 591 | $tf_build_wrapper make $make_j_opts $(cat "$config_file" | tr '\n' ' ') DEBUG=$DEBUG V=1 $build_targets |
| 592 | |
Paul Sokolovsky | 7f71b07 | 2023-10-16 12:59:09 +0300 | [diff] [blame] | 593 | CC version: |
| 594 | $(${CC-${CROSS_COMPILE}gcc} -v 2>&1) |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 595 | EOF |
| 596 | |
Javier Almansa Sobrino | e836318 | 2020-11-10 16:40:53 +0000 | [diff] [blame] | 597 | if not_upon "$local_ci"; then |
| 598 | connect_debugger=0 |
| 599 | fi |
| 600 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 601 | # Build TF. Since build output is being directed to the build log, have |
| 602 | # descriptor 3 point to the current terminal for build wrappers to vent. |
Harrison Mutai | 6361dbe | 2023-02-16 14:12:40 +0000 | [diff] [blame] | 603 | $tf_build_wrapper poetry run make $make_j_opts $(cat "$config_file") \ |
Javier Almansa Sobrino | e836318 | 2020-11-10 16:40:53 +0000 | [diff] [blame] | 604 | DEBUG="$DEBUG" V=1 SPIN_ON_BL1_EXIT="$connect_debugger" \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 605 | $build_targets 3>&1 &>>"$build_log" || fail_build |
Harrison Mutai | 32de9d0 | 2023-06-12 14:23:37 +0100 | [diff] [blame] | 606 | |
Harrison Mutai | 6dafb5f | 2023-07-18 15:21:48 +0100 | [diff] [blame] | 607 | if [ "$build_targets" != "doc" ]; then |
Harrison Mutai | 2c2c917 | 2024-04-12 11:24:27 +0000 | [diff] [blame] | 608 | (poetry run memory -sr "$tf_build_root" 2>&1 || true) | tee -a "$build_log" |
Harrison Mutai | 6dafb5f | 2023-07-18 15:21:48 +0100 | [diff] [blame] | 609 | fi |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 610 | ) |
| 611 | } |
| 612 | |
| 613 | build_tftf() { |
| 614 | ( |
| 615 | config_file="${tftf_build_config:-$tftf_config_file}" |
| 616 | |
| 617 | # Build tftf target by default |
| 618 | build_targets="${tftf_build_targets:-all}" |
| 619 | |
| 620 | source "$config_file" |
| 621 | |
| 622 | cd "$tftf_root" |
| 623 | |
| 624 | # Always distclean when running on Jenkins. Skip distclean when running |
| 625 | # locally and explicitly requested. |
| 626 | if upon "$jenkins_run" || not_upon "$dont_clean"; then |
| 627 | make distclean &>>"$build_log" || fail_build |
| 628 | fi |
| 629 | |
| 630 | # TFTF build system cannot reliably deal with -j option, so we avoid |
| 631 | # using that. |
| 632 | |
| 633 | # Log build command line |
| 634 | cat <<EOF | log_separator >/dev/null |
| 635 | |
| 636 | Build command line: |
Boyan Karatotev | 51060ba | 2024-10-29 16:55:10 +0000 | [diff] [blame] | 637 | make $make_j_opts $(cat "$config_file" | tr '\n' ' ') DEBUG=$DEBUG V=1 $build_targets |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 638 | |
| 639 | EOF |
| 640 | |
Boyan Karatotev | 51060ba | 2024-10-29 16:55:10 +0000 | [diff] [blame] | 641 | make $make_j_opts $(cat "$config_file") DEBUG="$DEBUG" V=1 \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 642 | $build_targets &>>"$build_log" || fail_build |
| 643 | ) |
| 644 | } |
| 645 | |
| 646 | build_scp() { |
| 647 | ( |
| 648 | config_file="${scp_build_config:-$scp_config_file}" |
| 649 | |
| 650 | source "$config_file" |
| 651 | |
| 652 | cd "$scp_root" |
| 653 | |
| 654 | # Always distclean when running on Jenkins. Skip distclean when running |
| 655 | # locally and explicitly requested. |
| 656 | if upon "$jenkins_run" || not_upon "$dont_clean"; then |
Leandro Belli | 99e20b2 | 2022-12-29 13:50:47 +0000 | [diff] [blame] | 657 | make -f Makefile.cmake clean &>>"$build_log" || fail_build |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 658 | fi |
| 659 | |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 660 | python3 -m venv .venv |
| 661 | . .venv/bin/activate |
| 662 | |
| 663 | # Install extra tools used by CMake build system |
| 664 | pip install -r requirements.txt --timeout 30 --retries 15 |
| 665 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 666 | # Log build command line. It is left unfolded on purpose to assist |
| 667 | # copying to clipboard. |
| 668 | cat <<EOF | log_separator >/dev/null |
| 669 | |
| 670 | SCP build command line: |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 671 | make -f Makefile.cmake $(cat "$config_file" | tr '\n' ' ') \ |
| 672 | TOOLCHAIN=GNU \ |
| 673 | MODE="$mode" \ |
Nicola Mazzucato | 506b580 | 2021-12-24 14:23:25 +0000 | [diff] [blame] | 674 | EXTRA_CONFIG_ARGS+=-DDISABLE_CPPCHECK=true \ |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 675 | V=1 &>>"$build_log" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 676 | |
| 677 | EOF |
| 678 | |
| 679 | # Build SCP |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 680 | make -f Makefile.cmake $(cat "$config_file" | tr '\n' ' ') \ |
| 681 | TOOLCHAIN=GNU \ |
| 682 | MODE="$mode" \ |
Nicola Mazzucato | 506b580 | 2021-12-24 14:23:25 +0000 | [diff] [blame] | 683 | EXTRA_CONFIG_ARGS+=-DDISABLE_CPPCHECK=true \ |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 684 | V=1 &>>"$build_log" \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 685 | || fail_build |
| 686 | ) |
| 687 | } |
| 688 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 689 | clone_scp_tools() { |
| 690 | |
| 691 | if [ ! -d "$scp_tools_root" ]; then |
| 692 | echo "Cloning SCP-tools ... $scp_tools_commit" |& log_separator |
| 693 | |
| 694 | clone_url="${SCP_TOOLS_CHECKOUT_LOC:-$scp_tools_src_repo_url}" \ |
| 695 | where="$scp_tools_root" \ |
| 696 | refspec="${scp_tools_commit}" |
| 697 | clone_repo &>>"$build_log" |
| 698 | else |
| 699 | echo "Already cloned SCP-tools ..." |& log_separator |
| 700 | fi |
| 701 | |
| 702 | show_head "$scp_tools_root" |
| 703 | |
| 704 | cd "$scp_tools_root" |
| 705 | |
| 706 | echo "Updating submodules" |
| 707 | |
| 708 | git submodule init |
| 709 | |
| 710 | git submodule update |
| 711 | |
Nicola Mazzucato | 9b17142 | 2023-08-29 15:50:49 +0100 | [diff] [blame] | 712 | lib_commit=$(grep "'scmi_lib_commit'" run_tests/settings.py | cut -d':' -f 2 | tr -d "'" | tr -d ",") |
Nicola Mazzucato | 7302cd3 | 2021-12-14 13:36:57 +0000 | [diff] [blame] | 713 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 714 | cd "scmi" |
Nicola Mazzucato | 7302cd3 | 2021-12-14 13:36:57 +0000 | [diff] [blame] | 715 | git checkout $lib_commit |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 716 | |
| 717 | git show --quiet --no-color | sed 's/^/ > /g' |
| 718 | } |
| 719 | |
| 720 | clone_tf_for_scp_tools() { |
| 721 | scp_tools_arm_tf="$scp_tools_root/arm-tf" |
| 722 | |
| 723 | if [ ! -d "$scp_tools_arm_tf" ]; then |
| 724 | echo "Cloning TF-4-SCP-tools ..." |& log_separator |
| 725 | |
| 726 | clone_url="$tf_for_scp_tools_src_repo_url" |
| 727 | where="$scp_tools_arm_tf" |
| 728 | |
| 729 | git clone "$clone_url" "$where" |
| 730 | |
| 731 | cd "$scp_tools_arm_tf" |
| 732 | |
Joel Goddard | 3ad0306 | 2021-03-16 16:47:42 +0000 | [diff] [blame] | 733 | git checkout --track origin/juno-v4.3 |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 734 | |
| 735 | git show --quiet --no-color | sed 's/^/ > /g' |
| 736 | |
| 737 | else |
| 738 | echo "Already cloned TF-4-SCP-tools ..." |& log_separator |
| 739 | fi |
| 740 | } |
| 741 | |
| 742 | build_scmi_lib_scp_tools() { |
| 743 | ( |
| 744 | cd "$scp_tools_root" |
| 745 | |
| 746 | cd "scmi" |
| 747 | |
| 748 | scp_tools_arm_tf="$scp_tools_root/arm-tf" |
| 749 | |
Leonardo Sandoval | feae3a2 | 2020-11-17 16:53:59 -0600 | [diff] [blame] | 750 | cross_compile="$(set_cross_compile_gcc_linaro_toolchain)" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 751 | |
| 752 | std_libs="-I$scp_tools_arm_tf/include/common" |
| 753 | std_libs="$std_libs -I$scp_tools_arm_tf/include/common/tbbr" |
| 754 | std_libs="$std_libs -I$scp_tools_arm_tf/include/drivers/arm" |
| 755 | std_libs="$std_libs -I$scp_tools_arm_tf/include/lib" |
| 756 | std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/aarch64" |
| 757 | std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/stdlib" |
| 758 | std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/stdlib/sys" |
| 759 | std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/xlat_tables" |
| 760 | std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/common" |
| 761 | std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/common" |
| 762 | std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/css/common" |
| 763 | std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/board/common" |
| 764 | std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/soc/common" |
| 765 | std_libs="$std_libs -I$scp_tools_arm_tf/plat/arm/board/juno/include" |
| 766 | |
| 767 | cflags="-Og -g" |
| 768 | cflags="$cflags -mgeneral-regs-only" |
| 769 | cflags="$cflags -mstrict-align" |
| 770 | cflags="$cflags -nostdinc" |
| 771 | cflags="$cflags -fno-inline" |
| 772 | cflags="$cflags -ffreestanding" |
| 773 | cflags="$cflags -ffunction-sections" |
| 774 | cflags="$cflags -fdata-sections" |
| 775 | cflags="$cflags -DAARCH64" |
| 776 | cflags="$cflags -DPRId32=\"ld\"" |
Joel Goddard | 3ad0306 | 2021-03-16 16:47:42 +0000 | [diff] [blame] | 777 | cflags="$cflags -DVERBOSE_LEVEL=3" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 778 | |
| 779 | cflags="$cflags $std_libs" |
| 780 | |
Joel Goddard | 3ad0306 | 2021-03-16 16:47:42 +0000 | [diff] [blame] | 781 | protocols="performance,power_domain,system_power,reset" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 782 | |
| 783 | echo "Building SCMI library (SCP-tools) ..." |
| 784 | |
| 785 | make "CROSS_COMPILE=$cross_compile" \ |
| 786 | "CFLAGS=$cflags" \ |
Joel Goddard | 3ad0306 | 2021-03-16 16:47:42 +0000 | [diff] [blame] | 787 | "PLAT=baremetal" \ |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 788 | "PROTOCOLS=$protocols" \ |
| 789 | "clean" \ |
| 790 | "all" |
| 791 | ) |
| 792 | } |
| 793 | |
| 794 | build_tf_for_scp_tools() { |
| 795 | |
| 796 | cd "$scp_tools_root/arm-tf" |
| 797 | |
Leonardo Sandoval | feae3a2 | 2020-11-17 16:53:59 -0600 | [diff] [blame] | 798 | cross_compile="$(set_cross_compile_gcc_linaro_toolchain)" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 799 | |
| 800 | if [ "$1" = "release" ]; then |
| 801 | echo "Build TF-4-SCP-Tools rls..." |
| 802 | else |
| 803 | echo "Build TF-4-SCP-Tools dbg..." |
| 804 | |
| 805 | make realclean |
| 806 | |
| 807 | make "BM_TEST=scmi" \ |
| 808 | "ARM_BOARD_OPTIMISE_MEM=1" \ |
| 809 | "BM_CSS=juno" \ |
| 810 | "CSS_USE_SCMI_SDS_DRIVER=1" \ |
| 811 | "PLAT=juno" \ |
| 812 | "DEBUG=1" \ |
| 813 | "PLATFORM=juno" \ |
| 814 | "CROSS_COMPILE=$cross_compile" \ |
| 815 | "BM_WORKSPACE=$scp_tools_root/baremetal" |
| 816 | |
| 817 | archive_file "build/juno/debug/bl1.bin" |
| 818 | |
| 819 | archive_file "build/juno/debug/bl2.bin" |
| 820 | |
| 821 | archive_file "build/juno/debug/bl31.bin" |
| 822 | fi |
| 823 | } |
| 824 | |
| 825 | build_fip_for_scp_tools() { |
| 826 | |
| 827 | cd "$scp_tools_root/arm-tf" |
| 828 | |
Leonardo Sandoval | feae3a2 | 2020-11-17 16:53:59 -0600 | [diff] [blame] | 829 | cross_compile="$(set_cross_compile_gcc_linaro_toolchain)" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 830 | |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 831 | if [ ! -d "$scp_root/build/juno/GNU/debug/firmware-scp_ramfw" ]; then |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 832 | make fiptool |
| 833 | echo "Make FIP 4 SCP-Tools rls..." |
| 834 | |
| 835 | else |
| 836 | make fiptool |
| 837 | echo "Make FIP 4 SCP-Tools dbg..." |
| 838 | |
| 839 | make "PLAT=juno" \ |
| 840 | "all" \ |
| 841 | "fip" \ |
| 842 | "DEBUG=1" \ |
| 843 | "CROSS_COMPILE=$cross_compile" \ |
| 844 | "BL31=$scp_tools_root/arm-tf/build/juno/debug/bl31.bin" \ |
| 845 | "BL33=$scp_tools_root/baremetal/dummy_bl33" \ |
Joel Goddard | 9bdfe3c | 2021-02-25 10:15:14 +0000 | [diff] [blame] | 846 | "SCP_BL2=$scp_root/build/juno/GNU/$mode/firmware-scp_ramfw/bin/juno-bl2.bin" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 847 | |
| 848 | archive_file "$scp_tools_root/arm-tf/build/juno/debug/fip.bin" |
| 849 | fi |
| 850 | } |
| 851 | |
| 852 | build_cc() { |
| 853 | # Building code coverage plugin |
| 854 | ARM_DIR=/arm |
| 855 | pvlibversion=$(/arm/devsys-tools/abs/detag "SysGen:PVModelLib:$model_version::trunk") |
| 856 | PVLIB_HOME=$warehouse/SysGen/PVModelLib/$model_version/${pvlibversion}/external |
| 857 | if [ -n "$(find "$ARM_DIR" -maxdepth 0 -type d -empty 2>/dev/null)" ]; then |
| 858 | echo "Error: Arm warehouse not mounted. Please mount the Arm warehouse to your /arm local folder" |
| 859 | exit -1 |
| 860 | fi # Error if arm warehouse not found |
| 861 | cd "$ccpathspec/scripts/tools/code_coverage/fastmodel_baremetal/bmcov" |
| 862 | |
| 863 | make -C model-plugin PVLIB_HOME=$PVLIB_HOME &>>"$build_log" |
| 864 | } |
| 865 | |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 866 | build_spm() { |
| 867 | ( |
| 868 | env_file="$workspace/spm.env" |
| 869 | config_file="${spm_build_config:-$spm_config_file}" |
| 870 | |
| 871 | source "$config_file" |
| 872 | |
| 873 | if [ -f "$env_file" ]; then |
| 874 | set -a |
| 875 | source "$env_file" |
| 876 | set +a |
| 877 | fi |
| 878 | |
| 879 | cd "$spm_root" |
| 880 | |
| 881 | # Always clean when running on Jenkins. Skip clean when running |
| 882 | # locally and explicitly requested. |
| 883 | if upon "$jenkins_run" || not_upon "$dont_clean"; then |
| 884 | # make clean fails on a fresh repo where the project has not |
| 885 | # yet been built. Hence only clean if out/reference directory |
| 886 | # already exists. |
| 887 | if [ -d "out/reference" ]; then |
| 888 | make clean &>>"$build_log" || fail_build |
| 889 | fi |
| 890 | fi |
| 891 | |
| 892 | # Log build command line. It is left unfolded on purpose to assist |
| 893 | # copying to clipboard. |
| 894 | cat <<EOF | log_separator >/dev/null |
| 895 | |
| 896 | Build command line: |
| 897 | make $make_j_opts $(cat "$config_file" | tr '\n' ' ') |
| 898 | |
| 899 | EOF |
| 900 | |
| 901 | # Build SPM. Since build output is being directed to the build log, have |
| 902 | # descriptor 3 point to the current terminal for build wrappers to vent. |
| 903 | make $make_j_opts $(cat "$config_file") 3>&1 &>>"$build_log" \ |
| 904 | || fail_build |
| 905 | ) |
| 906 | } |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 907 | |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 908 | build_rmm() { |
| 909 | ( |
| 910 | env_file="$workspace/rmm.env" |
| 911 | config_file="${rmm_build_config:-$rmm_config_file}" |
| 912 | |
| 913 | # Build fiptool and all targets by default |
| 914 | build_targets="${rmm_build_targets}" |
| 915 | export CROSS_COMPILE="${aarch64_none_elf_prefix}" |
| 916 | |
| 917 | source "$config_file" |
| 918 | |
| 919 | if [ -f "$env_file" ]; then |
| 920 | set -a |
| 921 | source "$env_file" |
| 922 | set +a |
| 923 | fi |
| 924 | |
| 925 | cd "$rmm_root" |
| 926 | |
| 927 | if [ -f "$rmm_root/requirements.txt" ]; then |
| 928 | export PATH="$HOME/.local/bin:$PATH" |
| 929 | python3 -m pip install --upgrade pip |
| 930 | python3 -m pip install -r "$rmm_root/requirements.txt" |
| 931 | fi |
| 932 | |
| 933 | # Always distclean when running on Jenkins. Skip distclean when running |
| 934 | # locally and explicitly requested. |
| 935 | if upon "$jenkins_run" || not_upon "$dont_clean"; then |
| 936 | # Remove 'rmm\build' folder |
| 937 | echo "Removing $rmm_build_root..." |
| 938 | rm -rf $rmm_build_root |
| 939 | fi |
| 940 | |
| 941 | # Log build command line. It is left unfolded on purpose to assist |
| 942 | # copying to clipboard. |
| 943 | cat <<EOF | log_separator >/dev/null |
| 944 | |
| 945 | Build command line: |
| 946 | cmake -DRMM_CONFIG=${plat}_defcfg $cmake_gen -S $rmm_root -B $rmm_build_root -DCMAKE_BUILD_TYPE=$cmake_build_type |
| 947 | cmake --build $rmm_build_root $make_j_opts -v |
| 948 | EOF |
| 949 | if not_upon "$local_ci"; then |
| 950 | connect_debugger=0 |
| 951 | fi |
| 952 | |
| 953 | cmake -DRMM_CONFIG=${plat}_defcfg $cmake_gen -S $rmm_root -B $rmm_build_root -DCMAKE_BUILD_TYPE=$cmake_build_type |
| 954 | cmake --build $rmm_build_root $make_j_opts -v 3>&1 &>>"$build_log" || fail_build |
| 955 | ) |
| 956 | } |
| 957 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 958 | # Set metadata for the whole package so that it can be used by both Jenkins and |
| 959 | # shell |
| 960 | set_package_var() { |
| 961 | env_file="$artefacts/env" emit_env "$@" |
| 962 | } |
| 963 | |
| 964 | set_tf_build_targets() { |
| 965 | echo "Set build target to '${targets:?}'" |
| 966 | set_hook_var "tf_build_targets" "$targets" |
| 967 | } |
| 968 | |
| 969 | set_tftf_build_targets() { |
| 970 | echo "Set build target to '${targets:?}'" |
| 971 | set_hook_var "tftf_build_targets" "$targets" |
| 972 | } |
| 973 | |
| 974 | set_scp_build_targets() { |
| 975 | echo "Set build target to '${targets:?}'" |
| 976 | set_hook_var "scp_build_targets" "$targets" |
| 977 | } |
| 978 | |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 979 | set_spm_build_targets() { |
| 980 | echo "Set build target to '${targets:?}'" |
| 981 | set_hook_var "spm_build_targets" "$targets" |
| 982 | } |
| 983 | |
Daniel Boulby | b8d2a46 | 2022-03-07 13:55:25 +0000 | [diff] [blame] | 984 | set_spm_out_dir() { |
| 985 | echo "Set SPMC binary build to '${out_dir:?}'" |
| 986 | set_hook_var "spm_secure_out_dir" "$out_dir" |
| 987 | } |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 988 | # Look under $archive directory for known files such as blX images, kernel, DTB, |
| 989 | # initrd etc. For each known file foo, if foo.bin exists, then set variable |
| 990 | # foo_bin to the path of the file. Make the path relative to the workspace so as |
| 991 | # to remove any @ characters, which Jenkins inserts for parallel runs. If the |
| 992 | # file doesn't exist, unset its path. |
| 993 | set_default_bin_paths() { |
| 994 | local image image_name image_path path |
| 995 | local archive="${archive:?}" |
| 996 | local set_vars |
| 997 | local var |
| 998 | |
| 999 | pushd "$archive" |
| 1000 | |
| 1001 | for file in *.bin; do |
| 1002 | # Get a shell variable from the file's stem |
| 1003 | var_name="${file%%.*}_bin" |
| 1004 | var_name="$(echo "$var_name" | sed -r 's/[^[:alnum:]]/_/g')" |
| 1005 | |
| 1006 | # Skip setting the variable if it's already |
| 1007 | if [ "${!var_name}" ]; then |
| 1008 | echo "Note: not setting $var_name; already set to ${!var_name}" |
| 1009 | continue |
| 1010 | else |
| 1011 | set_vars+="$var_name " |
| 1012 | fi |
| 1013 | |
| 1014 | eval "$var_name=$file" |
| 1015 | done |
| 1016 | |
| 1017 | echo "Binary paths set for: " |
| 1018 | { |
| 1019 | for var in $set_vars; do |
| 1020 | echo -n "\$$var " |
| 1021 | done |
| 1022 | } | fmt -80 | sed 's/^/ /' |
| 1023 | echo |
| 1024 | |
| 1025 | popd |
| 1026 | } |
| 1027 | |
| 1028 | gen_model_params() { |
| 1029 | local model_param_file="$archive/model_params" |
Javier Almansa Sobrino | e836318 | 2020-11-10 16:40:53 +0000 | [diff] [blame] | 1030 | [ "$connect_debugger" ] && [ "$connect_debugger" -eq 1 ] && wait_debugger=1 |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1031 | |
| 1032 | set_default_bin_paths |
| 1033 | echo "Generating model parameter for $model..." |
| 1034 | source "$ci_root/model/${model:?}.sh" |
| 1035 | archive_file "$model_param_file" |
| 1036 | } |
| 1037 | |
| 1038 | set_model_path() { |
| 1039 | set_run_env "model_path" "${1:?}" |
| 1040 | } |
| 1041 | |
Zelalem | 1af7a7b | 2020-08-04 17:34:32 -0500 | [diff] [blame] | 1042 | set_model_env() { |
| 1043 | local var="${1:?}" |
| 1044 | local val="${2?}" |
| 1045 | local run_root="${archive:?}/run" |
| 1046 | |
| 1047 | mkdir -p "$run_root" |
| 1048 | echo "export $var=$val" >> "$run_root/model_env" |
| 1049 | } |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1050 | set_run_env() { |
| 1051 | local var="${1:?}" |
| 1052 | local val="${2?}" |
| 1053 | local run_root="${archive:?}/run" |
| 1054 | |
| 1055 | mkdir -p "$run_root" |
| 1056 | env_file="$run_root/env" quote="1" emit_env "$var" "$val" |
| 1057 | } |
| 1058 | |
| 1059 | show_head() { |
| 1060 | # Display HEAD descripton |
| 1061 | pushd "$1" |
| 1062 | git show --quiet --no-color | sed 's/^/ > /g' |
| 1063 | echo |
| 1064 | popd |
| 1065 | } |
| 1066 | |
| 1067 | # Choose debug binaries to run; by default, release binaries are chosen to run |
| 1068 | use_debug_bins() { |
| 1069 | local run_root="${archive:?}/run" |
| 1070 | |
| 1071 | echo "Choosing debug binaries for execution" |
| 1072 | set_package_var "BIN_MODE" "debug" |
| 1073 | } |
| 1074 | |
| 1075 | assert_can_git_clone() { |
| 1076 | local name="${1:?}" |
| 1077 | local dir="${!name}" |
| 1078 | |
| 1079 | # If it doesn't exist, it can be cloned into |
| 1080 | if [ ! -e "$dir" ]; then |
| 1081 | return 0 |
| 1082 | fi |
| 1083 | |
| 1084 | # If it's a directory, it must be a Git clone already |
| 1085 | if [ -d "$dir" ] && [ -d "$dir/.git" ]; then |
| 1086 | # No need to clone again |
| 1087 | echo "Using existing git clone for $name: $dir" |
| 1088 | return 1 |
| 1089 | fi |
| 1090 | |
| 1091 | die "Path $dir exists but is not a git clone" |
| 1092 | } |
| 1093 | |
| 1094 | clone_repo() { |
| 1095 | if ! is_url "${clone_url?}"; then |
| 1096 | # For --depth to take effect on local paths, it needs to use the |
| 1097 | # file:// scheme. |
| 1098 | clone_url="file://$clone_url" |
| 1099 | fi |
| 1100 | |
| 1101 | git clone -q --depth 1 "$clone_url" "${where?}" |
| 1102 | if [ "$refspec" ]; then |
| 1103 | pushd "$where" |
| 1104 | git fetch -q --depth 1 origin "$refspec" |
| 1105 | git checkout -q FETCH_HEAD |
| 1106 | popd |
| 1107 | fi |
| 1108 | } |
| 1109 | |
| 1110 | build_unstable() { |
| 1111 | echo "--BUILD UNSTABLE--" | tee -a "$build_log" |
| 1112 | } |
| 1113 | |
| 1114 | undo_patch_record() { |
| 1115 | if [ ! -f "${patch_record:?}" ]; then |
| 1116 | return |
| 1117 | fi |
| 1118 | |
| 1119 | # Undo patches in reverse |
| 1120 | echo |
| 1121 | for patch_name in $(tac "$patch_record"); do |
| 1122 | echo "Undoing $patch_name..." |
| 1123 | if ! git apply -R "$ci_root/patch/$patch_name"; then |
| 1124 | if upon "$local_ci"; then |
| 1125 | echo |
| 1126 | echo "Your local directory may have been dirtied." |
| 1127 | echo |
| 1128 | fi |
| 1129 | fail_build |
| 1130 | fi |
| 1131 | done |
| 1132 | |
| 1133 | rm -f "$patch_record" |
| 1134 | } |
| 1135 | |
| 1136 | undo_local_patches() { |
| 1137 | pushd "$tf_root" |
| 1138 | patch_record="$tf_patch_record" undo_patch_record |
| 1139 | popd |
| 1140 | |
| 1141 | if [ -d "$tftf_root" ]; then |
| 1142 | pushd "$tftf_root" |
| 1143 | patch_record="$tftf_patch_record" undo_patch_record |
| 1144 | popd |
| 1145 | fi |
| 1146 | } |
| 1147 | |
| 1148 | undo_tftf_patches() { |
| 1149 | pushd "$tftf_root" |
| 1150 | patch_record="$tftf_patch_record" undo_patch_record |
| 1151 | popd |
| 1152 | } |
| 1153 | |
| 1154 | undo_tf_patches() { |
| 1155 | pushd "$tf_root" |
| 1156 | patch_record="$tf_patch_record" undo_patch_record |
| 1157 | popd |
| 1158 | } |
| 1159 | |
| 1160 | apply_patch() { |
| 1161 | # If skip_patches is set, the developer has applied required patches |
| 1162 | # manually. They probably want to keep them applied for debugging |
| 1163 | # purposes too. This means we don't have to apply/revert them as part of |
| 1164 | # build process. |
| 1165 | if upon "$skip_patches"; then |
| 1166 | echo "Skipped applying ${1:?}..." |
| 1167 | return 0 |
| 1168 | else |
| 1169 | echo "Applying ${1:?}..." |
| 1170 | fi |
| 1171 | |
Sandrine Bailleux | 4cb8c22 | 2023-09-13 13:48:15 +0200 | [diff] [blame] | 1172 | if git apply --reverse --check < "$ci_root/patch/$1" 2> /dev/null; then |
Jimmy Brisson | f134e4c | 2023-03-22 13:20:20 -0500 | [diff] [blame] | 1173 | echo "Skipping already applied ${1:?}" |
| 1174 | return 0 |
| 1175 | fi |
| 1176 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1177 | if git apply < "$ci_root/patch/$1"; then |
| 1178 | echo "$1" >> "${patch_record:?}" |
| 1179 | else |
| 1180 | if upon "$local_ci"; then |
| 1181 | undo_local_patches |
| 1182 | fi |
| 1183 | fail_build |
| 1184 | fi |
| 1185 | } |
| 1186 | |
| 1187 | apply_tftf_patch() { |
| 1188 | pushd "$tftf_root" |
| 1189 | patch_record="$tftf_patch_record" apply_patch "$1" |
| 1190 | popd |
| 1191 | } |
| 1192 | |
| 1193 | apply_tf_patch() { |
| 1194 | pushd "$tf_root" |
| 1195 | patch_record="$tf_patch_record" apply_patch "$1" |
| 1196 | popd |
| 1197 | } |
| 1198 | |
| 1199 | # Clear workspace for a local run |
Leandro Belli | be7b8fa | 2024-07-18 10:14:22 +0100 | [diff] [blame] | 1200 | if not_upon "$jenkins_run" && not_upon "$dont_clean"; then |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1201 | rm -rf "$workspace" |
| 1202 | |
| 1203 | # Clear residue from previous runs |
| 1204 | rm -rf "$archive" |
| 1205 | fi |
| 1206 | |
| 1207 | mkdir -p "$workspace" |
| 1208 | mkdir -p "$archive" |
| 1209 | set_package_var "TEST_CONFIG" "$test_config" |
| 1210 | |
| 1211 | { |
| 1212 | echo |
| 1213 | echo "CONFIGURATION: $test_group/$test_config" |
| 1214 | echo |
| 1215 | } |& log_separator |
| 1216 | |
| 1217 | tf_config="$(echo "$build_configs" | awk -F, '{print $1}')" |
| 1218 | tftf_config="$(echo "$build_configs" | awk -F, '{print $2}')" |
| 1219 | scp_config="$(echo "$build_configs" | awk -F, '{print $3}')" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1220 | scp_tools_config="$(echo "$build_configs" | awk -F, '{print $4}')" |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1221 | spm_config="$(echo "$build_configs" | awk -F, '{print $5}')" |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1222 | rmm_config="$(echo "$build_configs" | awk -F, '{print $6}')" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1223 | |
| 1224 | test_config_file="$ci_root/group/$test_group/$test_config" |
| 1225 | |
| 1226 | tf_config_file="$ci_root/tf_config/$tf_config" |
| 1227 | tftf_config_file="$ci_root/tftf_config/$tftf_config" |
| 1228 | scp_config_file="$ci_root/scp_config/$scp_config" |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1229 | scp_tools_config_file="$ci_root/scp_tools_config/$scp_tools_config" |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1230 | spm_config_file="$ci_root/spm_config/$spm_config" |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1231 | rmm_config_file="$ci_root/rmm_config/$rmm_config" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1232 | |
| 1233 | # File that keeps track of applied patches |
| 1234 | tf_patch_record="$workspace/tf_patches" |
| 1235 | tftf_patch_record="$workspace/tftf_patches" |
| 1236 | |
| 1237 | pushd "$workspace" |
| 1238 | |
| 1239 | if ! config_valid "$tf_config"; then |
| 1240 | tf_config= |
| 1241 | else |
| 1242 | echo "Trusted Firmware config:" |
| 1243 | echo |
| 1244 | sort "$tf_config_file" | sed '/^\s*$/d;s/^/\t/' |
| 1245 | echo |
| 1246 | fi |
| 1247 | |
| 1248 | if ! config_valid "$tftf_config"; then |
| 1249 | tftf_config= |
| 1250 | else |
| 1251 | echo "Trusted Firmware TF config:" |
| 1252 | echo |
| 1253 | sort "$tftf_config_file" | sed '/^\s*$/d;s/^/\t/' |
| 1254 | echo |
| 1255 | fi |
| 1256 | |
| 1257 | if ! config_valid "$scp_config"; then |
| 1258 | scp_config= |
| 1259 | else |
| 1260 | echo "SCP firmware config:" |
| 1261 | echo |
| 1262 | sort "$scp_config_file" | sed '/^\s*$/d;s/^/\t/' |
| 1263 | echo |
| 1264 | fi |
| 1265 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1266 | if ! config_valid "$scp_tools_config"; then |
| 1267 | scp_tools_config= |
| 1268 | else |
| 1269 | echo "SCP Tools config:" |
| 1270 | echo |
| 1271 | sort "$scp_tools_config_file" | sed '/^\s*$/d;s/^/\t/' |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1272 | fi |
| 1273 | |
| 1274 | if ! config_valid "$spm_config"; then |
| 1275 | spm_config= |
| 1276 | else |
| 1277 | echo "SPM config:" |
| 1278 | echo |
| 1279 | sort "$spm_config_file" | sed '/^\s*$/d;s/^/\t/' |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1280 | echo |
| 1281 | fi |
| 1282 | |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1283 | # File that keeps track of applied patches |
| 1284 | rmm_patch_record="$workspace/rmm_patches" |
| 1285 | |
| 1286 | if ! config_valid "$rmm_config"; then |
| 1287 | rmm_config= |
| 1288 | else |
| 1289 | echo "Trusted Firmware RMM config:" |
| 1290 | echo |
| 1291 | sort "$rmm_config_file" | sed '/^\s*$/d;s/^/\t/' |
| 1292 | echo |
| 1293 | fi |
| 1294 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1295 | if ! config_valid "$run_config"; then |
| 1296 | run_config= |
| 1297 | fi |
| 1298 | |
| 1299 | if [ "$tf_config" ] && assert_can_git_clone "tf_root"; then |
| 1300 | # If the Trusted Firmware repository has already been checked out, use |
| 1301 | # that location. Otherwise, clone one ourselves. |
| 1302 | echo "Cloning Trusted Firmware..." |
| 1303 | clone_url="${TF_CHECKOUT_LOC:-$tf_src_repo_url}" where="$tf_root" \ |
| 1304 | refspec="$TF_REFSPEC" clone_repo &>>"$build_log" |
| 1305 | show_head "$tf_root" |
| 1306 | fi |
| 1307 | |
| 1308 | if [ "$tftf_config" ] && assert_can_git_clone "tftf_root"; then |
| 1309 | # If the Trusted Firmware TF repository has already been checked out, |
| 1310 | # use that location. Otherwise, clone one ourselves. |
| 1311 | echo "Cloning Trusted Firmware TF..." |
| 1312 | clone_url="${TFTF_CHECKOUT_LOC:-$tftf_src_repo_url}" where="$tftf_root" \ |
| 1313 | refspec="$TFTF_REFSPEC" clone_repo &>>"$build_log" |
| 1314 | show_head "$tftf_root" |
| 1315 | fi |
| 1316 | |
| 1317 | if [ "$scp_config" ] && assert_can_git_clone "scp_root"; then |
| 1318 | # If the SCP firmware repository has already been checked out, |
| 1319 | # use that location. Otherwise, clone one ourselves. |
| 1320 | echo "Cloning SCP Firmware..." |
| 1321 | clone_url="${SCP_CHECKOUT_LOC:-$scp_src_repo_url}" where="$scp_root" \ |
| 1322 | refspec="${SCP_REFSPEC-master-upstream}" clone_repo &>>"$build_log" |
| 1323 | |
| 1324 | pushd "$scp_root" |
| 1325 | |
| 1326 | # Use filer submodule as a reference if it exists |
Girish Pathak | 31b824e | 2021-03-03 20:58:21 +0000 | [diff] [blame] | 1327 | if [ -d "$SCP_CHECKOUT_LOC/cmsis" ]; then |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1328 | cmsis_reference="--reference $SCP_CHECKOUT_LOC/cmsis" |
| 1329 | fi |
| 1330 | |
| 1331 | # If we don't have a reference yet, fall back to $cmsis_root if set, or |
| 1332 | # then to project filer if accessible. |
| 1333 | if [ -z "$cmsis_reference" ]; then |
| 1334 | cmsis_ref_repo="${cmsis_root:-$project_filer/ref-repos/cmsis}" |
| 1335 | if [ -d "$cmsis_ref_repo" ]; then |
| 1336 | cmsis_reference="--reference $cmsis_ref_repo" |
| 1337 | fi |
| 1338 | fi |
| 1339 | |
| 1340 | git submodule -q update $cmsis_reference --init |
| 1341 | |
| 1342 | popd |
| 1343 | |
| 1344 | show_head "$scp_root" |
| 1345 | fi |
| 1346 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1347 | if [ -n "$cc_config" ] ; then |
| 1348 | if [ "$cc_config" -eq 1 ] && assert_can_git_clone "cc_root"; then |
| 1349 | # Copy code coverage repository |
| 1350 | echo "Cloning Code Coverage..." |
| 1351 | git clone -q $cc_src_repo_url cc_plugin --depth 1 -b $cc_src_repo_tag > /dev/null |
| 1352 | show_head "$cc_root" |
| 1353 | fi |
| 1354 | fi |
| 1355 | |
Daniel Boulby | 25385ab | 2023-12-14 14:36:25 +0000 | [diff] [blame] | 1356 | if [ "$spm_config" ] ; then |
| 1357 | if assert_can_git_clone "spm_root"; then |
| 1358 | # If the SPM repository has already been checked out, use |
| 1359 | # that location. Otherwise, clone one ourselves. |
| 1360 | echo "Cloning SPM..." |
| 1361 | clone_url="${SPM_CHECKOUT_LOC:-$spm_src_repo_url}" \ |
| 1362 | where="$spm_root" refspec="$SPM_REFSPEC" \ |
| 1363 | clone_repo &>>"$build_log" |
| 1364 | fi |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1365 | |
| 1366 | # Query git submodules |
| 1367 | pushd "$spm_root" |
Daniel Boulby | 25385ab | 2023-12-14 14:36:25 +0000 | [diff] [blame] | 1368 | # Check if submodules need initialising |
Paul Sokolovsky | ad27442 | 2024-09-01 10:27:56 +0300 | [diff] [blame] | 1369 | |
| 1370 | # This handling is needed to reliably fetch submodules |
| 1371 | # in CI environment. |
| 1372 | for subm in $(git submodule status | awk '/^-/ {print $2}'); do |
| 1373 | for i in $(seq 1 7); do |
| 1374 | git submodule init $subm |
| 1375 | if git submodule update $subm; then |
| 1376 | break |
| 1377 | fi |
| 1378 | git submodule deinit --force $subm |
| 1379 | echo "Retrying $subm" |
| 1380 | sleep $((RANDOM % 10 + 5)) |
| 1381 | done |
| 1382 | done |
| 1383 | |
| 1384 | git submodule status |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1385 | popd |
| 1386 | |
| 1387 | show_head "$spm_root" |
| 1388 | fi |
| 1389 | |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1390 | if [ "$rmm_config" ] && assert_can_git_clone "rmm_root"; then |
Manish V Badarkhe | 4190945 | 2025-04-11 12:06:45 +0100 | [diff] [blame^] | 1391 | # If the RMM repository has already been checked out, |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1392 | # use that location. Otherwise, clone one ourselves. |
| 1393 | echo "Cloning TF-RMM..." |
| 1394 | clone_url="${RMM_CHECKOUT_LOC:-$rmm_src_repo_url}" where="$rmm_root" \ |
| 1395 | refspec="$RMM_REFSPEC" clone_repo &>>"$build_log" |
| 1396 | show_head "$rmm_root" |
| 1397 | fi |
| 1398 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1399 | if [ "$run_config" ]; then |
| 1400 | # Get candidates for run config |
Nicola Mazzucato | 7fc5abd | 2024-02-23 21:32:48 +0000 | [diff] [blame] | 1401 | run_config_candidates="$("$ci_root/script/gen_run_config_candidates.py" \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1402 | "$run_config")" |
Nicola Mazzucato | 7fc5abd | 2024-02-23 21:32:48 +0000 | [diff] [blame] | 1403 | if [ -z "$run_config_candidates" ]; then |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1404 | die "No run config candidates!" |
| 1405 | else |
| 1406 | echo |
| 1407 | echo "Chosen fragments:" |
| 1408 | echo |
Nicola Mazzucato | 7fc5abd | 2024-02-23 21:32:48 +0000 | [diff] [blame] | 1409 | echo "$run_config_candidates" | sed 's/^\|\n/\t/g' |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1410 | echo |
Harrison Mutai | 4dfe119 | 2024-07-03 12:35:38 +0000 | [diff] [blame] | 1411 | |
| 1412 | if [ ! -n "$bin_mode" ]; then |
| 1413 | if echo $run_config_candidates | grep -wq "debug"; then |
| 1414 | bin_mode="debug" |
| 1415 | else |
| 1416 | bin_mode="release" |
| 1417 | fi |
| 1418 | fi |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1419 | fi |
| 1420 | fi |
| 1421 | |
| 1422 | call_hook "test_setup" |
| 1423 | echo |
| 1424 | |
| 1425 | if upon "$local_ci"; then |
| 1426 | # For local runs, since each config is tried in sequence, it's |
| 1427 | # advantageous to run jobs in parallel |
| 1428 | if [ "$make_j" ]; then |
| 1429 | make_j_opts="-j $make_j" |
| 1430 | else |
| 1431 | n_cores="$(getconf _NPROCESSORS_ONLN)" 2>/dev/null || true |
| 1432 | if [ "$n_cores" ]; then |
| 1433 | make_j_opts="-j $n_cores" |
| 1434 | fi |
| 1435 | fi |
| 1436 | fi |
| 1437 | |
Harrison Mutai | 07043e9 | 2023-07-06 09:41:12 +0100 | [diff] [blame] | 1438 | # Install python build dependencies |
| 1439 | if is_arm_jenkins_env; then |
| 1440 | source "$ci_root/script/install_python_deps.sh" |
| 1441 | fi |
| 1442 | |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1443 | # Print CMake version |
| 1444 | cmake_ver=$(echo `cmake --version | sed -n '1p'`) |
| 1445 | echo "Using $cmake_ver" |
| 1446 | |
| 1447 | # Check for Ninja |
| 1448 | if [ -x "$(command -v ninja)" ]; then |
| 1449 | # Print Ninja version |
| 1450 | ninja_ver=$(echo `ninja --version | sed -n '1p'`) |
| 1451 | echo "Using ninja $ninja_ver" |
| 1452 | export cmake_gen="-G Ninja" |
| 1453 | else |
| 1454 | echo 'Ninja is not installed' |
| 1455 | export cmake_gen="" |
| 1456 | fi |
| 1457 | |
| 1458 | undo_rmm_patches() { |
| 1459 | pushd "$rmm_root" |
| 1460 | patch_record="$rmm_patch_record" undo_patch_record |
| 1461 | popd |
| 1462 | } |
| 1463 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1464 | modes="${bin_mode:-debug release}" |
| 1465 | for mode in $modes; do |
Paul Sokolovsky | e9962cd | 2021-12-17 18:39:40 +0300 | [diff] [blame] | 1466 | echo "===== Building package in mode: $mode =====" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1467 | # Build with a temporary archive |
| 1468 | build_archive="$archive/$mode" |
| 1469 | mkdir "$build_archive" |
| 1470 | |
| 1471 | if [ "$mode" = "debug" ]; then |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1472 | export bin_mode="debug" |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1473 | cmake_build_type="Debug" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1474 | DEBUG=1 |
| 1475 | else |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1476 | export bin_mode="release" |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1477 | cmake_build_type="Release" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1478 | DEBUG=0 |
| 1479 | fi |
| 1480 | |
| 1481 | # Perform builds in a subshell so as not to pollute the current and |
| 1482 | # subsequent builds' environment |
| 1483 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1484 | if config_valid "$cc_config"; then |
| 1485 | # Build code coverage plugin |
| 1486 | build_cc |
| 1487 | fi |
| 1488 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1489 | # SCP build |
| 1490 | if config_valid "$scp_config"; then |
| 1491 | ( |
| 1492 | echo "##########" |
| 1493 | |
| 1494 | # Source platform-specific utilities |
| 1495 | plat="$(get_scp_opt PRODUCT)" |
| 1496 | plat_utils="$ci_root/${plat}_utils.sh" |
| 1497 | if [ -f "$plat_utils" ]; then |
| 1498 | source "$plat_utils" |
| 1499 | fi |
| 1500 | |
| 1501 | archive="$build_archive" |
| 1502 | scp_build_root="$scp_root/build" |
| 1503 | |
| 1504 | echo "Building SCP Firmware ($mode) ..." |& log_separator |
| 1505 | |
| 1506 | build_scp |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1507 | to="$archive" collect_scp_artefacts |
| 1508 | |
| 1509 | echo "##########" |
| 1510 | echo |
| 1511 | ) |
| 1512 | fi |
| 1513 | |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1514 | # SCP-tools build |
| 1515 | if config_valid "$scp_tools_config"; then |
| 1516 | ( |
| 1517 | echo "##########" |
| 1518 | |
| 1519 | archive="$build_archive" |
| 1520 | scp_tools_build_root="$scp_tools_root/build" |
| 1521 | |
| 1522 | clone_scp_tools |
| 1523 | |
| 1524 | echo "##########" |
| 1525 | echo |
| 1526 | |
| 1527 | echo "##########" |
| 1528 | clone_tf_for_scp_tools |
| 1529 | echo "##########" |
| 1530 | echo |
| 1531 | ) |
| 1532 | fi |
| 1533 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1534 | # TFTF build |
| 1535 | if config_valid "$tftf_config"; then |
| 1536 | ( |
| 1537 | echo "##########" |
| 1538 | |
Manish V Badarkhe | 3bd3fea | 2020-11-08 15:17:00 +0000 | [diff] [blame] | 1539 | plat_utils="$(get_tf_opt PLAT_UTILS)" |
| 1540 | if [ -z ${plat_utils} ]; then |
| 1541 | # Source platform-specific utilities. |
| 1542 | plat="$(get_tftf_opt PLAT)" |
| 1543 | plat_utils="$ci_root/${plat}_utils.sh" |
| 1544 | else |
| 1545 | # Source platform-specific utilities by |
| 1546 | # using plat_utils name. |
| 1547 | plat_utils="$ci_root/${plat_utils}.sh" |
| 1548 | fi |
| 1549 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1550 | if [ -f "$plat_utils" ]; then |
| 1551 | source "$plat_utils" |
| 1552 | fi |
| 1553 | |
| 1554 | archive="$build_archive" |
| 1555 | tftf_build_root="$tftf_root/build" |
| 1556 | |
| 1557 | echo "Building Trusted Firmware TF ($mode) ..." |& log_separator |
| 1558 | |
| 1559 | # Call pre-build hook |
| 1560 | call_hook pre_tftf_build |
| 1561 | |
| 1562 | build_tftf |
| 1563 | |
| 1564 | from="$tftf_build_root" to="$archive" collect_build_artefacts |
| 1565 | |
| 1566 | # Clear any local changes made by applied patches |
| 1567 | undo_tftf_patches |
| 1568 | |
| 1569 | echo "##########" |
| 1570 | echo |
| 1571 | ) |
| 1572 | fi |
| 1573 | |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1574 | # SPM build |
| 1575 | if config_valid "$spm_config"; then |
| 1576 | ( |
| 1577 | echo "##########" |
| 1578 | |
| 1579 | # Get platform name from spm_config file |
| 1580 | plat="$(echo "$spm_config" | awk -F- '{print $1}')" |
| 1581 | plat_utils="$ci_root/${plat}_utils.sh" |
| 1582 | if [ -f "$plat_utils" ]; then |
| 1583 | source "$plat_utils" |
| 1584 | fi |
| 1585 | |
Daniel Boulby | b8d2a46 | 2022-03-07 13:55:25 +0000 | [diff] [blame] | 1586 | # Call pre-build hook |
| 1587 | call_hook pre_spm_build |
| 1588 | |
Manish Pandey | 1e7be85 | 2020-11-09 16:04:48 +0000 | [diff] [blame] | 1589 | # SPM build generates two sets of binaries, one for normal and other |
| 1590 | # for Secure world. We need both set of binaries for CI. |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1591 | archive="$build_archive" |
Manish Pandey | 1e7be85 | 2020-11-09 16:04:48 +0000 | [diff] [blame] | 1592 | spm_build_root="$spm_root/out/reference/$spm_secure_out_dir" |
| 1593 | hafnium_build_root="$spm_root/out/reference/$spm_non_secure_out_dir" |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1594 | |
Daniel Boulby | b8d2a46 | 2022-03-07 13:55:25 +0000 | [diff] [blame] | 1595 | echo "spm_build_root is $spm_build_root" |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1596 | echo "Building SPM ($mode) ..." |& log_separator |
| 1597 | |
| 1598 | # NOTE: mode has no effect on SPM build (for now), hence debug |
| 1599 | # mode is built but subsequent build using release mode just |
| 1600 | # goes through with "nothing to do". |
| 1601 | build_spm |
| 1602 | |
| 1603 | # Show SPM/Hafnium binary details |
Madhukar Pappireddy | c683cf6 | 2021-11-01 14:38:32 -0500 | [diff] [blame] | 1604 | cksum $spm_build_root/hafnium.bin |
| 1605 | |
| 1606 | # Some platforms only have secure configuration enabled. Hence, |
| 1607 | # non secure hanfnium binary might not be built. |
| 1608 | if [ -f $hafnium_build_root/hafnium.bin ]; then |
| 1609 | cksum $hafnium_build_root/hafnium.bin |
| 1610 | fi |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1611 | |
Manish Pandey | 1e7be85 | 2020-11-09 16:04:48 +0000 | [diff] [blame] | 1612 | secure_from="$spm_build_root" non_secure_from="$hafnium_build_root" to="$archive" collect_spm_artefacts |
Olivier Deprez | 0a9a348 | 2019-12-16 14:10:31 +0100 | [diff] [blame] | 1613 | |
| 1614 | echo "##########" |
| 1615 | echo |
| 1616 | ) |
| 1617 | fi |
| 1618 | |
Manish V Badarkhe | d62aa5f | 2025-03-18 21:18:14 +0000 | [diff] [blame] | 1619 | # TF RMM build |
| 1620 | if config_valid "$rmm_config"; then |
| 1621 | ( |
| 1622 | echo "##########" |
| 1623 | |
| 1624 | plat_utils="$(get_rmm_opt PLAT_UTILS)" |
| 1625 | if [ -z ${plat_utils} ]; then |
| 1626 | # Source platform-specific utilities. |
| 1627 | plat="$(get_rmm_opt PLAT)" |
| 1628 | plat_utils="$ci_root/${plat}_utils.sh" |
| 1629 | else |
| 1630 | # Source platform-specific utilities by |
| 1631 | # using plat_utils name. |
| 1632 | plat_utils="$ci_root/${plat_utils}.sh" |
| 1633 | fi |
| 1634 | |
| 1635 | if [ -f "$plat_utils" ]; then |
| 1636 | source "$plat_utils" |
| 1637 | fi |
| 1638 | |
| 1639 | archive="$build_archive" |
| 1640 | rmm_build_root="$rmm_root/build" |
| 1641 | |
| 1642 | echo "Building Trusted Firmware RMM ($mode) ..." |& log_separator |
| 1643 | |
| 1644 | #call_hook pre_rmm_build |
| 1645 | build_rmm |
| 1646 | |
| 1647 | # Collect all rmm.* files: rmm.img, rmm.elf, rmm.dump, rmm.map |
| 1648 | from="$rmm_build_root" to="$archive" collect_build_artefacts |
| 1649 | |
| 1650 | # Clear any local changes made by applied patches |
| 1651 | undo_rmm_patches |
| 1652 | |
| 1653 | echo "##########" |
| 1654 | ) |
| 1655 | fi |
| 1656 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1657 | # TF build |
| 1658 | if config_valid "$tf_config"; then |
| 1659 | ( |
| 1660 | echo "##########" |
| 1661 | |
Manish V Badarkhe | 3bd3fea | 2020-11-08 15:17:00 +0000 | [diff] [blame] | 1662 | plat_utils="$(get_tf_opt PLAT_UTILS)" |
Madhukar Pappireddy | 2f284e1 | 2021-08-30 16:06:14 -0500 | [diff] [blame] | 1663 | export plat_variant="$(get_tf_opt TARGET_PLATFORM)" |
| 1664 | |
Manish V Badarkhe | 3bd3fea | 2020-11-08 15:17:00 +0000 | [diff] [blame] | 1665 | if [ -z ${plat_utils} ]; then |
| 1666 | # Source platform-specific utilities. |
| 1667 | plat="$(get_tf_opt PLAT)" |
| 1668 | plat_utils="$ci_root/${plat}_utils.sh" |
| 1669 | else |
| 1670 | # Source platform-specific utilities by |
| 1671 | # using plat_utils name. |
| 1672 | plat_utils="$ci_root/${plat_utils}.sh" |
| 1673 | fi |
| 1674 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1675 | if [ -f "$plat_utils" ]; then |
| 1676 | source "$plat_utils" |
| 1677 | fi |
| 1678 | |
Chris Kay | e5a486b | 2023-08-04 11:50:31 +0000 | [diff] [blame] | 1679 | fvp_tsram_size="$(get_tf_opt FVP_TRUSTED_SRAM_SIZE)" |
| 1680 | fvp_tsram_size="${fvp_tsram_size:-256}" |
| 1681 | |
Harrison Mutai | dc70340 | 2024-08-02 14:40:16 +0000 | [diff] [blame] | 1682 | poetry -C "$tf_root" install --without docs |
Chris Kay | d083790 | 2021-11-17 10:17:52 +0000 | [diff] [blame] | 1683 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1684 | archive="$build_archive" |
| 1685 | tf_build_root="$tf_root/build" |
| 1686 | |
| 1687 | echo "Building Trusted Firmware ($mode) ..." |& log_separator |
| 1688 | |
| 1689 | # Call pre-build hook |
| 1690 | call_hook pre_tf_build |
| 1691 | |
| 1692 | build_tf |
| 1693 | |
| 1694 | # Call post-build hook |
| 1695 | call_hook post_tf_build |
| 1696 | |
| 1697 | # Pre-archive hook |
| 1698 | call_hook pre_tf_archive |
| 1699 | |
| 1700 | from="$tf_build_root" to="$archive" collect_build_artefacts |
| 1701 | |
| 1702 | # Post-archive hook |
| 1703 | call_hook post_tf_archive |
| 1704 | |
| 1705 | call_hook fetch_tf_resource |
| 1706 | call_hook post_fetch_tf_resource |
| 1707 | |
Chris Kay | 4e8aaf1 | 2022-09-01 15:21:55 +0100 | [diff] [blame] | 1708 | # Generate LAVA job files if necessary |
| 1709 | call_hook generate_lava_job_template |
| 1710 | call_hook generate_lava_job |
| 1711 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1712 | # Clear any local changes made by applied patches |
| 1713 | undo_tf_patches |
| 1714 | |
| 1715 | echo "##########" |
| 1716 | ) |
| 1717 | fi |
| 1718 | |
| 1719 | echo |
| 1720 | echo |
| 1721 | done |
| 1722 | |
| 1723 | call_hook pre_package |
| 1724 | |
| 1725 | call_hook post_package |
| 1726 | |
| 1727 | if upon "$jenkins_run" && upon "$artefacts_receiver" && [ -d "artefacts" ]; then |
Zelalem | 219df41 | 2020-05-17 19:21:20 -0500 | [diff] [blame] | 1728 | source "$CI_ROOT/script/send_artefacts.sh" "artefacts" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 1729 | fi |
| 1730 | |
| 1731 | echo |
| 1732 | echo "Done" |