Ver código fonte

Merge pull request #6231 from kambala-decapitator/conan-windows-powershell

[windows] generate bat files that use conanrun.ps1
Ivan Savenko 1 dia atrás
pai
commit
4e790493d6

+ 8 - 4
cmake_modules/VCMIUtils.cmake

@@ -164,8 +164,12 @@ function(vcmi_create_exe_shim tgt)
 	if(NOT CONAN_RUNENV_SCRIPT)
 		return()
 	endif()
-	file(GENERATE OUTPUT "$<TARGET_FILE_DIR:${tgt}>/$<TARGET_FILE_BASE_NAME:${tgt}>.bat" CONTENT
-"call ${CONAN_RUNENV_SCRIPT}
-@start $<TARGET_FILE_NAME:${tgt}>"
-	)
+
+	set(exe "%~dp0$<TARGET_FILE_NAME:${tgt}>")
+	if(EXISTS "${CONAN_RUNENV_SCRIPT}.bat")
+		set(batContent "call \"${CONAN_RUNENV_SCRIPT}.bat\" & start \"\" \"${exe}\"")
+	else()
+		set(batContent "powershell -ExecutionPolicy Bypass -Command \"& '${CONAN_RUNENV_SCRIPT}.ps1' ; & '${exe}'\"")
+	endif()
+	file(GENERATE OUTPUT "$<TARGET_FILE_DIR:${tgt}>/$<TARGET_FILE_BASE_NAME:${tgt}>.bat" CONTENT "${batContent}")
 endfunction()

+ 1 - 1
conanfile.py

@@ -50,5 +50,5 @@ class VCMIApp(VCMI):
             tc.variables["CMAKE_ANDROID_API"] = str(self.settings.os.api_level)
             tc.variables["SDL_JAVA_SRC_DIR"] = os.path.join(self.dependencies.host["sdl"].package_folder, "share", "java", "SDL2")
         elif self.settings.os == "Windows":
-            tc.variables["CONAN_RUNENV_SCRIPT"] = self._pathForCmake(os.path.join(self.build_folder, "conanrun.bat"))
+            tc.variables["CONAN_RUNENV_SCRIPT"] = self._pathForCmake(os.path.join(self.build_folder, "conanrun"))
         tc.generate()

+ 2 - 2
docs/developers/Building_Windows.md

@@ -43,7 +43,7 @@ On the step where you need to replace **PROFILE**, choose:
 - `msvc-arm64` to build for ARM 64-bit (arm64)
 - `msvc-x86` to build for Intel 32-bit (x86)
 
-*Note*: we recommend using CMD (`cmd.exe`) for the next steps. If you absolutely want to use Powershell, then run `conan install` twice appending `-c tools.env.virtualenv:powershell=powershell.exe` on the second run.
+*Note*: we recommend using CMD (`cmd.exe`) for the next steps. If you absolutely want to use Powershell, then append `-c tools.env.virtualenv:powershell=powershell.exe` to the `conan install` command.
 
 ## Install CCache
 
@@ -98,7 +98,7 @@ call "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv
     - Specify the following CMake variable: `ENABLE_CCACHE=ON`
     - See the [Visual Studio documentation](https://learn.microsoft.com/en-us/cpp/build/customize-cmake-settings?view=msvc-170#cmake-variables-and-cache) for details
 4. Right click on `BUILD_ALL` project. This `BUILD_ALL` project should be in `CMakePredefinedTargets` tree in Solution Explorer. You can also build individual targets if you want.
-5. VCMI will be built in `%VCMI_DIR%/build/bin/<config>` folder where `<config>` is e.g. `RelWithDebInfo`. Use `bat` files to launch executables, e.g. `VCMI_launcher.bat`.
+5. VCMI will be built in `%VCMI_DIR%/build/bin/<config>` folder where `<config>` is e.g. `RelWithDebInfo`. To launch the built executables from a file manager, use respective `bat` files, e.g. `VCMI_launcher.bat`.
 
 ### Compile VCMI with MinGW via MSYS2
 

+ 1 - 1
docs/developers/Conan.md

@@ -115,7 +115,7 @@ Make sure that you've cloned VCMI repository with submodules! (or initialized th
 
 In terminal `cd` to the VCMI source directory and run the following command (it's written in Bash syntax, for other shells like Cmd or Powershell use appropriate line continuation character instead of `\` or type everything on a single line). Also check subsections for additional requirements on consuming prebuilt binaries.
 
-*Note*: if you're going to build for Windows MSVC, it's recommended to use Cmd shell. If you absolutely want to use Powershell, then run the below command twice appending `-c tools.env.virtualenv:powershell=powershell.exe` on the second run.
+*Note*: if you're going to build for Windows MSVC, it's recommended to use Cmd shell. If you absolutely want to use Powershell, then append `-c tools.env.virtualenv:powershell=powershell.exe` to the below command.
 
 <pre>
 conan install . \