[meta-mingw,v2,4/5] classes/toolchain-scripts-mingw32: Ensure exit code is success

Submitted by Joshua Watt on Nov. 19, 2018, 9:17 p.m. | Patch ID: 156408

Details

Message ID 20181119211752.18963-5-JPEWhacker@gmail.com
State New
Headers show

Commit Message

Joshua Watt Nov. 19, 2018, 9:17 p.m.
The "set" command in Windows has some unfortunate behaviors that can
frequently make it look like the toolchain script had an error. This
makes automated testing of the SDK more difficult, so add a line to the
environment setup script that ensures the script exits with success.

[YOCTO #13020]

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 classes/toolchain-scripts-mingw32.bbclass | 11 +++++++++++
 1 file changed, 11 insertions(+)

Patch hide | download patch | download mbox

diff --git a/classes/toolchain-scripts-mingw32.bbclass b/classes/toolchain-scripts-mingw32.bbclass
index a64f5f5..32493d7 100644
--- a/classes/toolchain-scripts-mingw32.bbclass
+++ b/classes/toolchain-scripts-mingw32.bbclass
@@ -81,6 +81,17 @@  toolchain_shared_env_script_sdkmingw32 () {
    FOR %%x IN (%OECORE_NATIVE_SYSROOT%\\environment-setup.d\\*.bat) DO call "%%x"
 )
 EOF
+
+	# set has some annoying properties:
+	# 1) If it is successful %ERRORLEVEL% is unchanged (as opposed to being set
+	#	 to 0 to indicate success)
+	# 2) Making an assignment like "set A=" is considered an error and sets
+	#	 %ERRORLEVEL% to 1.
+	#
+	# Practically, this means that if any of the set calls make an empty
+	# assignment that error will be propagated. To prevent this, a command is
+	# run to ensure that the "exit code" of this script is 0
+	echo "@%COMSPEC% /C exit 0 > NUL" >> $script
 }
 
 toolchain_create_sdk_siteconfig_append_sdkmingw32 () {