Skip to content

Commit

Permalink
chore: add resource info for windows MSVC build
Browse files Browse the repository at this point in the history
  • Loading branch information
fxliang committed Mar 11, 2024
1 parent 7470f38 commit 643aeab
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ option(INSTALL_PRIVATE_HEADERS "Install private headers (usually needed for exte
option(ENABLE_EXTERNAL_PLUGINS "Enable loading of externally built Rime plugins (from directory set by RIME_PLUGINS_DIR variable)" OFF)
option(ENABLE_THREADING "Enable threading for deployer" ON)
option(ENABLE_TIMESTAMP "Embed timestamp to schema artifacts" ON)
option(BUILD_RELEASE "Build a release version" OFF)

set(RIME_DATA_DIR "rime-data" CACHE STRING "Target directory for Rime data")
set(RIME_PLUGINS_DIR "rime-plugins" CACHE STRING "Target directory for externally built Rime plugins")
Expand Down
40 changes: 40 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,46 @@ set(rime_core_module_src
${rime_api_src}
${rime_base_src}
${rime_config_src})

# add rc info for windows MSVC build
if(MSVC)
# check if HEAD on master
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE)
if ("${GIT_BRANCH}" STREQUAL "master")
set(BUILD_RELEASE OFF)
else()
set(BUILD_RELEASE ON)
endif()
# generate tag_subfix for nightly and release
if(BUILD_RELEASE)
set(tag_subfix ".0")
else()
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(bitsubfix "x64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(bitsubfix "Win32")
endif()
set(tag_subfix "-${GIT_COMMIT} Nightly build ${bitsubfix}")
endif()
# set resource file
set(RIME_RESOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/rime.rc")
# convert rime_version to comma separated format
string(REPLACE "." "," RIME_VERSION_COMMA_SEPARATED ${rime_version})
# configure resource file, make version info to actually value
configure_file(${RIME_RESOURCE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/rime.rc @ONLY)
# append resource file to source file list
list(APPEND rime_core_module_src ${CMAKE_CURRENT_BINARY_DIR}/rime.rc)
endif()

set(rime_dict_module_src
${rime_algo_src}
${rime_dict_src})
Expand Down
61 changes: 61 additions & 0 deletions src/rime.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "winver.h"
#ifdef MSVC
#pragma code_page (65001)
#endif

VS_VERSION_INFO VERSIONINFO
FILEVERSION @RIME_VERSION_COMMA_SEPARATED@,0
PRODUCTVERSION @RIME_VERSION_COMMA_SEPARATED@,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080404b0"
BEGIN
VALUE "Comments", "Powered by RIME | 中州韵输入法引擎"
VALUE "CompanyName", "式恕堂"
VALUE "FileDescription", "中州韵输入法引擎"
VALUE "InternalName", "librime"
VALUE "LegalCopyright", "式恕堂 版权所无"
VALUE "OriginalFilename", "rime.dll"
VALUE "ProductName", "中州韵输入法引擎"
VALUE "ProductVersion", "@rime_version@@tag_subfix@"
END
BLOCK "040904b0"
BEGIN
VALUE "Comments", "Powered by RIME | 中州韻輸入法引擎"
VALUE "CompanyName", "式恕堂"
VALUE "FileDescription", "中州韻輸入法引擎"
VALUE "InternalName", "librime"
VALUE "LegalCopyright", "式恕堂 版權所無"
VALUE "OriginalFilename", "rime.dll"
VALUE "ProductName", "中州韻輸入法引擎"
VALUE "ProductVersion", "@rime_version@@tag_subfix@"
END
BLOCK "040904E4"
BEGIN
VALUE "Comments", "Powered by RIME | Rime Input Method Engine"
VALUE "CompanyName", "rime.io"
VALUE "FileDescription", "Rime Input Method Engine"
VALUE "InternalName", "librime"
VALUE "LegalCopyright", "All Left reserved ©rime.io "
VALUE "OriginalFilename", "rime.dll"
VALUE "ProductName", "Rime Input Method Engine"
VALUE "ProductVersion", "@rime_version@@tag_subfix@"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x804, 1200
VALUE "Translation", 0x409, 1200
VALUE "Translation", 0x409, 1252
END
END

0 comments on commit 643aeab

Please sign in to comment.