SlideCombine/build_simple.bat
yuuko e8fe5026de Add simplified build script for C compilation
创建简化的C语言编译脚本:
- 移除复杂的路径检测逻辑
- 使用简单的if-goto结构
- 支持GCC和MSVC两种编译器
- 自动创建发布包和使用说明
- 避免批处理脚本的语法问题

运行方法:build_simple.bat

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 13:31:08 +08:00

149 lines
3.9 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
title PDF书签合并工具 - C语言版编译
echo ==========================================
echo PDF书签合并工具 - C语言版编译脚本
echo ==========================================
echo.
echo 检查源文件...
if not exist "slide_combine_core.c" goto :missing_file
if not exist "slide_combine_merger.c" goto :missing_file
if not exist "slide_combine_gui.c" goto :missing_file
if not exist "slide_combine_c.h" goto :missing_file
echo 所有源文件检查通过
echo.
echo 检查编译器...
gcc --version >nul 2>&1
if %errorlevel% equ 0 (
echo 找到GCC编译器
goto :compile_gcc
)
echo 尝试查找MinGW...
if exist "C:\msys64\mingw64\bin\gcc.exe" (
set PATH=C:\msys64\mingw64\bin;%PATH%
echo 找到MSYS2 MinGW64
goto :compile_gcc
)
if exist "C:\mingw64\bin\gcc.exe" (
set PATH=C:\mingw64\bin;%PATH%
echo 找到MinGW64
goto :compile_gcc
)
echo 尝试使用Visual Studio编译器...
cl 2>nul
if %errorlevel% equ 0 (
echo 找到Visual Studio编译器
goto :compile_msvc
)
echo 错误:未找到编译器
echo 请安装MinGW-w64或Visual Studio
pause
exit /b 1
:missing_file
echo 错误:缺少必要的源文件
pause
exit /b 1
:compile_gcc
echo 使用GCC编译...
echo 清理旧文件...
if exist "slide_combine.exe" del "slide_combine.exe"
echo 编译中...
gcc -O2 -mwindows -static ^
slide_combine_core.c slide_combine_merger.c slide_combine_gui.c ^
-o slide_combine.exe ^
-luser32 -lgdi32 -lcomctl32 -lshlwapi -lole32
if %errorlevel% equ 0 (
echo 编译成功!
goto :package
) else (
echo GCC编译失败尝试MSVC...
goto :compile_msvc
)
:compile_msvc
echo 使用MSVC编译...
echo 清理旧文件...
if exist "slide_combine.exe" del "slide_combine.exe"
echo 编译中...
cl /EHsc /O2 ^
slide_combine_core.c slide_combine_merger.c slide_combine_gui.c ^
/link user32.lib gdi32.lib comctl32.lib shlwapi.lib ole32.lib
if %errorlevel% equ 0 (
echo 编译成功!
goto :package
) else (
echo 编译失败!
pause
exit /b 1
)
:package
if not exist "slide_combine.exe" (
echo 错误:未找到编译输出文件
pause
exit /b 1
)
echo.
echo 创建发布包...
for %%F in ("slide_combine.exe") do set SIZE=%%~zF
set /a SIZE_KB=%SIZE% / 1024
echo 文件大小:%SIZE_KB% KB
set PACKAGE_NAME=SlideCombine_C_v2_0_0
if exist "%PACKAGE_NAME%" rd /s /q "%PACKAGE_NAME%"
mkdir "%PACKAGE_NAME%"
copy "slide_combine.exe" "%PACKAGE_NAME%\" >nul
echo 创建使用说明...
echo PDF书签合并工具 v2.0.0 - C语言版 > "%PACKAGE_NAME%\使用说明.txt"
echo ================================ >> "%PACKAGE_NAME%\使用说明.txt"
echo. >> "%PACKAGE_NAME%\使用说明.txt"
echo 特点: >> "%PACKAGE_NAME%\使用说明.txt"
echo - 零依赖纯C语言Win32无需任何运行时 >> "%PACKAGE_NAME%\使用说明.txt"
echo - 体积小:编译后约 %SIZE_KB% KB >> "%PACKAGE_NAME%\使用说明.txt"
echo - 性能高:直接编译为机器码 >> "%PACKAGE_NAME%\使用说明.txt"
echo - 兼容强Windows 7-11 完全支持 >> "%PACKAGE_NAME%\使用说明.txt"
echo - 绿色软件:复制即用,无任何安装 >> "%PACKAGE_NAME%\使用说明.txt"
echo. >> "%PACKAGE_NAME%\使用说明.txt"
echo 使用方法: >> "%PACKAGE_NAME%\使用说明.txt"
echo 1. 双击运行 slide_combine.exe >> "%PACKAGE_NAME%\使用说明.txt"
echo 2. 选择三个路径并处理 >> "%PACKAGE_NAME%\使用说明.txt"
echo 创建启动脚本...
echo @echo off > "%PACKAGE_NAME%\启动.bat"
echo echo 启动PDF书签合并工具... >> "%PACKAGE_NAME%\启动.bat"
echo start "" "slide_combine.exe" >> "%PACKAGE_NAME%\启动.bat"
echo.
echo ==========================================
echo 编译完成
echo ==========================================
echo 发布包:%PACKAGE_NAME%
echo 文件大小:%SIZE_KB% KB
echo.
echo 是否打开文件夹Y/N
set /p choice=
if /i "%choice%"=="Y" start "" "%PACKAGE_NAME%"
echo.
echo 编译完成!按任意键退出...
pause >nul