tests/docker/dockerfiles: Add ccache to containers where it was missing
[qemu/rayw.git] / tests / uefi-test-tools / build.sh
blob3b78f30840692c1ce17989bcb63f87d99aca4004
1 #!/bin/bash
3 # Build script that determines the edk2 toolchain to use, invokes the edk2
4 # "build" utility, and copies the built UEFI binary to the requested location.
6 # Copyright (C) 2019, Red Hat, Inc.
8 # This program and the accompanying materials are licensed and made available
9 # under the terms and conditions of the BSD License that accompanies this
10 # distribution. The full text of the license may be found at
11 # <http://opensource.org/licenses/bsd-license.php>.
13 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 set -e -u -C
18 # Save the command line arguments. We need to reset $# to 0 before sourcing
19 # "edksetup.sh", as it will inherit $@.
20 program_name=$(basename -- "$0")
21 edk2_dir=$1
22 dsc_component=$2
23 emulation_target=$3
24 uefi_binary=$4
25 shift 4
27 # Set up the environment for edk2 building.
28 export PACKAGES_PATH=$(realpath -- "$edk2_dir")
29 export WORKSPACE=$PWD
30 mkdir -p Conf
32 export PYTHON_COMMAND=${EDK2_PYTHON_COMMAND:-python3}
34 # Source "edksetup.sh" carefully.
35 set +e +u +C
36 source "$PACKAGES_PATH/edksetup.sh"
37 ret=$?
38 set -e -u -C
39 if [ $ret -ne 0 ]; then
40 exit $ret
43 # Fetch some option arguments, and set the cross-compilation environment (if
44 # any), for the edk2 "build" utility.
45 source "$edk2_dir/../edk2-funcs.sh"
46 edk2_arch=$(qemu_edk2_get_arch "$emulation_target")
47 edk2_toolchain=$(qemu_edk2_get_toolchain "$emulation_target")
48 MAKEFLAGS=$(qemu_edk2_quirk_tianocore_1607 "$MAKEFLAGS")
49 edk2_thread_count=$(qemu_edk2_get_thread_count "$MAKEFLAGS")
50 qemu_edk2_set_cross_env "$emulation_target"
52 # Build the UEFI binary
53 mkdir -p log
54 build \
55 --arch="$edk2_arch" \
56 -n "$edk2_thread_count" \
57 --buildtarget=DEBUG \
58 --platform=UefiTestToolsPkg/UefiTestToolsPkg.dsc \
59 --tagname="$edk2_toolchain" \
60 --module="UefiTestToolsPkg/$dsc_component/$dsc_component.inf" \
61 --log="log/$dsc_component.$edk2_arch.log" \
62 --report-file="log/$dsc_component.$edk2_arch.report"
63 cp -a -- \
64 "Build/UefiTestTools/DEBUG_${edk2_toolchain}/$edk2_arch/$dsc_component.efi" \
65 "$uefi_binary"