• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# Builds Trusted OS, mainly for ARM Trusted Firmware.
4# Calls $ATF_SPD-build.sh for the actual build of a specific Trusted OS.
5# Not intended to be called directly, invoked from uefi-build.sh.
6#
7# Board configuration is extracted from
8# parse-platforms.py and platforms.config.
9#
10
11. "$TOOLS_DIR"/common-functions
12
13function usage
14{
15	echo "usage:"
16	echo "tos-build.sh -e <EDK2 source directory> -t <UEFI build profile/toolchain> <platform>"
17	echo
18}
19
20function build_platform
21{
22	if [ X"$EDK2_DIR" = X"" ];then
23		echo "EDK2_DIR not set!" >&2
24		return 1
25	fi
26
27	if [ X"`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $1 get -o build_tos`" = X"" ]; then
28		echo "Platform '$1' is not configured to build Trusted OS."
29		return 0
30	fi
31
32	#
33	# Build Trusted OS
34	#
35	ATF_SPD="`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $1 get -o atf_spd`"
36	if [ -f $TOOLS_DIR/$ATF_SPD-build.sh ]; then
37		echo "Building $ATF_SPD Trusted OS"
38		if [ $VERBOSE -eq 1 ]; then
39			echo "$TOOLS_DIR/$ATF_SPD-build.sh -e "$EDK2_DIR" -t "$BUILD_PROFILE" $build"
40		fi
41		$TOOLS_DIR/$ATF_SPD-build.sh -e "$EDK2_DIR" -t "$BUILD_PROFILE" $build
42		return $?
43	else
44		echo "ERROR: missing Trusted OS build script."
45		echo "       Or build script not named $ATF_SPD-build.sh"
46		return 1
47	fi
48}
49
50build=
51
52if [ $# = 0 ]
53then
54	usage
55	exit 1
56else
57	while [ "$1" != "" ]; do
58		case $1 in
59			"-e" )
60				shift
61				EDK2_DIR="$1"
62				;;
63			"/h" | "/?" | "-?" | "-h" | "--help" )
64				usage
65				exit
66				;;
67			"-t" )
68				shift
69				BUILD_PROFILE="$1"
70				;;
71			* )
72				build="$1"
73				;;
74		esac
75		shift
76	done
77fi
78
79if [ X"$build" = X"" ]; then
80	echo "No platform specified!" >&2
81	echo
82	usage
83	exit 1
84fi
85
86build_platform $build
87exit $?
88