Home | History | Annotate | Download | only in uefi-tools
      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="`dirname $0`"
     12 . "$TOOLS_DIR"/common-functions
     13 
     14 function usage
     15 {
     16 	echo "usage:"
     17 	echo "tos-build.sh -e <EDK2 source directory> -t <UEFI build profile/toolchain> <platform>"
     18 	echo
     19 }
     20 
     21 function build_platform
     22 {
     23 	if [ X"$EDK2_DIR" = X"" ];then
     24 		echo "EDK2_DIR not set!" >&2
     25 		return 1
     26 	fi
     27 
     28 	if [ X"`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $1 get -o build_tos`" = X"" ]; then
     29 		echo "Platform '$1' is not configured to build Trusted OS."
     30 		return 0
     31 	fi
     32 
     33 	#
     34 	# Build Trusted OS
     35 	#
     36 	ATF_SPD="`$TOOLS_DIR/parse-platforms.py $PLATFORM_CONFIG -p $1 get -o atf_spd`"
     37 	if [ -f $TOOLS_DIR/$ATF_SPD-build.sh ]; then
     38 		echo "Building $ATF_SPD Trusted OS"
     39 		if [ $VERBOSE -eq 1 ]; then
     40 			echo "$TOOLS_DIR/$ATF_SPD-build.sh -e "$EDK2_DIR" -t "$BUILD_PROFILE" $build"
     41 		fi
     42 		$TOOLS_DIR/$ATF_SPD-build.sh -e "$EDK2_DIR" -t "$BUILD_PROFILE" $build
     43 		return $?
     44 	else
     45 		echo "ERROR: missing Trusted OS build script."
     46 		echo "       Or build script not named $ATF_SPD-build.sh"
     47 		return 1
     48 	fi
     49 }
     50 
     51 build=
     52 
     53 if [ $# = 0 ]
     54 then
     55 	usage
     56 	exit 1
     57 else
     58 	while [ "$1" != "" ]; do
     59 		case $1 in
     60 			"-e" )
     61 				shift
     62 				EDK2_DIR="$1"
     63 				;;
     64 			"/h" | "/?" | "-?" | "-h" | "--help" )
     65 				usage
     66 				exit
     67 				;;
     68 			"-t" )
     69 				shift
     70 				BUILD_PROFILE="$1"
     71 				;;
     72 			* )
     73 				build="$1"
     74 				;;
     75 		esac
     76 		shift
     77 	done
     78 fi
     79 
     80 if [ X"$build" = X"" ]; then
     81 	echo "No platform specified!" >&2
     82 	echo
     83 	usage
     84 	exit 1
     85 fi
     86 
     87 build_platform $build
     88 exit $?
     89