设置文件版本信息 (#1344)

* 设置文件版本信息

不固定为 0.0.0.0,可以不打开应用时读取版本信息
TouchHelper 版本检查和 Updater 检查更新时可以直接从文件读取版本号

* 设置文件版本号时不考虑MP_VERSION_TAG

同时从 public.py 中移除替换逻辑

* chore: RC 优化
1. 用 MP_VERSION_STRING 取代 MP_VERSION_TAG,前者不包含开头的 v 字符
2. RC 文件不再支持 VS 编辑,删除了冗余代码。区域由非特定语言改为 en-US
3. STRINGIFY 和 WIDEN_STRINGIFY 宏移到通用头文件

* chore: 简化 resource.h

* chore: 删除 APSTUDIO_READONLY_SYMBOLS 宏
这个宏供 VS 资源编辑器使用

* chore: 始终定义 MP_MEOW_VERSION
通过 MP_VERSION_STRING 区分开发版本和发布版本

* chore: 简化版本字符串提取
使用了正则表达式的正向先行断言

---------

Co-authored-by: Xu <blinue@outlook.com>
This commit is contained in:
Howard Wu 2025-12-02 18:28:58 +08:00 committed by GitHub
commit b38dbf2c9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 125 additions and 334 deletions

View file

@ -48,7 +48,9 @@ jobs:
echo "tag=$tag" >> $env:GITHUB_OUTPUT echo "tag=$tag" >> $env:GITHUB_OUTPUT
- name: Build - name: Build
run: python scripts/publish.py --compiler=ClangCL --platform=${{ matrix.platform }} --version-major=${{ inputs.major }} --version-minor=${{ inputs.minor }} --version-patch=${{ inputs.patch }} --version-tag=${{ steps.tag.outputs.tag }} --pfx-path=certs\Magpie.pfx --pfx-password="${{ secrets.MAGPIE_PFX_PASSWORD }}" run: |
$versionString = "${{ steps.tag.outputs.tag }}" -replace "^v(?=\d)", ""
python scripts/publish.py --compiler=ClangCL --platform=${{ matrix.platform }} --version-major=${{ inputs.major }} --version-minor=${{ inputs.minor }} --version-patch=${{ inputs.patch }} --version-string=$versionString --pfx-path=certs\Magpie.pfx --pfx-password="${{ secrets.MAGPIE_PFX_PASSWORD }}"
- name: Store artifacts - name: Store artifacts
uses: actions/upload-artifact@v5 uses: actions/upload-artifact@v5

View file

@ -2,7 +2,6 @@ import sys
import os import os
import subprocess import subprocess
import glob import glob
import re
import argparse import argparse
try: try:
@ -21,7 +20,7 @@ argParser.add_argument("--use-native-march", action="store_true")
argParser.add_argument("--version-major", type=int, default=0) argParser.add_argument("--version-major", type=int, default=0)
argParser.add_argument("--version-minor", type=int, default=0) argParser.add_argument("--version-minor", type=int, default=0)
argParser.add_argument("--version-patch", type=int, default=0) argParser.add_argument("--version-patch", type=int, default=0)
argParser.add_argument("--version-tag", default="") argParser.add_argument("--version-string", default="")
argParser.add_argument("--pfx-path", default="") argParser.add_argument("--pfx-path", default="")
argParser.add_argument("--pfx-password", default="") argParser.add_argument("--pfx-password", default="")
args = argParser.parse_args() args = argParser.parse_args()
@ -57,44 +56,11 @@ os.chdir(os.path.dirname(__file__) + "\\..")
p = subprocess.run("git rev-parse --short HEAD", capture_output=True) p = subprocess.run("git rev-parse --short HEAD", capture_output=True)
commitId = str(p.stdout, encoding="utf-8")[0:-1] commitId = str(p.stdout, encoding="utf-8")[0:-1]
versionNumProps = "" versionNumProps = f";MajorVersion={args.version_major};MinorVersion={args.version_minor};PatchVersion={args.version_patch}"
if args.version_major != 0 or args.version_minor != 0 or args.version_patch != 0: versionStrProp = "" if args.version_string == "" else f";VersionString={args.version_string}"
versionNumProps = f";MajorVersion={args.version_major};MinorVersion={args.version_minor};PatchVersion={args.version_patch}"
# 更新 RC 文件中的版本号
version = f"{args.version_major}.{args.version_minor}.{args.version_patch}.0"
version_comma = version.replace(".", ",")
for project in os.listdir("src"):
rcPath = f"src\\{project}\\{project}.rc"
if not os.access(rcPath, os.R_OK | os.W_OK):
continue
with open(rcPath, mode="r+", encoding="utf-8") as f:
src = f.read()
src = re.sub(
r"FILEVERSION .*?\n", "FILEVERSION " + version_comma + "\n", src
)
src = re.sub(
r"PRODUCTVERSION .*?\n", "PRODUCTVERSION " + version_comma + "\n", src
)
src = re.sub(
r'"FileVersion", *?".*?"\n', '"FileVersion", "' + version + '"\n', src
)
src = re.sub(
r'"ProductVersion", *?".*?"\n',
'"ProductVersion", "' + version + '"\n',
src,
)
f.seek(0)
f.truncate()
f.write(src)
versionTagProp = "" if args.version_tag == "" else f";VersionTag={args.version_tag}"
p = subprocess.run( p = subprocess.run(
f'"{msbuildPath}" Magpie.slnx -m -t:Rebuild -restore -p:RestorePackagesConfig=true;Configuration=Release;Platform={args.platform};DisablePDB=true;UseClangCL={args.compiler == "ClangCL"};UseNativeMicroArch={args.use_native_march};OutDir={os.getcwd()}\\publish\\{args.platform}\\;CommitId={commitId}{versionNumProps}{versionTagProp}' f'"{msbuildPath}" Magpie.slnx -m -t:Rebuild -restore -p:RestorePackagesConfig=true;Configuration=Release;Platform={args.platform};DisablePDB=true;UseClangCL={args.compiler == "ClangCL"};UseNativeMicroArch={args.use_native_march};OutDir={os.getcwd()}\\publish\\{args.platform}\\;CommitId={commitId}{versionNumProps}{versionStrProp}'
) )
if p.returncode != 0: if p.returncode != 0:
raise Exception("编译失败") raise Exception("编译失败")

View file

@ -14,12 +14,12 @@
<DebugInfoOnOverlay>false</DebugInfoOnOverlay> <DebugInfoOnOverlay>false</DebugInfoOnOverlay>
<!-- 使用 composition swapchain 呈现 --> <!-- 使用 composition swapchain 呈现 -->
<UseCompSwapchain>false</UseCompSwapchain> <UseCompSwapchain>false</UseCompSwapchain>
<CommitId></CommitId>
<MajorVersion></MajorVersion> <MajorVersion></MajorVersion>
<MinorVersion></MinorVersion> <MinorVersion></MinorVersion>
<PatchVersion></PatchVersion> <PatchVersion></PatchVersion>
<VersionTag></VersionTag> <VersionString></VersionString>
<CommitId></CommitId>
</PropertyGroup> </PropertyGroup>
<!-- 用户自定义编译选项 --> <!-- 用户自定义编译选项 -->

View file

@ -6,9 +6,9 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile> <PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<PreprocessorDefinitions>_WINDOWS;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;WINRT_NO_MODULE_LOCK;WIL_SUPPRESS_EXCEPTIONS;WIL_USE_STL=1;NOGDICAPMASKS;NOICONS;NOATOM;NOCLIPBOARD;NODRAWTEXT;NOMEMMGR;NOMETAFILE;NOMINMAX;NOOPENFILE;NOSCROLL;NOSERVICE;NOSOUND;NOTEXTMETRIC;NOCOMM;NOKANJI;NOHELP;NOPROFILER;NOMCX;NO_SHLWAPI_PATH;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_WINDOWS;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;WINRT_NO_MODULE_LOCK;WIL_SUPPRESS_EXCEPTIONS;WIL_USE_STL=1;NOGDICAPMASKS;NOICONS;NOATOM;NOCLIPBOARD;NODRAWTEXT;NOMEMMGR;NOMETAFILE;NOMINMAX;NOOPENFILE;NOSCROLL;NOSERVICE;NOSOUND;NOTEXTMETRIC;NOCOMM;NOKANJI;NOHELP;NOPROFILER;NOMCX;NO_SHLWAPI_PATH;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>MP_MAJOR_VERSION=$(MajorVersion);MP_MINOR_VERSION=$(MinorVersion);MP_PATCH_VERSION=$(PatchVersion);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(VersionString)' != ''">MP_VERSION_STRING=$(VersionString);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(CommitId)' != ''">MP_COMMIT_ID=$(CommitId);%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions Condition="'$(CommitId)' != ''">MP_COMMIT_ID=$(CommitId);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(MajorVersion)' != '' And '$(MinorVersion)' != '' And '$(PatchVersion)' != ''">MP_MAJOR_VERSION=$(MajorVersion);MP_MINOR_VERSION=$(MinorVersion);MP_PATCH_VERSION=$(PatchVersion);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(VersionTag)' != ''">MP_VERSION_TAG=$(VersionTag);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="$(DebugBorder)">MP_DEBUG_BORDER;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions Condition="$(DebugBorder)">MP_DEBUG_BORDER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="$(DebugInfoOnOverlay)">MP_DEBUG_INFO_ON_OVERLAY;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions Condition="$(DebugInfoOnOverlay)">MP_DEBUG_INFO_ON_OVERLAY;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="$(UseCompSwapchain)">MP_USE_COMPSWAPCHAIN;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions Condition="$(UseCompSwapchain)">MP_USE_COMPSWAPCHAIN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -29,6 +29,12 @@
<!-- 修复编译 Shared 中源文件找不到 pch.h 的问题 --> <!-- 修复编译 Shared 中源文件找不到 pch.h 的问题 -->
<AdditionalIncludeDirectories Condition="$(UseClangCL)">.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories Condition="$(UseClangCL)">.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>MP_MAJOR_VERSION=$(MajorVersion);MP_MINOR_VERSION=$(MinorVersion);MP_PATCH_VERSION=$(PatchVersion);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(VersionString)' != ''">MP_VERSION_STRING=$(VersionString);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(CommitId)' != ''">MP_COMMIT_ID=$(CommitId);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)\Shared;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link> <Link>
<GenerateDebugInformation Condition="'$(DisablePDB)' == 'true'">false</GenerateDebugInformation> <GenerateDebugInformation Condition="'$(DisablePDB)' == 'true'">false</GenerateDebugInformation>
</Link> </Link>
@ -38,6 +44,9 @@
<ClCompile> <ClCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)' == 'Release'"> <ItemDefinitionGroup Condition="'$(Configuration)' == 'Release'">
<ClCompile> <ClCompile>

