blob: 168565f7248ceefc1199c3d17ab68c7370601225 [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Leonardo Sandoval579c7372020-10-23 15:23:32 -05003# Copyright (c) 2019-2020 Arm Limited. All rights reserved.
Fathi Boudra422bf772019-12-02 11:10:16 +02004#
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
11set -e
12
13ci_root="$(readlink -f "$(dirname "$0")/..")"
14source "$ci_root/utils.sh"
15
16if [ ! -d "$workspace" ]; then
17 die "Directory $workspace doesn't exist"
18fi
19
20# Directory to where the source code e.g. for Trusted Firmware is checked out.
Zelalem219df412020-05-17 19:21:20 -050021export tf_root="${tf_root:-$workspace/trusted_firmware}"
22export tftf_root="${tftf_root:-$workspace/trusted_firmware_tf}"
23export scp_root="${scp_root:-$workspace/scp}"
24scp_tools_root="${scp_tools_root:-$workspace/scp_tools}"
25cc_root="${cc_root:-$ccpathspec}"
Olivier Deprez0a9a3482019-12-16 14:10:31 +010026spm_root="${spm_root:-$workspace/spm}"
Zelalem219df412020-05-17 19:21:20 -050027
28scp_tf_tools_root="$scp_tools_root/scp_tf_tools"
Fathi Boudra422bf772019-12-02 11:10:16 +020029
30# Refspecs
31tf_refspec="$TF_REFSPEC"
32tftf_refspec="$TFTF_REFSPEC"
33scp_refspec="$SCP_REFSPEC"
Zelalem219df412020-05-17 19:21:20 -050034scp_tools_commit="${SCP_TOOLS_COMMIT:-master}"
Olivier Deprez0a9a3482019-12-16 14:10:31 +010035spm_refspec="$SPM_REFSPEC"
Fathi Boudra422bf772019-12-02 11:10:16 +020036
37test_config="${TEST_CONFIG:?}"
38test_group="${TEST_GROUP:?}"
39build_configs="${BUILD_CONFIG:?}"
40run_config="${RUN_CONFIG:?}"
Zelalem219df412020-05-17 19:21:20 -050041cc_config="${CC_ENABLE:-}"
Fathi Boudra422bf772019-12-02 11:10:16 +020042
43archive="$artefacts"
44build_log="$artefacts/build.log"
45fiptool="$tf_root/tools/fiptool/fiptool"
46cert_create="$tf_root/tools/cert_create/cert_create"
47
48# Validate $bin_mode
49case "$bin_mode" in
50 "" | debug | release)
51 ;;
52 *)
53 die "Invalid value for bin_mode: $bin_mode"
54 ;;
55esac
56
57# File to save any environem
58hook_env_file="$(mktempfile)"
59
60# Check if a config is valid
61config_valid() {
62 local config="${1?}"
63 if [ -z "$config" ] || [ "$(basename "$config")" = "nil" ]; then
64 return 1
65 fi
66
67 return 0
68}
69
70# Echo from a build wrapper. Print to descriptor 3 that's opened by the build
71# function.
72echo_w() {
73 echo $echo_flags "$@" >&3
74}
75
76# Print a separator to the log file. Intended to be used at the tail end of a pipe
77log_separator() {
78 {
79 echo
80 echo "----------"
81 } >> "$build_log"
82
83 tee -a "$build_log"
84
85 {
86 echo "----------"
87 echo
88 } >> "$build_log"
89}
90
91# Call function $1 if it's defined
92call_func() {
93 if type "${1:?}" &>/dev/null; then
94 echo
95 echo "> ${2:?}:$1()"
96 eval "$1"
97 echo "< $2:$1()"
98 fi
99}
100
101# Call hook $1 in all chosen fragments if it's defined. Hooks are invoked from
102# within a subshell, so any variables set within a hook are lost. Should a
103# variable needs to be set from within a hook, the function 'set_hook_var'
104# should be used
105call_hook() {
106 local func="$1"
107 local config_fragment
108
109 [ -z "$func" ] && return 0
110
111 : >"$hook_env_file"
112
113 if [ "$run_config_candiates" ]; then
114 for config_fragment in $run_config_candiates; do
115 (
116 source "$ci_root/run_config/$config_fragment"
117 call_func "$func" "$config_fragment"
118 )
119 done
120 fi
121
122 # Also source test config file
123 (
124 unset "$func"
125 source "$test_config_file"
126 call_func "$func" "$(basename $test_config_file)"
127 )
128
129 # Have any variables set take effect
130 source "$hook_env_file"
131}
132
133# Set a variable from within a hook
134set_hook_var() {
135 echo "export $1=\"${2?}\"" >> "$hook_env_file"
136}
137
138# Append to an array from within a hook
139append_hook_var() {
140 echo "export $1+=\"${2?}\"" >> "$hook_env_file"
141}
142
143# Have the main build script source a file
144source_later() {
145 echo "source ${1?}" >> "$hook_env_file"
146}
147
148# Setup TF build wrapper function by pointing to a script containing a function
149# that will be called with the TF build commands.
150setup_tf_build_wrapper() {
151 source_later "$ci_root/script/${wrapper?}_wrapper.sh"
152 set_hook_var "tf_build_wrapper" "${wrapper}_wrapper"
153 echo "Setup $wrapper build wrapper."
154}
155
156# Collect .bin files for archiving
157collect_build_artefacts() {
158 if [ ! -d "${from:?}" ]; then
159 return
160 fi
161
Javier Almansa Sobrinof98dbd82020-09-30 19:29:27 +0100162 if ! find "$from" \( -name "*.bin" -o -name '*.elf' -o -name '*.dtb' -o -name '*.axf' \) -exec cp -t "${to:?}" '{}' +; then
Fathi Boudra422bf772019-12-02 11:10:16 +0200163 echo "You probably are running local CI on local repositories."
164 echo "Did you set 'dont_clean' but forgot to run 'distclean'?"
165 die
166 fi
167}
168
169# SCP and MCP binaries are named firmware.{bin,elf}, and are placed under
170# scp/mcp_ramfw and scp/mcp_romfw directories, so can't be collected by
171# collect_build_artefacts function.
172collect_scp_artefacts() {
173 to="${to:?}" \
174 find "$scp_root" \( -name "*.bin" -o -name '*.elf' \) -exec bash -c '
175 for file; do
176 ext="$(echo $file | awk -F. "{print \$NF}")"
177 case $file in
178 */scp_ramfw/*)
179 cp $file $to/scp_ram.$ext
180 ;;
181 */scp_romfw/*)
182 cp $file $to/scp_rom.$ext
183 ;;
184 */mcp_ramfw/*)
185 cp $file $to/mcp_ram.$ext
186 ;;
187 */mcp_romfw/*)
188 cp $file $to/mcp_rom.$ext
189 ;;
Zelalem219df412020-05-17 19:21:20 -0500190 */scp_romfw_bypass/*)
191 cp $file $to/scp_rom_bypass.$ext
192 ;;
Fathi Boudra422bf772019-12-02 11:10:16 +0200193 *)
194 echo "Unknown SCP binary: $file" >&2
195 ;;
196 esac
197 done
198 ' bash '{}' +
199}
200
Javier Almansa Sobrino412d3612020-05-22 17:53:12 +0100201# Map the UART ID used for expect with the UART descriptor and port
202# used by the FPGA automation tools.
203map_uart() {
204 local port="${port:?}"
205 local descriptor="${descriptor:?}"
206 local baudrate="${baudrate:?}"
207 local run_root="${archive:?}/run"
208
209 local uart_dir="$run_root/uart${uart:?}"
210 mkdir -p "$uart_dir"
211
212 echo "$port" > "$uart_dir/port"
213 echo "$descriptor" > "$uart_dir/descriptor"
214 echo "$baudrate" > "$uart_dir/baudrate"
215
216 echo "UART${uart} mapped to port ${port} with descriptor ${descriptor} and baudrate ${baudrate}"
217}
218
Fathi Boudra422bf772019-12-02 11:10:16 +0200219# Arrange environment varibles to be set when expect scripts are launched
220set_expect_variable() {
221 local var="${1:?}"
222 local val="${2?}"
223
224 local run_root="${archive:?}/run"
225 local uart_dir="$run_root/uart${uart:?}"
226 mkdir -p "$uart_dir"
227
228 env_file="$uart_dir/env" quote="1" emit_env "$var" "$val"
229 echo "UART$uart: env has $@"
230}
231
232# Place the binary package a pointer to expect script, and its parameters
233track_expect() {
234 local file="${file:?}"
235 local timeout="${timeout-600}"
236 local run_root="${archive:?}/run"
237
238 local uart_dir="$run_root/uart${uart:?}"
239 mkdir -p "$uart_dir"
240
241 echo "$file" > "$uart_dir/expect"
242 echo "$timeout" > "$uart_dir/timeout"
243
244 echo "UART$uart to be tracked with $file; timeout ${timeout}s"
245
246 # The run script assumes UART0 to be primary. If we're asked to set any
247 # other UART to be primary, set a run environment variable to signal
248 # that to the run script
249 if upon "$set_primary"; then
250 echo "Primary UART set to UART$uart."
251 set_run_env "primary_uart" "$uart"
252 fi
253}
254
255# Extract a FIP in $1 using fiptool
256extract_fip() {
257 local fip="$1"
258
259 if is_url "$1"; then
260 url="$1" fetch_file
261 fip="$(basename "$1")"
262 fi
263
264 "$fiptool" unpack "$fip"
265 echo "Extracted FIP: $fip"
266}
267
268# Report build failure by printing a the tail end of build log. Archive the
269# build log for later inspection
270fail_build() {
271 local log_path
272
273 if upon "$jenkins_run"; then
274 log_path="$BUILD_URL/artifact/artefacts/build.log"
275 else
276 log_path="$build_log"
277 fi
278
279 echo
Leonardo Sandovalae97eda2020-11-12 10:07:03 -0600280 echo "Build failed! Full build log below:"
Fathi Boudra422bf772019-12-02 11:10:16 +0200281 echo "[...]"
282 echo
Leonardo Sandovalae97eda2020-11-12 10:07:03 -0600283 cat "$build_log"
Fathi Boudra422bf772019-12-02 11:10:16 +0200284 echo
285 echo "See $log_path for full output"
286 echo
287 cp -t "$archive" "$build_log"
288 exit 1;
289}
290
291# Build a FIP with supplied arguments
292build_fip() {
293 (
294 echo "Building FIP with arguments: $@"
295 local tf_env="$workspace/tf.env"
296
297 if [ -f "$tf_env" ]; then
298 set -a
299 source "$tf_env"
300 set +a
301 fi
302
303 make -C "$tf_root" $(cat "$tf_config_file") DEBUG="$DEBUG" V=1 "$@" \
304 ${fip_targets:-fip} &>>"$build_log" || fail_build
305 )
306}
307
308fip_update() {
309 # Before the update process, check if the given image is supported by
310 # the fiptool. It's assumed that both fiptool and cert_create move in
311 # tandem, and therfore, if one has support, the other has it too.
312 if ! "$fiptool" update 2>&1 | grep -qe "\s\+--${bin_name:?}"; then
313 return 1
314 fi
315
316 if not_upon "$(get_tf_opt TRUSTED_BOARD_BOOT)"; then
317 echo "Updating FIP image: $bin_name"
318 # Update HW config. Without TBBR, it's only a matter of using
319 # the update sub-command of fiptool
320 "$fiptool" update "--$bin_name" "${src:-}" \
321 "$archive/fip.bin"
322 else
323 echo "Updating FIP image (TBBR): $bin_name"
324 # With TBBR, we need to unpack, re-create certificates, and then
325 # recreate the FIP.
326 local fip_dir="$(mktempdir)"
327 local bin common_args stem
328 local rot_key="$(get_tf_opt ROT_KEY)"
329
330 rot_key="${rot_key:?}"
331 if ! is_abs "$rot_key"; then
332 rot_key="$tf_root/$rot_key"
333 fi
334
335 # Arguments only for cert_create
336 local cert_args="-n"
337 cert_args+=" --tfw-nvctr ${nvctr:-31}"
338 cert_args+=" --ntfw-nvctr ${nvctr:-223}"
339 cert_args+=" --key-alg ${KEY_ALG:-rsa}"
340 cert_args+=" --rot-key $rot_key"
341
342 local dyn_config_opts=(
Zelalem1af7a7b2020-08-04 17:34:32 -0500343 "fw-config"
Fathi Boudra422bf772019-12-02 11:10:16 +0200344 "hw-config"
345 "tb-fw-config"
346 "nt-fw-config"
347 "soc-fw-config"
348 "tos-fw-config"
349 )
350
351 # Binaries without key certificates
352 declare -A has_no_key_cert
353 for bin in "tb-fw" "${dyn_config_opts[@]}"; do
354 has_no_key_cert["$bin"]="1"
355 done
356
357 # Binaries without certificates
358 declare -A has_no_cert
359 for bin in "hw-config" "${dyn_config_opts[@]}"; do
360 has_no_cert["$bin"]="1"
361 done
362
363 pushd "$fip_dir"
364
365 # Unpack FIP
366 "$fiptool" unpack "$archive/fip.bin" &>>"$build_log"
367
368 # Remove all existing certificates
369 rm -f *-cert.bin
370
371 # Copy the binary to be updated
372 cp -f "$src" "${bin_name}.bin"
373
374 # FIP unpack dumps binaries with the same name as the option
375 # used to pack it; likewise for certificates. Reverse-engineer
376 # the command line from the binary output.
377 common_args="--trusted-key-cert trusted_key.crt"
378 for bin in *.bin; do
379 stem="${bin%%.bin}"
380 common_args+=" --$stem $bin"
381 if not_upon "${has_no_cert[$stem]}"; then
382 common_args+=" --$stem-cert $stem.crt"
383 fi
384 if not_upon "${has_no_key_cert[$stem]}"; then
385 common_args+=" --$stem-key-cert $stem-key.crt"
386 fi
387 done
388
389 # Create certificates
390 "$cert_create" $cert_args $common_args &>>"$build_log"
391
392 # Recreate and archive FIP
393 "$fiptool" create $common_args "fip.bin" &>>"$build_log"
394 archive_file "fip.bin"
395
396 popd
397 fi
398}
399
400# Update hw-config in FIP, and remove the original DTB afterwards.
401update_fip_hw_config() {
402 # The DTB needs to be loaded by the model (and not updated in the FIP)
403 # in configs where BL2 isn't present
404 case "1" in
405 "$(get_tf_opt RESET_TO_BL31)" | \
406 "$(get_tf_opt RESET_TO_SP_MIN)" | \
407 "$(get_tf_opt BL2_AT_EL3)")
408 return 0;;
409 esac
410
411 if bin_name="hw-config" src="$archive/dtb.bin" fip_update; then
412 # Remove the DTB so that model won't load it
413 rm -f "$archive/dtb.bin"
414 fi
415}
416
417get_scp_opt() {
418 (
419 name="${1:?}"
420 if config_valid "$scp_config_file"; then
421 source "$scp_config_file"
422 echo "${!name}"
423 fi
424 )
425}
426
427get_tftf_opt() {
428 (
429 name="${1:?}"
430 if config_valid "$tftf_config_file"; then
431 source "$tftf_config_file"
432 echo "${!name}"
433 fi
434 )
435}
436
437get_tf_opt() {
438 (
439 name="${1:?}"
440 if config_valid "$tf_config_file"; then
441 source "$tf_config_file"
442 echo "${!name}"
443 fi
444 )
445}
446
447build_tf() {
448 (
449 env_file="$workspace/tf.env"
450 config_file="${tf_build_config:-$tf_config_file}"
451
452 # Build fiptool and all targets by default
453 build_targets="${tf_build_targets:-fiptool all}"
454
455 source "$config_file"
456
457 # If it is a TBBR build, extract the MBED TLS library from archive
458 if [ "$(get_tf_opt TRUSTED_BOARD_BOOT)" = 1 ]; then
459 mbedtls_dir="$workspace/mbedtls"
460 if [ ! -d "$mbedtls_dir" ]; then
461 mbedtls_ar="$workspace/mbedtls.tar.gz"
462
463 url="$mbedtls_archive" saveas="$mbedtls_ar" fetch_file
464 mkdir "$mbedtls_dir"
Leonardo Sandovalec9e16c2020-09-09 14:32:40 -0500465 extract_tarball $mbedtls_ar $mbedtls_dir --strip-components=1
Fathi Boudra422bf772019-12-02 11:10:16 +0200466 fi
467
468 emit_env "MBEDTLS_DIR" "$mbedtls_dir"
469 fi
470
471 if [ -f "$env_file" ]; then
472 set -a
473 source "$env_file"
474 set +a
475 fi
476
477 cd "$tf_root"
478
479 # Always distclean when running on Jenkins. Skip distclean when running
480 # locally and explicitly requested.
481 if upon "$jenkins_run" || not_upon "$dont_clean"; then
482 make distclean &>>"$build_log" || fail_build
483 fi
484
485 # Log build command line. It is left unfolded on purpose to assist
486 # copying to clipboard.
487 cat <<EOF | log_separator >/dev/null
488
489Build command line:
490 $tf_build_wrapper make $make_j_opts $(cat "$config_file" | tr '\n' ' ') DEBUG=$DEBUG V=1 $build_targets
491
492EOF
493
Javier Almansa Sobrinoe8363182020-11-10 16:40:53 +0000494 if not_upon "$local_ci"; then
495 connect_debugger=0
496 fi
497
Fathi Boudra422bf772019-12-02 11:10:16 +0200498 # Build TF. Since build output is being directed to the build log, have
499 # descriptor 3 point to the current terminal for build wrappers to vent.
500 $tf_build_wrapper make $make_j_opts $(cat "$config_file") \
Javier Almansa Sobrinoe8363182020-11-10 16:40:53 +0000501 DEBUG="$DEBUG" V=1 SPIN_ON_BL1_EXIT="$connect_debugger" \
Fathi Boudra422bf772019-12-02 11:10:16 +0200502 $build_targets 3>&1 &>>"$build_log" || fail_build
503 )
504}
505
506build_tftf() {
507 (
508 config_file="${tftf_build_config:-$tftf_config_file}"
509
510 # Build tftf target by default
511 build_targets="${tftf_build_targets:-all}"
512
513 source "$config_file"
514
515 cd "$tftf_root"
516
517 # Always distclean when running on Jenkins. Skip distclean when running
518 # locally and explicitly requested.
519 if upon "$jenkins_run" || not_upon "$dont_clean"; then
520 make distclean &>>"$build_log" || fail_build
521 fi
522
523 # TFTF build system cannot reliably deal with -j option, so we avoid
524 # using that.
525
526 # Log build command line
527 cat <<EOF | log_separator >/dev/null
528
529Build command line:
530 make $(cat "$config_file" | tr '\n' ' ') DEBUG=$DEBUG V=1 $build_targets
531
532EOF
533
534 make $(cat "$config_file") DEBUG="$DEBUG" V=1 \
535 $build_targets &>>"$build_log" || fail_build
536 )
537}
538
539build_scp() {
540 (
541 config_file="${scp_build_config:-$scp_config_file}"
542
543 source "$config_file"
544
545 cd "$scp_root"
546
547 # Always distclean when running on Jenkins. Skip distclean when running
548 # locally and explicitly requested.
549 if upon "$jenkins_run" || not_upon "$dont_clean"; then
550 make clean &>>"$build_log" || fail_build
551 fi
552
553 # Log build command line. It is left unfolded on purpose to assist
554 # copying to clipboard.
555 cat <<EOF | log_separator >/dev/null
556
557SCP build command line:
558 make $(cat "$config_file" | tr '\n' ' ') MODE=$mode V=1
559
560EOF
561
562 # Build SCP
563 make $(cat "$config_file") MODE="$mode" V=1 &>>"$build_log" \
564 || fail_build
565 )
566}
567
Zelalem219df412020-05-17 19:21:20 -0500568clone_scp_tools() {
569
570 if [ ! -d "$scp_tools_root" ]; then
571 echo "Cloning SCP-tools ... $scp_tools_commit" |& log_separator
572
573 clone_url="${SCP_TOOLS_CHECKOUT_LOC:-$scp_tools_src_repo_url}" \
574 where="$scp_tools_root" \
575 refspec="${scp_tools_commit}"
576 clone_repo &>>"$build_log"
577 else
578 echo "Already cloned SCP-tools ..." |& log_separator
579 fi
580
581 show_head "$scp_tools_root"
582
583 cd "$scp_tools_root"
584
585 echo "Updating submodules"
586
587 git submodule init
588
589 git submodule update
590
591 cd "scmi"
592
593 git show --quiet --no-color | sed 's/^/ > /g'
594}
595
596clone_tf_for_scp_tools() {
597 scp_tools_arm_tf="$scp_tools_root/arm-tf"
598
599 if [ ! -d "$scp_tools_arm_tf" ]; then
600 echo "Cloning TF-4-SCP-tools ..." |& log_separator
601
602 clone_url="$tf_for_scp_tools_src_repo_url"
603 where="$scp_tools_arm_tf"
604
605 git clone "$clone_url" "$where"
606
607 cd "$scp_tools_arm_tf"
608
609 git checkout --track origin/dev/pedro/juno
610
611 git show --quiet --no-color | sed 's/^/ > /g'
612
613 else
614 echo "Already cloned TF-4-SCP-tools ..." |& log_separator
615 fi
616}
617
618build_scmi_lib_scp_tools() {
619 (
620 cd "$scp_tools_root"
621
622 cd "scmi"
623
624 scp_tools_arm_tf="$scp_tools_root/arm-tf"
625
Leonardo Sandovalfeae3a22020-11-17 16:53:59 -0600626 cross_compile="$(set_cross_compile_gcc_linaro_toolchain)"
Zelalem219df412020-05-17 19:21:20 -0500627
628 std_libs="-I$scp_tools_arm_tf/include/common"
629 std_libs="$std_libs -I$scp_tools_arm_tf/include/common/tbbr"
630 std_libs="$std_libs -I$scp_tools_arm_tf/include/drivers/arm"
631 std_libs="$std_libs -I$scp_tools_arm_tf/include/lib"
632 std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/aarch64"
633 std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/stdlib"
634 std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/stdlib/sys"
635 std_libs="$std_libs -I$scp_tools_arm_tf/include/lib/xlat_tables"
636 std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/common"
637 std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/common"
638 std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/css/common"
639 std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/board/common"
640 std_libs="$std_libs -I$scp_tools_arm_tf/include/plat/arm/soc/common"
641 std_libs="$std_libs -I$scp_tools_arm_tf/plat/arm/board/juno/include"
642
643 cflags="-Og -g"
644 cflags="$cflags -mgeneral-regs-only"
645 cflags="$cflags -mstrict-align"
646 cflags="$cflags -nostdinc"
647 cflags="$cflags -fno-inline"
648 cflags="$cflags -ffreestanding"
649 cflags="$cflags -ffunction-sections"
650 cflags="$cflags -fdata-sections"
651 cflags="$cflags -DAARCH64"
652 cflags="$cflags -DPRId32=\"ld\""
653
654 cflags="$cflags $std_libs"
655
656 protocols="power,system_power,performance,sensor"
657
658 echo "Building SCMI library (SCP-tools) ..."
659
660 make "CROSS_COMPILE=$cross_compile" \
661 "CFLAGS=$cflags" \
662 "PROTOCOLS=$protocols" \
663 "clean" \
664 "all"
665 )
666}
667
668build_tf_for_scp_tools() {
669
670 cd "$scp_tools_root/arm-tf"
671
Leonardo Sandovalfeae3a22020-11-17 16:53:59 -0600672 cross_compile="$(set_cross_compile_gcc_linaro_toolchain)"
Zelalem219df412020-05-17 19:21:20 -0500673
674 if [ "$1" = "release" ]; then
675 echo "Build TF-4-SCP-Tools rls..."
676 else
677 echo "Build TF-4-SCP-Tools dbg..."
678
679 make realclean
680
681 make "BM_TEST=scmi" \
682 "ARM_BOARD_OPTIMISE_MEM=1" \
683 "BM_CSS=juno" \
684 "CSS_USE_SCMI_SDS_DRIVER=1" \
685 "PLAT=juno" \
686 "DEBUG=1" \
687 "PLATFORM=juno" \
688 "CROSS_COMPILE=$cross_compile" \
689 "BM_WORKSPACE=$scp_tools_root/baremetal"
690
691 archive_file "build/juno/debug/bl1.bin"
692
693 archive_file "build/juno/debug/bl2.bin"
694
695 archive_file "build/juno/debug/bl31.bin"
696 fi
697}
698
699build_fip_for_scp_tools() {
700
701 cd "$scp_tools_root/arm-tf"
702
Leonardo Sandovalfeae3a22020-11-17 16:53:59 -0600703 cross_compile="$(set_cross_compile_gcc_linaro_toolchain)"
Zelalem219df412020-05-17 19:21:20 -0500704
705 if [ ! -d "$scp_root/build/product/juno/scp_ramfw/debug" ]; then
706 make fiptool
707 echo "Make FIP 4 SCP-Tools rls..."
708
709 else
710 make fiptool
711 echo "Make FIP 4 SCP-Tools dbg..."
712
713 make "PLAT=juno" \
714 "all" \
715 "fip" \
716 "DEBUG=1" \
717 "CROSS_COMPILE=$cross_compile" \
718 "BL31=$scp_tools_root/arm-tf/build/juno/debug/bl31.bin" \
719 "BL33=$scp_tools_root/baremetal/dummy_bl33" \
720 "SCP_BL2=$scp_root/build/product/juno/scp_ramfw/debug/bin/firmware.bin"
721
722 archive_file "$scp_tools_root/arm-tf/build/juno/debug/fip.bin"
723 fi
724}
725
726build_cc() {
727# Building code coverage plugin
728 ARM_DIR=/arm
729 pvlibversion=$(/arm/devsys-tools/abs/detag "SysGen:PVModelLib:$model_version::trunk")
730 PVLIB_HOME=$warehouse/SysGen/PVModelLib/$model_version/${pvlibversion}/external
731 if [ -n "$(find "$ARM_DIR" -maxdepth 0 -type d -empty 2>/dev/null)" ]; then
732 echo "Error: Arm warehouse not mounted. Please mount the Arm warehouse to your /arm local folder"
733 exit -1
734 fi # Error if arm warehouse not found
735 cd "$ccpathspec/scripts/tools/code_coverage/fastmodel_baremetal/bmcov"
736
737 make -C model-plugin PVLIB_HOME=$PVLIB_HOME &>>"$build_log"
738}
739
Olivier Deprez0a9a3482019-12-16 14:10:31 +0100740build_spm() {
741 (
742 env_file="$workspace/spm.env"
743 config_file="${spm_build_config:-$spm_config_file}"
744
745 source "$config_file"
746
747 if [ -f "$env_file" ]; then
748 set -a
749 source "$env_file"
750 set +a
751 fi
752
753 cd "$spm_root"
754
755 # Always clean when running on Jenkins. Skip clean when running
756 # locally and explicitly requested.
757 if upon "$jenkins_run" || not_upon "$dont_clean"; then
758 # make clean fails on a fresh repo where the project has not
759 # yet been built. Hence only clean if out/reference directory
760 # already exists.
761 if [ -d "out/reference" ]; then
762 make clean &>>"$build_log" || fail_build
763 fi
764 fi
765
766 # Log build command line. It is left unfolded on purpose to assist
767 # copying to clipboard.
768 cat <<EOF | log_separator >/dev/null
769
770Build command line:
771 make $make_j_opts $(cat "$config_file" | tr '\n' ' ')
772
773EOF
774
775 # Build SPM. Since build output is being directed to the build log, have
776 # descriptor 3 point to the current terminal for build wrappers to vent.
777 make $make_j_opts $(cat "$config_file") 3>&1 &>>"$build_log" \
778 || fail_build
779 )
780}
Zelalem219df412020-05-17 19:21:20 -0500781
Fathi Boudra422bf772019-12-02 11:10:16 +0200782# Set metadata for the whole package so that it can be used by both Jenkins and
783# shell
784set_package_var() {
785 env_file="$artefacts/env" emit_env "$@"
786}
787
788set_tf_build_targets() {
789 echo "Set build target to '${targets:?}'"
790 set_hook_var "tf_build_targets" "$targets"
791}
792
793set_tftf_build_targets() {
794 echo "Set build target to '${targets:?}'"
795 set_hook_var "tftf_build_targets" "$targets"
796}
797
798set_scp_build_targets() {
799 echo "Set build target to '${targets:?}'"
800 set_hook_var "scp_build_targets" "$targets"
801}
802
Olivier Deprez0a9a3482019-12-16 14:10:31 +0100803set_spm_build_targets() {
804 echo "Set build target to '${targets:?}'"
805 set_hook_var "spm_build_targets" "$targets"
806}
807
Fathi Boudra422bf772019-12-02 11:10:16 +0200808# Look under $archive directory for known files such as blX images, kernel, DTB,
809# initrd etc. For each known file foo, if foo.bin exists, then set variable
810# foo_bin to the path of the file. Make the path relative to the workspace so as
811# to remove any @ characters, which Jenkins inserts for parallel runs. If the
812# file doesn't exist, unset its path.
813set_default_bin_paths() {
814 local image image_name image_path path
815 local archive="${archive:?}"
816 local set_vars
817 local var
818
819 pushd "$archive"
820
821 for file in *.bin; do
822 # Get a shell variable from the file's stem
823 var_name="${file%%.*}_bin"
824 var_name="$(echo "$var_name" | sed -r 's/[^[:alnum:]]/_/g')"
825
826 # Skip setting the variable if it's already
827 if [ "${!var_name}" ]; then
828 echo "Note: not setting $var_name; already set to ${!var_name}"
829 continue
830 else
831 set_vars+="$var_name "
832 fi
833
834 eval "$var_name=$file"
835 done
836
837 echo "Binary paths set for: "
838 {
839 for var in $set_vars; do
840 echo -n "\$$var "
841 done
842 } | fmt -80 | sed 's/^/ /'
843 echo
844
845 popd
846}
847
848gen_model_params() {
849 local model_param_file="$archive/model_params"
Javier Almansa Sobrinoe8363182020-11-10 16:40:53 +0000850 [ "$connect_debugger" ] && [ "$connect_debugger" -eq 1 ] && wait_debugger=1
Fathi Boudra422bf772019-12-02 11:10:16 +0200851
852 set_default_bin_paths
853 echo "Generating model parameter for $model..."
854 source "$ci_root/model/${model:?}.sh"
855 archive_file "$model_param_file"
856}
857
858set_model_path() {
859 set_run_env "model_path" "${1:?}"
860}
861
Zelalem1af7a7b2020-08-04 17:34:32 -0500862set_model_env() {
863 local var="${1:?}"
864 local val="${2?}"
865 local run_root="${archive:?}/run"
866
867 mkdir -p "$run_root"
868 echo "export $var=$val" >> "$run_root/model_env"
869}
Fathi Boudra422bf772019-12-02 11:10:16 +0200870set_run_env() {
871 local var="${1:?}"
872 local val="${2?}"
873 local run_root="${archive:?}/run"
874
875 mkdir -p "$run_root"
876 env_file="$run_root/env" quote="1" emit_env "$var" "$val"
877}
878
879show_head() {
880 # Display HEAD descripton
881 pushd "$1"
882 git show --quiet --no-color | sed 's/^/ > /g'
883 echo
884 popd
885}
886
887# Choose debug binaries to run; by default, release binaries are chosen to run
888use_debug_bins() {
889 local run_root="${archive:?}/run"
890
891 echo "Choosing debug binaries for execution"
892 set_package_var "BIN_MODE" "debug"
893}
894
895assert_can_git_clone() {
896 local name="${1:?}"
897 local dir="${!name}"
898
899 # If it doesn't exist, it can be cloned into
900 if [ ! -e "$dir" ]; then
901 return 0
902 fi
903
904 # If it's a directory, it must be a Git clone already
905 if [ -d "$dir" ] && [ -d "$dir/.git" ]; then
906 # No need to clone again
907 echo "Using existing git clone for $name: $dir"
908 return 1
909 fi
910
911 die "Path $dir exists but is not a git clone"
912}
913
914clone_repo() {
915 if ! is_url "${clone_url?}"; then
916 # For --depth to take effect on local paths, it needs to use the
917 # file:// scheme.
918 clone_url="file://$clone_url"
919 fi
920
921 git clone -q --depth 1 "$clone_url" "${where?}"
922 if [ "$refspec" ]; then
923 pushd "$where"
924 git fetch -q --depth 1 origin "$refspec"
925 git checkout -q FETCH_HEAD
926 popd
927 fi
928}
929
930build_unstable() {
931 echo "--BUILD UNSTABLE--" | tee -a "$build_log"
932}
933
934undo_patch_record() {
935 if [ ! -f "${patch_record:?}" ]; then
936 return
937 fi
938
939 # Undo patches in reverse
940 echo
941 for patch_name in $(tac "$patch_record"); do
942 echo "Undoing $patch_name..."
943 if ! git apply -R "$ci_root/patch/$patch_name"; then
944 if upon "$local_ci"; then
945 echo
946 echo "Your local directory may have been dirtied."
947 echo
948 fi
949 fail_build
950 fi
951 done
952
953 rm -f "$patch_record"
954}
955
956undo_local_patches() {
957 pushd "$tf_root"
958 patch_record="$tf_patch_record" undo_patch_record
959 popd
960
961 if [ -d "$tftf_root" ]; then
962 pushd "$tftf_root"
963 patch_record="$tftf_patch_record" undo_patch_record
964 popd
965 fi
966}
967
968undo_tftf_patches() {
969 pushd "$tftf_root"
970 patch_record="$tftf_patch_record" undo_patch_record
971 popd
972}
973
974undo_tf_patches() {
975 pushd "$tf_root"
976 patch_record="$tf_patch_record" undo_patch_record
977 popd
978}
979
980apply_patch() {
981 # If skip_patches is set, the developer has applied required patches
982 # manually. They probably want to keep them applied for debugging
983 # purposes too. This means we don't have to apply/revert them as part of
984 # build process.
985 if upon "$skip_patches"; then
986 echo "Skipped applying ${1:?}..."
987 return 0
988 else
989 echo "Applying ${1:?}..."
990 fi
991
992 if git apply < "$ci_root/patch/$1"; then
993 echo "$1" >> "${patch_record:?}"
994 else
995 if upon "$local_ci"; then
996 undo_local_patches
997 fi
998 fail_build
999 fi
1000}
1001
1002apply_tftf_patch() {
1003 pushd "$tftf_root"
1004 patch_record="$tftf_patch_record" apply_patch "$1"
1005 popd
1006}
1007
1008apply_tf_patch() {
1009 pushd "$tf_root"
1010 patch_record="$tf_patch_record" apply_patch "$1"
1011 popd
1012}
1013
1014# Clear workspace for a local run
1015if not_upon "$jenkins_run"; then
1016 rm -rf "$workspace"
1017
1018 # Clear residue from previous runs
1019 rm -rf "$archive"
1020fi
1021
1022mkdir -p "$workspace"
1023mkdir -p "$archive"
1024set_package_var "TEST_CONFIG" "$test_config"
1025
1026{
1027echo
1028echo "CONFIGURATION: $test_group/$test_config"
1029echo
1030} |& log_separator
1031
1032tf_config="$(echo "$build_configs" | awk -F, '{print $1}')"
1033tftf_config="$(echo "$build_configs" | awk -F, '{print $2}')"
1034scp_config="$(echo "$build_configs" | awk -F, '{print $3}')"
Zelalem219df412020-05-17 19:21:20 -05001035scp_tools_config="$(echo "$build_configs" | awk -F, '{print $4}')"
Olivier Deprez0a9a3482019-12-16 14:10:31 +01001036spm_config="$(echo "$build_configs" | awk -F, '{print $5}')"
Fathi Boudra422bf772019-12-02 11:10:16 +02001037
1038test_config_file="$ci_root/group/$test_group/$test_config"
1039
1040tf_config_file="$ci_root/tf_config/$tf_config"
1041tftf_config_file="$ci_root/tftf_config/$tftf_config"
1042scp_config_file="$ci_root/scp_config/$scp_config"
Zelalem219df412020-05-17 19:21:20 -05001043scp_tools_config_file="$ci_root/scp_tools_config/$scp_tools_config"
Olivier Deprez0a9a3482019-12-16 14:10:31 +01001044spm_config_file="$ci_root/spm_config/$spm_config"
Fathi Boudra422bf772019-12-02 11:10:16 +02001045
1046# File that keeps track of applied patches
1047tf_patch_record="$workspace/tf_patches"
1048tftf_patch_record="$workspace/tftf_patches"
1049
1050pushd "$workspace"
1051
1052if ! config_valid "$tf_config"; then
1053 tf_config=
1054else
1055 echo "Trusted Firmware config:"
1056 echo
1057 sort "$tf_config_file" | sed '/^\s*$/d;s/^/\t/'
1058 echo
1059fi
1060
1061if ! config_valid "$tftf_config"; then
1062 tftf_config=
1063else
1064 echo "Trusted Firmware TF config:"
1065 echo
1066 sort "$tftf_config_file" | sed '/^\s*$/d;s/^/\t/'
1067 echo
1068fi
1069
1070if ! config_valid "$scp_config"; then
1071 scp_config=
1072else
1073 echo "SCP firmware config:"
1074 echo
1075 sort "$scp_config_file" | sed '/^\s*$/d;s/^/\t/'
1076 echo
1077fi
1078
Zelalem219df412020-05-17 19:21:20 -05001079if ! config_valid "$scp_tools_config"; then
1080 scp_tools_config=
1081else
1082 echo "SCP Tools config:"
1083 echo
1084 sort "$scp_tools_config_file" | sed '/^\s*$/d;s/^/\t/'
Olivier Deprez0a9a3482019-12-16 14:10:31 +01001085fi
1086
1087if ! config_valid "$spm_config"; then
1088 spm_config=
1089else
1090 echo "SPM config:"
1091 echo
1092 sort "$spm_config_file" | sed '/^\s*$/d;s/^/\t/'
Zelalem219df412020-05-17 19:21:20 -05001093 echo
1094fi
1095
Fathi Boudra422bf772019-12-02 11:10:16 +02001096if ! config_valid "$run_config"; then
1097 run_config=
1098fi
1099
1100if [ "$tf_config" ] && assert_can_git_clone "tf_root"; then
1101 # If the Trusted Firmware repository has already been checked out, use
1102 # that location. Otherwise, clone one ourselves.
1103 echo "Cloning Trusted Firmware..."
1104 clone_url="${TF_CHECKOUT_LOC:-$tf_src_repo_url}" where="$tf_root" \
1105 refspec="$TF_REFSPEC" clone_repo &>>"$build_log"
1106 show_head "$tf_root"
1107fi
1108
1109if [ "$tftf_config" ] && assert_can_git_clone "tftf_root"; then
1110 # If the Trusted Firmware TF repository has already been checked out,
1111 # use that location. Otherwise, clone one ourselves.
1112 echo "Cloning Trusted Firmware TF..."
1113 clone_url="${TFTF_CHECKOUT_LOC:-$tftf_src_repo_url}" where="$tftf_root" \
1114 refspec="$TFTF_REFSPEC" clone_repo &>>"$build_log"
1115 show_head "$tftf_root"
1116fi
1117
1118if [ "$scp_config" ] && assert_can_git_clone "scp_root"; then
1119 # If the SCP firmware repository has already been checked out,
1120 # use that location. Otherwise, clone one ourselves.
1121 echo "Cloning SCP Firmware..."
1122 clone_url="${SCP_CHECKOUT_LOC:-$scp_src_repo_url}" where="$scp_root" \
1123 refspec="${SCP_REFSPEC-master-upstream}" clone_repo &>>"$build_log"
1124
1125 pushd "$scp_root"
1126
1127 # Use filer submodule as a reference if it exists
1128 if [ -d "$SCP_CHECKOUT_LOC/cmsis" ]; then
1129 cmsis_reference="--reference $SCP_CHECKOUT_LOC/cmsis"
1130 fi
1131
1132 # If we don't have a reference yet, fall back to $cmsis_root if set, or
1133 # then to project filer if accessible.
1134 if [ -z "$cmsis_reference" ]; then
1135 cmsis_ref_repo="${cmsis_root:-$project_filer/ref-repos/cmsis}"
1136 if [ -d "$cmsis_ref_repo" ]; then
1137 cmsis_reference="--reference $cmsis_ref_repo"
1138 fi
1139 fi
1140
1141 git submodule -q update $cmsis_reference --init
1142
1143 popd
1144
1145 show_head "$scp_root"
1146fi
1147
Zelalem219df412020-05-17 19:21:20 -05001148if [ -n "$cc_config" ] ; then
1149 if [ "$cc_config" -eq 1 ] && assert_can_git_clone "cc_root"; then
1150 # Copy code coverage repository
1151 echo "Cloning Code Coverage..."
1152 git clone -q $cc_src_repo_url cc_plugin --depth 1 -b $cc_src_repo_tag > /dev/null
1153 show_head "$cc_root"
1154 fi
1155fi
1156
Olivier Deprez0a9a3482019-12-16 14:10:31 +01001157if [ "$spm_config" ] && assert_can_git_clone "spm_root"; then
1158 # If the SPM repository has already been checked out, use
1159 # that location. Otherwise, clone one ourselves.
1160 echo "Cloning SPM..."
1161 clone_url="${SPM_CHECKOUT_LOC:-$spm_src_repo_url}" where="$spm_root" \
1162 refspec="$SPM_REFSPEC" clone_repo &>>"$build_log"
1163
1164 # Query git submodules
1165 pushd "$spm_root"
1166 git submodule update --init
1167 popd
1168
1169 show_head "$spm_root"
1170fi
1171
Fathi Boudra422bf772019-12-02 11:10:16 +02001172if [ "$run_config" ]; then
1173 # Get candidates for run config
1174 run_config_candiates="$("$ci_root/script/gen_run_config_candidates.py" \
1175 "$run_config")"
1176 if [ -z "$run_config_candiates" ]; then
1177 die "No run config candidates!"
1178 else
1179 echo
1180 echo "Chosen fragments:"
1181 echo
1182 echo "$run_config_candiates" | sed 's/^\|\n/\t/g'
1183 echo
1184 fi
1185fi
1186
1187call_hook "test_setup"
1188echo
1189
1190if upon "$local_ci"; then
1191 # For local runs, since each config is tried in sequence, it's
1192 # advantageous to run jobs in parallel
1193 if [ "$make_j" ]; then
1194 make_j_opts="-j $make_j"
1195 else
1196 n_cores="$(getconf _NPROCESSORS_ONLN)" 2>/dev/null || true
1197 if [ "$n_cores" ]; then
1198 make_j_opts="-j $n_cores"
1199 fi
1200 fi
1201fi
1202
1203modes="${bin_mode:-debug release}"
1204for mode in $modes; do
1205 # Build with a temporary archive
1206 build_archive="$archive/$mode"
1207 mkdir "$build_archive"
1208
1209 if [ "$mode" = "debug" ]; then
Zelalem219df412020-05-17 19:21:20 -05001210 export bin_mode="debug"
Fathi Boudra422bf772019-12-02 11:10:16 +02001211 DEBUG=1
1212 else
Zelalem219df412020-05-17 19:21:20 -05001213 export bin_mode="release"
Fathi Boudra422bf772019-12-02 11:10:16 +02001214 DEBUG=0
1215 fi
1216
1217 # Perform builds in a subshell so as not to pollute the current and
1218 # subsequent builds' environment
1219
Zelalem219df412020-05-17 19:21:20 -05001220 if config_valid "$cc_config"; then
1221 # Build code coverage plugin
1222 build_cc
1223 fi
1224
Fathi Boudra422bf772019-12-02 11:10:16 +02001225 # SCP build
1226 if config_valid "$scp_config"; then
1227 (
1228 echo "##########"
1229
1230 # Source platform-specific utilities
1231 plat="$(get_scp_opt PRODUCT)"
1232 plat_utils="$ci_root/${plat}_utils.sh"
1233 if [ -f "$plat_utils" ]; then
1234 source "$plat_utils"
1235 fi
1236
1237 archive="$build_archive"
1238 scp_build_root="$scp_root/build"
1239
1240 echo "Building SCP Firmware ($mode) ..." |& log_separator
1241
1242 build_scp
Fathi Boudra422bf772019-12-02 11:10:16 +02001243 to="$archive" collect_scp_artefacts
1244
1245 echo "##########"
1246 echo
1247 )
1248 fi
1249
Zelalem219df412020-05-17 19:21:20 -05001250 # SCP-tools build
1251 if config_valid "$scp_tools_config"; then
1252 (
1253 echo "##########"
1254
1255 archive="$build_archive"
1256 scp_tools_build_root="$scp_tools_root/build"
1257
1258 clone_scp_tools
1259
1260 echo "##########"
1261 echo
1262
1263 echo "##########"
1264 clone_tf_for_scp_tools
1265 echo "##########"
1266 echo
1267 )
1268 fi
1269
Fathi Boudra422bf772019-12-02 11:10:16 +02001270 # TFTF build
1271 if config_valid "$tftf_config"; then
1272 (
1273 echo "##########"
1274
Manish V Badarkhe3bd3fea2020-11-08 15:17:00 +00001275 plat_utils="$(get_tf_opt PLAT_UTILS)"
1276 if [ -z ${plat_utils} ]; then
1277 # Source platform-specific utilities.
1278 plat="$(get_tftf_opt PLAT)"
1279 plat_utils="$ci_root/${plat}_utils.sh"
1280 else
1281 # Source platform-specific utilities by
1282 # using plat_utils name.
1283 plat_utils="$ci_root/${plat_utils}.sh"
1284 fi
1285
Fathi Boudra422bf772019-12-02 11:10:16 +02001286 if [ -f "$plat_utils" ]; then
1287 source "$plat_utils"
1288 fi
1289
1290 archive="$build_archive"
1291 tftf_build_root="$tftf_root/build"
1292
1293 echo "Building Trusted Firmware TF ($mode) ..." |& log_separator
1294
1295 # Call pre-build hook
1296 call_hook pre_tftf_build
1297
1298 build_tftf
1299
1300 from="$tftf_build_root" to="$archive" collect_build_artefacts
1301
1302 # Clear any local changes made by applied patches
1303 undo_tftf_patches
1304
1305 echo "##########"
1306 echo
1307 )
1308 fi
1309
Olivier Deprez0a9a3482019-12-16 14:10:31 +01001310 # SPM build
1311 if config_valid "$spm_config"; then
1312 (
1313 echo "##########"
1314
1315 # Get platform name from spm_config file
1316 plat="$(echo "$spm_config" | awk -F- '{print $1}')"
1317 plat_utils="$ci_root/${plat}_utils.sh"
1318 if [ -f "$plat_utils" ]; then
1319 source "$plat_utils"
1320 fi
1321
1322 archive="$build_archive"
1323 spm_build_root="$spm_root/out/reference/secure_aem_v8a_fvp_clang"
1324
1325 echo "Building SPM ($mode) ..." |& log_separator
1326
1327 # NOTE: mode has no effect on SPM build (for now), hence debug
1328 # mode is built but subsequent build using release mode just
1329 # goes through with "nothing to do".
1330 build_spm
1331
1332 # Show SPM/Hafnium binary details
1333 ls -lart $spm_build_root/hafnium.bin
1334 cksum $spm_build_root/hafnium.bin
1335
1336 from="$spm_build_root" to="$archive" collect_build_artefacts
1337
1338 echo "##########"
1339 echo
1340 )
1341 fi
1342
Fathi Boudra422bf772019-12-02 11:10:16 +02001343 # TF build
1344 if config_valid "$tf_config"; then
1345 (
1346 echo "##########"
1347
Manish V Badarkhe3bd3fea2020-11-08 15:17:00 +00001348 plat_utils="$(get_tf_opt PLAT_UTILS)"
1349 if [ -z ${plat_utils} ]; then
1350 # Source platform-specific utilities.
1351 plat="$(get_tf_opt PLAT)"
1352 plat_utils="$ci_root/${plat}_utils.sh"
1353 else
1354 # Source platform-specific utilities by
1355 # using plat_utils name.
1356 plat_utils="$ci_root/${plat_utils}.sh"
1357 fi
1358
Fathi Boudra422bf772019-12-02 11:10:16 +02001359 if [ -f "$plat_utils" ]; then
1360 source "$plat_utils"
1361 fi
1362
1363 archive="$build_archive"
1364 tf_build_root="$tf_root/build"
1365
1366 echo "Building Trusted Firmware ($mode) ..." |& log_separator
1367
1368 # Call pre-build hook
1369 call_hook pre_tf_build
1370
1371 build_tf
1372
1373 # Call post-build hook
1374 call_hook post_tf_build
1375
1376 # Pre-archive hook
1377 call_hook pre_tf_archive
1378
1379 from="$tf_build_root" to="$archive" collect_build_artefacts
1380
1381 # Post-archive hook
1382 call_hook post_tf_archive
1383
1384 call_hook fetch_tf_resource
1385 call_hook post_fetch_tf_resource
1386
1387 # Clear any local changes made by applied patches
1388 undo_tf_patches
1389
1390 echo "##########"
1391 )
1392 fi
1393
1394 echo
1395 echo
1396done
1397
1398call_hook pre_package
1399
1400call_hook post_package
1401
1402if upon "$jenkins_run" && upon "$artefacts_receiver" && [ -d "artefacts" ]; then
Zelalem219df412020-05-17 19:21:20 -05001403 source "$CI_ROOT/script/send_artefacts.sh" "artefacts"
Fathi Boudra422bf772019-12-02 11:10:16 +02001404fi
1405
1406echo
1407echo "Done"