[meta-arm,1/4] arm/trusted-firmware-m: clean up configure/compile

Submitted by Ross Burton on Aug. 12, 2020, 10:12 a.m. | Patch ID: 175243

Details

Message ID 20200812101251.3237307-1-ross.burton@arm.com
State New
Headers show

Commit Message

Ross Burton Aug. 12, 2020, 10:12 a.m.
From: Ross Burton <ross.burton@arm.com>

Move B up a level so the build tree is entirely separate from the source
tree.

Use [cleandirs] to ensure that B is present and empty when rebuilding,
and remove now redundant code.

Finally add some comments to explain why trying to use cmake.bbclass is
pointless.

Change-Id: Ic8ddc08c46b9e945023e0b0a6e4ca1a6294b726b
Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 .../trusted-firmware-m_1.0.bb                 | 30 +++++++++----------
 1 file changed, 14 insertions(+), 16 deletions(-)

Patch hide | download patch | download mbox

diff --git a/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.0.bb b/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.0.bb
index 3be1b33..814529a 100644
--- a/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.0.bb
+++ b/meta-arm/recipes-bsp/trusted-firmware-m/trusted-firmware-m_1.0.bb
@@ -30,6 +30,11 @@  SRCREV_mbed-crypto ?= "mbedcrypto-3.0.1"
 SRCREV_mbedtls ?= "mbedtls-2.7.14"
 SRCREV_cmsis ?= "5.5.0"
 
+# Note to future readers of this recipe: until the CMakeLists don't abuse
+# installation (see do_install) there is no point in trying to inherit
+# cmake here. You can easily short-circuit the toolchain but the install
+# is so convoluted there's no gain.
+
 inherit python3native deploy
 
 TFM_DEPENDS ?= ""
@@ -39,7 +44,7 @@  DEPENDS += "python3-cryptography-native python3-pyasn1-native"
 DEPENDS += "python3-jinja2-native python3-cbor-native python3-pyyaml-native"
 
 S = "${WORKDIR}/git/tfm"
-B = "${S}/build"
+B = "${WORKDIR}/build"
 
 COMPATIBLE_MACHINE ?= "invalid"
 
@@ -89,28 +94,21 @@  do_check_config() {
     fi
 }
 
+do_configure[cleandirs] = "${B}"
 do_configure() {
     cd ${S}
-    python3 "tools/tfm_parse_manifest_list.py"
-
-    if [ ! -d "${B}" ]
-    then
-        install -d ${B}
-    else
-        rm -f ${B}/CMakeCache.txt
-    fi
+    python3 tools/tfm_parse_manifest_list.py
+    cd -
 
-    cd ${B}
     cmake -G"Unix Makefiles" --build ${S} ${EXTRA_OECMAKE}
 }
 
+# Invoke install here as there's no point in splitting compile from install: the
+# first thing the build does is 'install' inside the build tree thus causing a
+# rebuild. It also overrides the install prefix to be in the build tree, so you
+# can't use the usual install prefix variables.
 do_compile() {
-    if [ -d "${B}" ]
-    then
-        oe_runmake -C ${B} install
-    else
-        bbfatal "TF-M CMake not generated!"
-    fi
+    oe_runmake install
 }
 
 do_install() {