Skip to contentSkip to conversation

cmake.bbclass: remove ${B} before cmake_do_configure

PATCH New kai 1 participant 2 messages Apr 23, 2021

lore
Share & tools
lore

kai

author
#0 lore raw

PATCH 1/2 cmake.bbclass: remove ${B} before cmake_do_configure

From: Kai Kang <[email protected]>

It is fallible to remove ${B} in directory ${B} itself. And it does fail when call bitbake by third-party wrapper script.

Use flag 'cleandirs' to remove ${B} first if build out of source tree.

---
 meta/classes/cmake.bbclass | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
meta/classes/cmake.bbclass +3 -5
index 8876ce5aa5..f01db7480b 100644
@@ -149,16 +149,14 @@ addtask generate_toolchain_file after do_patch before do_configure
 
 CONFIGURE_FILES = "CMakeLists.txt"
 
+do_configure[cleandirs] = "${@d.getVar('B') if d.getVar('S') != d.getVar('B') else ''}"
+
 cmake_do_configure() {
 	if [ "${OECMAKE_BUILDPATH}" ]; then
 		bbnote "cmake.bbclass no longer uses OECMAKE_BUILDPATH.  The default behaviour is now out-of-tree builds with B=WORKDIR/build."
 	fi
 
-	if [ "${S}" != "${B}" ]; then
-		rm -rf ${B}
-		mkdir -p ${B}
-		cd ${B}
-	else
+	if [ "${S}" = "${B}" ]; then
 		find ${B} -name CMakeFiles -or -name Makefile -or -name cmake_install.cmake -or -name CMakeCache.txt -delete
 	fi
 
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 2/2 kernel-yocto.bbclass: chdir to ${WORKDIR} for do_kernel_checkout

From: Kai Kang <[email protected]>

It chdirs to ${S} at the beginning of task do_kernel_checkout. Then it removes ${S} when it still resides in ${S}. It may fail to run the task do_kernel_checkout when bitbake is called by third-part wrapper script. So chdir to ${WORKDIR} by default for do_kernel_checkout. And it will chdir to ${S} afterwards in task do_kernel_checkout.

---
 meta/classes/kernel-yocto.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/kernel-yocto.bbclass +1 -1
index 15c8dbb81f..30f07de4ca 100644
@@ -378,7 +378,7 @@ do_kernel_checkout() {
 	# checkout and clobber any unimportant files
 	git checkout -f ${machine_branch}
 }
-do_kernel_checkout[dirs] = "${S}"
+do_kernel_checkout[dirs] = "${S} ${WORKDIR}"
 
 addtask kernel_checkout before do_kernel_metadata after do_symlink_kernsrc
 addtask kernel_metadata after do_validate_branches do_unpack before do_patch
Signature · 1 line
2.17.1