feat(build_package): add build_tf_extra() helper function

It allows building any extra rule from TF-A makefile, which is useful
in case you need to build something else than firmware binaries or the
FIP.

Change-Id: Ie63d8b152762934561405de5937e44696ba4081a
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
diff --git a/script/build_package.sh b/script/build_package.sh
index 741c797..c63db61 100755
--- a/script/build_package.sh
+++ b/script/build_package.sh
@@ -336,6 +336,29 @@
 	)
 }
 
+# Build any extra rule from TF-A makefile with supplied arguments.
+#
+# This is useful in case you need to build something else than firmware binaries
+# or the FIP.
+build_tf_extra() {
+	(
+	tf_extra_rules=${tf_extra_rules:?}
+	echo "Building extra TF rule(s): $tf_extra_rules"
+	echo "  Arguments: $@"
+
+	local tf_env="$workspace/tf.env"
+
+	if [ -f "$tf_env" ]; then
+		set -a
+		source "$tf_env"
+		set +a
+	fi
+
+	make -C "$tf_root" $(cat "$tf_config_file") DEBUG="$DEBUG" V=1 "$@" \
+		${tf_extra_rules} &>>"$build_log" || fail_build
+	)
+}
+
 fip_update() {
 	# Before the update process, check if the given image is supported by
 	# the fiptool. It's assumed that both fiptool and cert_create move in