From f4943b8eee7cfa3409576a84daa4502e9bc1307c Mon Sep 17 00:00:00 2001 From: Changhua Date: Sun, 26 Jan 2025 19:44:40 +0800 Subject: [PATCH] Add license check for compiling --- WeChatFerry/DISCLAIMER.md | 18 ++++++++++++++ WeChatFerry/license_check.bat | 44 +++++++++++++++++++++++++++++++++++ WeChatFerry/spy/Spy.vcxproj | 12 +++++++--- 3 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 WeChatFerry/DISCLAIMER.md create mode 100644 WeChatFerry/license_check.bat diff --git a/WeChatFerry/DISCLAIMER.md b/WeChatFerry/DISCLAIMER.md new file mode 100644 index 0000000..520a4ac --- /dev/null +++ b/WeChatFerry/DISCLAIMER.md @@ -0,0 +1,18 @@ +# 免责声明 + +1. **本工具为开源项目,仅提供基础功能,供用户进行合法的学习、研究和非商业用途**。禁止将本工具用于任何违法或侵权行为。 + +2. **二次开发者的责任**: + - 任何基于本工具进行的二次开发、修改或衍生产品,其行为及后果由二次开发者独立承担,与本工具贡献者无关。 + - **禁止使用贡献者的姓名、项目名称或相关信息作为二次开发产品的背书或推广手段**。 + - 建议二次开发者在其衍生产品中添加自己的免责声明,明确责任归属。 + +3. **用户责任**: + - 使用本工具或其衍生产品的所有后果由用户自行承担。原贡献者不对因直接或间接使用本工具而导致的任何损失、责任或争议负责。 + +4. **法律约束**: + - 用户和二次开发者须遵守《中华人民共和国网络安全法》、《中华人民共和国著作权法》等相关法律法规。 + - 本工具涉及的所有第三方商标或产品名称,其权利归权利人所有,作者与第三方无任何直接或间接关联。 + +5. **作者保留权利**: + - 本工具作者保留随时修改、更新、删除或终止本工具的权利,无需事先通知或承担任何义务。 diff --git a/WeChatFerry/license_check.bat b/WeChatFerry/license_check.bat new file mode 100644 index 0000000..f097f04 --- /dev/null +++ b/WeChatFerry/license_check.bat @@ -0,0 +1,44 @@ +@echo off +chcp 65001 > nul +cd /d %~dp0 + +if "%CI%" == "true" ( + echo 自动化编译环境,跳过手动确认。 + echo 用户已接受开源协议 > license_accepted.flag + exit /b 0 +) + +:: 检查是否已接受协议 +if exist ".license_accepted.flag" ( + echo 用户已接受免责声明 + exit /b 0 +) + +:: 检查免责声明文件是否存在 +if not exist "DISCLAIMER.md" ( + echo 错误:未找到免责声明文件 DISCLAIMER.md。 + exit /b 1 +) + +:: 生成临时文件并读取免责声明 +type "DISCLAIMER.md" > temp_disclaimer.txt + +:: 使用 PowerShell 显示弹窗 +powershell -NoProfile -Command ^ + "$text = Get-Content -Raw -Path 'temp_disclaimer.txt';" ^ + "Add-Type -AssemblyName PresentationFramework;" ^ + "$result = [System.Windows.MessageBox]::Show($text, '免责声明', 'OKCancel', 'Warning');" ^ + "if ($result -ne 'OK') { exit 1 }" + +:: 检查 PowerShell 执行结果 +if %errorlevel% neq 0 ( + echo 错误:用户未接受免责声明。停止生成。 + del temp_disclaimer.txt + exit /b 1 +) + +:: 用户接受免责声明,创建标志文件 +echo 用户已接受免责声明 > .license_accepted.flag +del temp_disclaimer.txt +echo 用户已接受免责声明 +exit /b 0 diff --git a/WeChatFerry/spy/Spy.vcxproj b/WeChatFerry/spy/Spy.vcxproj index 17b983b..6855ffb 100644 --- a/WeChatFerry/spy/Spy.vcxproj +++ b/WeChatFerry/spy/Spy.vcxproj @@ -112,7 +112,9 @@ true - cd $(SolutionDir)rpc\proto + call "$(SolutionDir)license_check.bat" +if errorlevel 1 exit 1 +cd $(SolutionDir)rpc\proto $(SolutionDir)rpc\tool\protoc --nanopb_out=. wcf.proto @@ -161,7 +163,9 @@ xcopy /y $(OutDir)$(TargetFileName) $(SolutionDir)..\clients\python\wcferrytrue - cd $(SolutionDir)rpc\proto + call "$(SolutionDir)license_check.bat" +if errorlevel 1 exit 1 +cd $(SolutionDir)rpc\proto $(SolutionDir)rpc\tool\protoc --nanopb_out=. wcf.proto @@ -211,7 +215,9 @@ xcopy /y $(OutDir)$(TargetFileName) $(SolutionDir)..\clients\python\wcferry Generating PB files - cd $(SolutionDir)rpc\proto + call "$(SolutionDir)license_check.bat" +if errorlevel 1 exit 1 +cd $(SolutionDir)rpc\proto $(SolutionDir)rpc\tool\protoc --nanopb_out=. wcf.proto