mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-12-04 00:20:50 +00:00
Merge pull request #26633 from SnehPatel21/fix/winlibs-windres-install-path
fix(build): handle spaces in the WinLibs resource compiler path
This commit is contained in:
4 files changed
+39
-1
No files matched your search
@@ -8,6 +8,22 @@ project(Relinker CXX)
|
||||
set(ANYPS5_TEST_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests")
|
||||
if(MINGW)
|
||||
enable_language(RC)
|
||||
function(configure_windows_resource_preprocessor target source)
|
||||
if(NOT CMAKE_HOST_WIN32 OR CMAKE_VERSION VERSION_LESS 3.25 OR NOT CMAKE_GENERATOR MATCHES "Ninja|Makefiles")
|
||||
return()
|
||||
endif()
|
||||
get_filename_component(resourceCompiler "${CMAKE_RC_COMPILER}" NAME_WE)
|
||||
get_filename_component(resourceCompilerDirectory "${CMAKE_RC_COMPILER}" DIRECTORY)
|
||||
if(NOT resourceCompiler MATCHES "^(.*-mingw32-)?windres$" OR NOT resourceCompilerDirectory MATCHES " "
|
||||
OR NOT EXISTS "${resourceCompilerDirectory}/gcc.exe")
|
||||
return()
|
||||
endif()
|
||||
set(launcher "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/cmake/WindowsResourceCompiler.cmake")
|
||||
set_property(TARGET ${target} PROPERTY RULE_LAUNCH_COMPILE
|
||||
"\"${CMAKE_COMMAND}\" -P \"${launcher}\" --")
|
||||
set_property(SOURCE "${source}" APPEND PROPERTY OBJECT_DEPENDS "${launcher}")
|
||||
endfunction()
|
||||
|
||||
function(add_test_executable_manifests_test)
|
||||
if(NOT BUILD_TESTING)
|
||||
return()
|
||||
@@ -259,6 +275,7 @@ if(MINGW)
|
||||
add_library(anyps5_windows_test_exit OBJECT cmake/WindowsTestExit.cpp)
|
||||
add_library(anyps5_windows_test_manifest OBJECT cmake/WindowsManifest.rc)
|
||||
set_source_files_properties(cmake/WindowsManifest.rc PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/WindowsManifest.manifest)
|
||||
configure_windows_resource_preprocessor(anyps5_windows_test_manifest cmake/WindowsManifest.rc)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
set(compiler "${CMAKE_ARGV4}")
|
||||
set(arguments)
|
||||
set(hasPreprocessorOverride OFF)
|
||||
math(EXPR last "${CMAKE_ARGC} - 1")
|
||||
foreach(index RANGE 5 ${last})
|
||||
set(argument "${CMAKE_ARGV${index}}")
|
||||
if(argument MATCHES "^--preprocessor(-arg)?(=|$)")
|
||||
set(hasPreprocessorOverride ON)
|
||||
endif()
|
||||
string(REPLACE ";" "\\;" argument "${argument}")
|
||||
list(APPEND arguments "${argument}")
|
||||
endforeach()
|
||||
if(NOT hasPreprocessorOverride)
|
||||
get_filename_component(compilerDirectory "${compiler}" DIRECTORY)
|
||||
set(ENV{PATH} "${compilerDirectory};$ENV{PATH}")
|
||||
list(PREPEND arguments --preprocessor=gcc.exe --preprocessor-arg=-E --preprocessor-arg=-xc --preprocessor-arg=-DRC_INVOKED)
|
||||
endif()
|
||||
execute_process(COMMAND "${compiler}" ${arguments} COMMAND_ERROR_IS_FATAL ANY)
|
||||
@@ -268,6 +268,9 @@ endif()
|
||||
if(WIN32)
|
||||
add_library(relinker_resources OBJECT ${CMAKE_CURRENT_SOURCE_DIR}/relinker.rc)
|
||||
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/relinker.rc PROPERTIES OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/relinker.manifest)
|
||||
if(MINGW)
|
||||
configure_windows_resource_preprocessor(relinker_resources "${CMAKE_CURRENT_SOURCE_DIR}/relinker.rc")
|
||||
endif()
|
||||
target_sources(relinker PRIVATE $<TARGET_OBJECTS:relinker_resources>)
|
||||
if(MSVC)
|
||||
set_target_properties(relinker PROPERTIES LINK_FLAGS "/MANIFEST:NO")
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -
|
||||
|
||||
The documentation runs the Python tools as `python3`. With the python.org installer for Windows, which provides `python.exe` and the `py` launcher but no `python3.exe`, `python3` resolves to the Microsoft Store alias in `WindowsApps`, which prints `Python was not found` and exits with code 9009 (49 in Git Bash). Installs that provide `python3.exe`, such as the Python Install Manager, are not affected. In that case run these commands with `python` or `py -3`, for example `py -3 tools/check_conventions.py`.
|
||||
|
||||
If `windres` reports `preprocessing failed` and Windows prints the first part of the WinLibs installation path as an unrecognized command, `windres` may be splitting the path to its preprocessor at a space. This can occur when WinLibs GCC 15.2.0 r7 is installed in a directory with spaces. With the selected WinLibs `bin` directory first on `PATH`, append the following argument to the CMake configure command.
|
||||
If `windres` reports `preprocessing failed` and Windows prints the first part of the WinLibs installation path as an unrecognized command, `windres` may be splitting the path to its preprocessor at a space. CMake 3.25 or newer with Ninja or Makefiles handles this for the relinker and test manifests by selecting the `gcc.exe` alongside `windres`. For older CMake versions, put the selected WinLibs `bin` directory first on `PATH` and append the following argument to the CMake configure command.
|
||||
|
||||
```powershell
|
||||
'-DCMAKE_RC_FLAGS=--preprocessor=gcc.exe --preprocessor-arg=-E --preprocessor-arg=-xc --preprocessor-arg=-DRC_INVOKED'
|
||||
|
||||
Reference in new issue
Block a user