From 9bb2b5be2ecc34b48a609b2445f9a13bb614a4a7 Mon Sep 17 00:00:00 2001 From: Ivan Diaz Sanchez Date: Wed, 29 Nov 2023 10:46:09 -0800 Subject: [PATCH] Replace `pushd/popd` Calls With `-S/-B` CMake Flags in the Build System (#94353) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Successfully replaced pushd/popd with CMake's -S/-B in gen-buildsys.sh for native and clr. Now, looking into removing other instances if possible. * Removed redundant pushd/popd in src/native/libs/build-native.cmd * Experimenting with removing 'pushd/popd' for Wasm/Wasi. * Restored pushd/popd to eng/native/build-commons.sh because it is actually not directly related to CMake. * Add explicit exit code to gen-buildsys.sh Make sure we don't forget to return the cmake exist code, see https://github.com/dotnet/runtime/pull/95408. * Replace with comment instead --------- Co-authored-by: Alexander Köplinger --- eng/native/gen-buildsys.sh | 8 +++----- src/native/libs/build-native.cmd | 2 -- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/eng/native/gen-buildsys.sh b/eng/native/gen-buildsys.sh index b39448626fb3a..4c1ed0943c45a 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,6 +111,7 @@ $cmake_command \ "-DCMAKE_INSTALL_PREFIX=$__CMakeBinDir" \ $cmake_extra_defines \ $__UnprocessedCMakeArgs \ - "$1" + -S "$1" \ + -B "$2" -popd +# don't add anything after this line so the cmake exit code gets propagated correctly diff --git a/src/native/libs/build-native.cmd b/src/native/libs/build-native.cmd index b1a23666457a7..13e7334a73c53 100644 --- a/src/native/libs/build-native.cmd +++ b/src/native/libs/build-native.cmd @@ -102,10 +102,8 @@ echo %MSBUILD_EMPTY_PROJECT_CONTENT% > "%__artifactsDir%\obj\native\Directory.Bu :: Regenerate the VS solution -pushd "%__IntermediatesDir%" call "%__repoRoot%\eng\native\gen-buildsys.cmd" "%__sourceRootDir%" "%__IntermediatesDir%" %__VSVersion% %__BuildArch% %__TargetOS% %__ExtraCmakeParams% if NOT [%errorlevel%] == [0] goto :Failure -popd :BuildNativeProj :: Build the project created by Cmake