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.
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")
27 # Set up the environment for edk2 building.
28 export PACKAGES_PATH
=$
(realpath
-- "$edk2_dir")
32 # Source "edksetup.sh" carefully.
34 source "$PACKAGES_PATH/edksetup.sh"
37 if [ $ret -ne 0 ]; then
41 # Map the QEMU system emulation target to the following types of architecture
44 # - gcc cross-compilation.
45 # Cover only those targets that are supported by the UEFI spec and edk2.
46 case "$emulation_target" in
64 printf '%s: unknown/unsupported QEMU system emulation target "%s"\n' \
65 "$program_name" "$emulation_target" >&2
70 # Check if cross-compilation is needed.
72 if [ "$gcc_arch" == "$host_arch" ] ||
73 ( [ "$gcc_arch" == i686
] && [ "$host_arch" == x86_64
] ); then
76 cross_prefix
=${gcc_arch}-linux-gnu-
79 # Expose cross_prefix (which is possibly empty) to the edk2 tools. While at it,
80 # determine the suitable edk2 toolchain as well.
81 # - For ARM and AARCH64, edk2 only offers the GCC5 toolchain tag, which covers
82 # the gcc-5+ releases.
83 # - For IA32 and X64, edk2 offers the GCC44 through GCC49 toolchain tags, in
84 # addition to GCC5. Unfortunately, the mapping between the toolchain tags and
85 # the actual gcc releases isn't entirely trivial. Run "git-blame" on
86 # "OvmfPkg/build.sh" in edk2 for more information.
87 # And, because the above is too simple, we have to assign cross_prefix to an
88 # edk2 build variable that is specific to both the toolchain tag and the target
93 export GCC5_ARM_PREFIX
=$cross_prefix
97 export GCC5_AARCH64_PREFIX
=$cross_prefix
100 gcc_version
=$
("${cross_prefix}gcc" -v 2>&1 |
tail -1 |
awk '{print $3}')
101 case "$gcc_version" in
103 printf '%s: unsupported gcc version "%s"\n' \
104 "$program_name" "$gcc_version" >&2
129 eval "export ${edk2_toolchain}_BIN=\$cross_prefix"
133 # Build the UEFI binary
136 --arch="$edk2_arch" \
137 --buildtarget=DEBUG \
138 --platform=UefiTestToolsPkg
/UefiTestToolsPkg.dsc \
139 --tagname="$edk2_toolchain" \
140 --module="UefiTestToolsPkg/$dsc_component/$dsc_component.inf" \
141 --log="log/$dsc_component.$edk2_arch.log" \
142 --report-file="log/$dsc_component.$edk2_arch.report"
144 "Build/UefiTestTools/DEBUG_${edk2_toolchain}/$edk2_arch/$dsc_component.efi" \