diff --git a/CMakeLists.txt b/CMakeLists.txt index e4b4e85585..cfb5935b2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6ee20e8956..a9e10590df 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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}) diff --git a/src/rime.rc b/src/rime.rc new file mode 100644 index 0000000000..8318a0f748 --- /dev/null +++ b/src/rime.rc @@ -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