Skip to content

Commit

Permalink
WIP: rcedit
Browse files Browse the repository at this point in the history
  • Loading branch information
askmeaboutlo0m committed Oct 18, 2024
1 parent 12885af commit 3bc1f4e
Show file tree
Hide file tree
Showing 2 changed files with 315 additions and 254 deletions.
41 changes: 41 additions & 0 deletions .github/scripts/edit-pe-metadata.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# SPDX-License-Identifier: MIT
if(NOT PRODUCT_NAME OR NOT BUILD_VERSION OR NOT SEARCH_PATHS)
message(FATAL_ERROR "PRODUCT_NAME, BUILD_VERSION and SEARCH_PATHS are required")
endif()

if(BUILD_VERSION MATCHES "^([0-9]+)\.([0-9]+)\.([0-9]+)")
set(server "${CMAKE_MATCH_1}")
set(major "${CMAKE_MATCH_2}")
set(minor "${CMAKE_MATCH_3}")

if(version MATCHES "-beta\.([0-9]+)")
set(beta "${CMAKE_MATCH_1}")
else()
set(beta 0)
endif()

set(PRODUCT_VERSION "${server}.${major}.${minor}.${beta}")
else()
message(FATAL_ERROR "Unable to determine product version from '${BUILD_VERSION}'")
endif()

find_program(RCEDIT_COMMAND rcedit REQUIRED)

unset(globs)
foreach(search_path IN LISTS SEARCH_PATHS)
list(APPEND globs "${search_path}/*.dll" "${search_path}/*.exe")
endforeach()

message(STATUS "Looking for PE files: ${globs}")
file(GLOB_RECURSE pe_paths FOLLOW_SYMLINKS ${globs})
foreach(pe_path IN LISTS pe_paths)
execute_process(
COMMAND
${RCEDIT_COMMAND}
"${pe_path}"
--set-version-string ProductName "${PRODUCT_NAME}"
--set-version-string ProductVersion "${PRODUCT_VERSION}"
COMMAND_ECHO STDOUT
COMMAND_ERROR_IS_FATAL ANY
)
endforeach()
Loading

0 comments on commit 3bc1f4e

Please sign in to comment.