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 a0f7c83
Show file tree
Hide file tree
Showing 4 changed files with 338 additions and 257 deletions.
25 changes: 25 additions & 0 deletions .github/scripts/build-to-product-version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-License-Identifier: MIT
if(NOT BUILD_VERSION OR NOT OUTPUT_PATH)
message(FATAL_ERROR "BUILD_VERSION and OUTPUT_PATH are required")
endif()

message(STATUS "Build version: '${BUILD_VERSION}'")
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(BUILD_VERSION MATCHES "-beta\\.([0-9]+)")
set(beta "${CMAKE_MATCH_1}")
else()
set(beta 0)
endif()

set(PRODUCT_VERSION "${server}.${major}.${minor}.${beta}")
message(STATUS "Product version: '${PRODUCT_VERSION}'")
file(APPEND "${OUTPUT_PATH}" "WINDOWS_PRODUCT_VERSION=${PRODUCT_VERSION}\n")
else()
message(FATAL_ERROR "Unable to determine product version")
endif()


25 changes: 25 additions & 0 deletions .github/scripts/edit-pe-metadata.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-License-Identifier: MIT
if(NOT PRODUCT_NAME OR NOT PRODUCT_VERSION OR NOT SEARCH_PATHS)
message(FATAL_ERROR "PRODUCT_NAME, PRODUCT_VERSION and SEARCH_PATHS are required")
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 a0f7c83

Please sign in to comment.