From 1e8340f69bf3283db28db2017a560314f4aeb48b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 29 Nov 2023 16:41:38 +0100 Subject: [PATCH 1/2] Fix propagating cmake exit code from gen-buildsys.sh While looking at https://github.com/dotnet/runtime/pull/95405 I noticed that we didn't fail the build when the cmake configure step failed but tried to run the build regardless. The reason is because in ece10adbddc8d7b18711f1ad753f75a6e2234caa another command `popd` was added after the cmake invocation which overwrote the exit code so build-commons.sh didn't know cmake failed. --- eng/native/gen-buildsys.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index b39448626fb3a0..223e0ed89be26c 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -116,4 +116,6 @@ $cmake_command \ $__UnprocessedCMakeArgs \ "$1" +cmake_exit_code=$? popd +exit $cmake_exit_code From 07713869b5cf0eead9dd9cdb15aa726f8aea068d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Wed, 29 Nov 2023 16:58:02 +0100 Subject: [PATCH 2/2] Use -S and -B flags instead --- eng/native/gen-buildsys.sh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index 223e0ed89be26c..04c1e1f99bb0d9 100755 --- a/eng/native/gen-buildsys.sh +++ b/eng/native/gen-buildsys.sh @@ -104,9 +104,6 @@ if [[ "$host_arch" == "wasm" ]]; then fi fi -# We have to be able to build with CMake 3.6.2, so we can't use the -S or -B options -pushd "$2" - $cmake_command \ --no-warn-unused-cli \ -G "$generator" \ @@ -114,8 +111,7 @@ $cmake_command \ "-DCMAKE_INSTALL_PREFIX=$__CMakeBinDir" \ $cmake_extra_defines \ $__UnprocessedCMakeArgs \ - "$1" + -S "$1" \ + -B "$3" -cmake_exit_code=$? -popd -exit $cmake_exit_code +exit $?