View file

@ -24,6 +24,11 @@
<PropertyGroup> <PropertyGroup>
<DefaultLanguage>en-US</DefaultLanguage> <DefaultLanguage>en-US</DefaultLanguage>
<MajorVersion Condition="'$(MajorVersion)' == ''">0</MajorVersion>
<MinorVersion Condition="'$(MinorVersion)' == ''">0</MinorVersion>
<PatchVersion Condition="'$(PatchVersion)' == ''">0</PatchVersion>
<!-- 可通过 VersionString 区分开发版本和发布版本 -->
<VersionString Condition="'$(VersionString)' == '' And ('$(MajorVersion)' != '0' Or '$(MinorVersion)' != '0' Or '$(PatchVersion)' != '0')">$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionString>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Label="Configuration"> <PropertyGroup Label="Configuration">

View file

@ -52,8 +52,10 @@ static void LogRects(const RECT& srcRect, const RECT& rendererRect, const RECT&
ScalingError ScalingWindow::_StartImpl(HWND hwndSrc) noexcept { ScalingError ScalingWindow::_StartImpl(HWND hwndSrc) noexcept {
Logger::Get().Info(fmt::format("缩放开始\n\t程序版本: {}\n\tOS 版本: {}\n\t管理员: {}", Logger::Get().Info(fmt::format("缩放开始\n\t程序版本: {}\n\tOS 版本: {}\n\t管理员: {}",
#ifdef MP_VERSION_TAG #ifdef MP_VERSION_STRING
STRING(MP_VERSION_TAG), STRINGIFY(MP_VERSION_STRING),
#elif defined(MP_COMMIT_ID)
"dev (" STRINGIFY(MP_COMMIT_ID) ")",
#else #else
"dev", "dev",
#endif #endif

View file

@ -58,16 +58,15 @@ hstring AboutViewModel::Version() const noexcept {
ResourceLoader::GetForCurrentView(CommonSharedConstants::APP_RESOURCE_MAP_ID); ResourceLoader::GetForCurrentView(CommonSharedConstants::APP_RESOURCE_MAP_ID);
return hstring(StrHelper::Concat( return hstring(StrHelper::Concat(
resourceLoader.GetString(L"About_Version_Version"), resourceLoader.GetString(L"About_Version_Version"),
#ifdef MP_VERSION_TAG #ifdef MP_VERSION_STRING
L" ", L" " WIDEN_STRINGIFY(MP_VERSION_STRING),
&WIDEN(STRING(MP_VERSION_TAG))[1],
#else #else
L" dev", L" dev",
#endif #endif
#ifdef MP_COMMIT_ID #ifdef MP_COMMIT_ID
L" | ", L" | ",
resourceLoader.GetString(L"About_Version_CommitId"), resourceLoader.GetString(L"About_Version_CommitId"),
L" " WIDEN(STRING(MP_COMMIT_ID)), L" " WIDEN_STRINGIFY(MP_COMMIT_ID),
#endif #endif
L" | " L" | "
#ifdef _M_X64 #ifdef _M_X64
@ -103,7 +102,7 @@ void AboutViewModel::IsCheckForPreviewUpdates(bool value) {
bool AboutViewModel::IsCheckForUpdatesButtonEnabled() const noexcept { bool AboutViewModel::IsCheckForUpdatesButtonEnabled() const noexcept {
// 只有发布版本能检查更新 // 只有发布版本能检查更新
#ifdef MP_VERSION_TAG #ifdef MP_VERSION_STRING
return !IsCheckingForUpdates() && !IsDownloadingOrLater(); return !IsCheckingForUpdates() && !IsDownloadingOrLater();
#else #else
return false; return false;

View file

@ -1,24 +1,11 @@
// Microsoft Visual C++ generated resource script.
//
#pragma code_page(65001) #pragma code_page(65001)
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h" #include "winres.h"
#include "resource.h"
#include "StrMacros.h"
///////////////////////////////////////////////////////////////////////////// // en-US
#undef APSTUDIO_READONLY_SYMBOLS LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
/////////////////////////////////////////////////////////////////////////////
// 非特定语言 resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -29,54 +16,46 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
// remains consistent on all systems. // remains consistent on all systems.
IDI_APP ICON "Magpie.ico" IDI_APP ICON "Magpie.ico"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Version // Version
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,0 FILEVERSION MP_MAJOR_VERSION, MP_MINOR_VERSION, MP_PATCH_VERSION, 0
PRODUCTVERSION 0,0,0,0 PRODUCTVERSION MP_MAJOR_VERSION, MP_MINOR_VERSION, MP_PATCH_VERSION, 0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS VS_FF_DEBUG
#else #else
FILEFLAGS 0x0L FILEFLAGS 0x0L
#endif #endif
FILEOS 0x40004L FILEOS VOS_NT_WINDOWS32
FILETYPE 0x1L FILETYPE VFT_APP
FILESUBTYPE 0x0L FILESUBTYPE VFT2_UNKNOWN
BEGIN BEGIN
BLOCK "StringFileInfo" BLOCK "StringFileInfo"
BEGIN BEGIN
BLOCK "000004b0" BLOCK "040904b0"
BEGIN BEGIN
VALUE "FileVersion", "0.0.0.0" #ifdef MP_VERSION_STRING
VALUE "FileVersion", STRINGIFY(MP_VERSION_STRING)
VALUE "ProductVersion", STRINGIFY(MP_VERSION_STRING)
#elif defined(MP_COMMIT_ID)
VALUE "FileVersion", "dev (" STRINGIFY(MP_COMMIT_ID) ")"
VALUE "ProductVersion", "dev (" STRINGIFY(MP_COMMIT_ID) ")"
#else
VALUE "FileVersion", "dev"
VALUE "ProductVersion", "dev"
#endif
VALUE "InternalName", "Magpie.exe" VALUE "InternalName", "Magpie.exe"
VALUE "LegalCopyright", "Copyright (C) 2023 Liu Xu" VALUE "LegalCopyright", "Copyright © 2021-2025 Xu"
VALUE "OriginalFilename", "Magpie.exe" VALUE "OriginalFilename", "Magpie.exe"
VALUE "ProductName", "Magpie" VALUE "ProductName", "Magpie"
VALUE "ProductVersion", "0.0.0.0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
BEGIN BEGIN
VALUE "Translation", 0x0, 1200 VALUE "Translation", 0x409, 1200
END END
END END
#endif // 非特定语言 resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -25,19 +25,13 @@ using namespace Windows::Web::Http;
namespace Magpie { namespace Magpie {
static constexpr Version MAGPIE_VERSION( static constexpr Version MAGPIE_VERSION(MP_MAJOR_VERSION, MP_MINOR_VERSION, MP_PATCH_VERSION);
#ifdef MP_MAJOR_VERSION
MP_MAJOR_VERSION, MP_MINOR_VERSION, MP_PATCH_VERSION
#else
0, 0, 0
#endif
);
static constexpr uint32_t MD5_HASH_LENGTH = 16; static constexpr uint32_t MD5_HASH_LENGTH = 16;
void UpdateService::Initialize() noexcept { void UpdateService::Initialize() noexcept {
// 只有发布版本能检查更新 // 只有发布版本能检查更新
#ifdef MP_VERSION_TAG #ifdef MP_VERSION_STRING
AppSettings& settings = AppSettings::Get(); AppSettings& settings = AppSettings::Get();
if (settings.IsAutoCheckForUpdates()) { if (settings.IsAutoCheckForUpdates()) {
_StartTimer(); _StartTimer();

View file

@ -74,8 +74,10 @@ int APIENTRY wWinMain(
CommonSharedConstants::REGISTER_TOUCH_HELPER_LOG_PATH); CommonSharedConstants::REGISTER_TOUCH_HELPER_LOG_PATH);
Logger::Get().Info(fmt::format("程序启动\n\t版本: {}\n\tOS 版本: {}\n\t管理员: {}", Logger::Get().Info(fmt::format("程序启动\n\t版本: {}\n\tOS 版本: {}\n\t管理员: {}",
#ifdef MP_VERSION_TAG #ifdef MP_VERSION_STRING
STRING(MP_VERSION_TAG), STRINGIFY(MP_VERSION_STRING),
#elif defined(MP_COMMIT_ID)
"dev (" STRINGIFY(MP_COMMIT_ID) ")",
#else #else
"dev", "dev",
#endif #endif

View file

@ -1,16 +1,3 @@
//{{NO_DEPENDENCIES}} #pragma once
// Microsoft Visual C++ 生成的包含文件。
// 供 Magpie.rc 使用
//
#define IDI_APP 101
// Next default values for new objects #define IDI_APP 101
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -1,4 +1,5 @@
#pragma once #pragma once
#include "StrMacros.h"
using namespace std::string_literals; using namespace std::string_literals;
using namespace std::string_view_literals; using namespace std::string_view_literals;
@ -14,11 +15,6 @@ using winrt::operator co_await;
bool Name() const noexcept { return WI_IsFlagSet(FlagsVar, FlagBit); } \ bool Name() const noexcept { return WI_IsFlagSet(FlagsVar, FlagBit); } \
void Name(bool value) noexcept { WI_UpdateFlag(FlagsVar, FlagBit, value); } void Name(bool value) noexcept { WI_UpdateFlag(FlagsVar, FlagBit, value); }
#define _WIDEN_HELPER(x) L ## x
#define WIDEN(x) _WIDEN_HELPER(x)
#define _STRING_HELPER(x) #x
#define STRING(x) _STRING_HELPER(x)
#define SWP_NO_ACTIVATE_MOVE_SIZE (SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE) #define SWP_NO_ACTIVATE_MOVE_SIZE (SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE)
struct Ignore { struct Ignore {

View file

@ -18,6 +18,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)Logger.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)Logger.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)SmallVector.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)SmallVector.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)StrHelper.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)StrHelper.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)StrMacros.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Version.h" /> <ClInclude Include="$(MSBuildThisFileDirectory)Version.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

7
src/Shared/StrMacros.h Normal file
View file

@ -0,0 +1,7 @@
// 供 C++ 和 RC 使用
#pragma once
#define _STRINGIFY_HELPER(x) #x
#define STRINGIFY(x) _STRINGIFY_HELPER(x)
#define _WIDEN_STRINGIFY_HELPER(x) L ## #x
#define WIDEN_STRINGIFY(x) _WIDEN_STRINGIFY_HELPER(x)

View file

@ -1,24 +1,10 @@
// Microsoft Visual C++ generated resource script.
//
#pragma code_page(65001) #pragma code_page(65001)
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h" #include "winres.h"
#include "StrMacros.h"
///////////////////////////////////////////////////////////////////////////// // en-US
#undef APSTUDIO_READONLY_SYMBOLS LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
/////////////////////////////////////////////////////////////////////////////
// 非特定语言 resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -26,88 +12,40 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,0 FILEVERSION MP_MAJOR_VERSION, MP_MINOR_VERSION, MP_PATCH_VERSION, 0
PRODUCTVERSION 0,0,0,0 PRODUCTVERSION MP_MAJOR_VERSION, MP_MINOR_VERSION, MP_PATCH_VERSION, 0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS VS_FF_DEBUG
#else #else
FILEFLAGS 0x0L FILEFLAGS 0x0L
#endif #endif
FILEOS 0x40004L FILEOS VOS_NT_WINDOWS32
FILETYPE 0x1L FILETYPE VFT_APP
FILESUBTYPE 0x0L FILESUBTYPE VFT2_UNKNOWN
BEGIN BEGIN
BLOCK "StringFileInfo" BLOCK "StringFileInfo"
BEGIN BEGIN
BLOCK "000004b0" BLOCK "040904b0"
BEGIN BEGIN
VALUE "FileVersion", "0.0.0.0" #ifdef MP_VERSION_STRING
VALUE "FileVersion", STRINGIFY(MP_VERSION_STRING)
VALUE "ProductVersion", STRINGIFY(MP_VERSION_STRING)
#elif defined(MP_COMMIT_ID)
VALUE "FileVersion", "dev (" STRINGIFY(MP_COMMIT_ID) ")"
VALUE "ProductVersion", "dev (" STRINGIFY(MP_COMMIT_ID) ")"
#else
VALUE "FileVersion", "dev"
VALUE "ProductVersion", "dev"
#endif
VALUE "InternalName", "TouchHelper.exe" VALUE "InternalName", "TouchHelper.exe"
VALUE "LegalCopyright", "Copyright (C) 2024 Liu Xu" VALUE "LegalCopyright", "Copyright © 2021-2025 Xu"
VALUE "OriginalFilename", "TouchHelper.exe" VALUE "OriginalFilename", "TouchHelper.exe"
VALUE "ProductName", "TouchHelpers" VALUE "ProductName", "Magpie"
VALUE "ProductVersion", "0.0.0.0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
BEGIN BEGIN
VALUE "Translation", 0x0, 1200 VALUE "Translation", 0x409, 1200
END END
END END
#endif // 非特定语言 resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// 非特定语言 resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#ifndef APSTUDIO_INVOKED\r\n"
"#include ""targetver.h""\r\n"
"#endif\r\n"
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // 非特定语言 resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -35,7 +35,6 @@
<ItemGroup> <ItemGroup>
<ClInclude Include="App.h" /> <ClInclude Include="App.h" />
<ClInclude Include="pch.h" /> <ClInclude Include="pch.h" />
<ClInclude Include="resource.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="App.cpp" /> <ClCompile Include="App.cpp" />

View file

@ -8,9 +8,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="pch.h" /> <ClInclude Include="pch.h" />
<ClInclude Include="resource.h">
<Filter>Resources</Filter>
</ClInclude>
<ClInclude Include="App.h" /> <ClInclude Include="App.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -1,16 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ 生成的包含文件。
// 供 TouchHelper.rc 使用
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif

View file

@ -1,24 +1,11 @@
// Microsoft Visual C++ generated resource script.
//
#pragma code_page(65001) #pragma code_page(65001)
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h" #include "winres.h"
#include "resource.h"
#include "StrMacros.h"
///////////////////////////////////////////////////////////////////////////// // en-US
#undef APSTUDIO_READONLY_SYMBOLS LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
/////////////////////////////////////////////////////////////////////////////
// 非特定语言 resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
@ -29,95 +16,46 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
// remains consistent on all systems. // remains consistent on all systems.
IDI_UPDATER ICON "Updater.ico" IDI_UPDATER ICON "Updater.ico"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Version // Version
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,0,0 FILEVERSION MP_MAJOR_VERSION, MP_MINOR_VERSION, MP_PATCH_VERSION, 0
PRODUCTVERSION 0,0,0,0 PRODUCTVERSION MP_MAJOR_VERSION, MP_MINOR_VERSION, MP_PATCH_VERSION, 0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS VS_FF_DEBUG
#else #else
FILEFLAGS 0x0L FILEFLAGS 0x0L
#endif #endif
FILEOS 0x40004L FILEOS VOS_NT_WINDOWS32
FILETYPE 0x1L FILETYPE VFT_APP
FILESUBTYPE 0x0L FILESUBTYPE VFT2_UNKNOWN
BEGIN BEGIN
BLOCK "StringFileInfo" BLOCK "StringFileInfo"
BEGIN BEGIN
BLOCK "000004b0" BLOCK "040904b0"
BEGIN BEGIN
VALUE "FileVersion", "0.0.0.0" #ifdef MP_VERSION_STRING
VALUE "FileVersion", STRINGIFY(MP_VERSION_STRING)
VALUE "ProductVersion", STRINGIFY(MP_VERSION_STRING)
#elif defined(MP_COMMIT_ID)
VALUE "FileVersion", "dev (" STRINGIFY(MP_COMMIT_ID) ")"
VALUE "ProductVersion", "dev (" STRINGIFY(MP_COMMIT_ID) ")"
#else
VALUE "FileVersion", "dev"
VALUE "ProductVersion", "dev"
#endif
VALUE "InternalName", "Updater.exe" VALUE "InternalName", "Updater.exe"
VALUE "LegalCopyright", "Copyright (C) 2024 Liu Xu" VALUE "LegalCopyright", "Copyright © 2021-2025 Xu"
VALUE "OriginalFilename", "Updater.exe" VALUE "OriginalFilename", "Updater.exe"
VALUE "ProductName", "Magpie" VALUE "ProductName", "Magpie"
VALUE "ProductVersion", "0.0.0.0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
BEGIN BEGIN
VALUE "Translation", 0x0, 1200 VALUE "Translation", 0x409, 1200
END END
END END
#endif // 非特定语言 resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// 非特定语言 resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#ifndef APSTUDIO_INVOKED\r\n"
"#include ""targetver.h""\r\n"
"#endif\r\n"
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // 非特定语言 resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View file

@ -1,17 +1,3 @@
//{{NO_DEPENDENCIES}} #pragma once
// Microsoft Visual C++ 生成的包含文件。
// 供 Updater.rc 使用
//
#define IDI_UPDATER 101
// Next default values for new objects #define IDI_UPDATER 101
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif