Initial dstalk project: core DLL + CLI + BearSSL TLS

- Core DLL: AI API client (DeepSeek/OpenAI compatible), HTTP(S) via Boost.Beast
- BearSSL vendored as TLS backend (MIT license, replacing OpenSSL)
- CLI frontend with ANSI colors, /help /model /file /save /load commands
- WinHTTP alternative HTTP client for Windows
- GPLv3 license with linking exception
- Build: CMake + Ninja + Clang, dependencies via Conan2

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 16:42:42 +08:00
parent f74ead4d73
commit c9fb924a1c
327 changed files with 80579 additions and 2 deletions

107
build.bat Normal file
View File

@@ -0,0 +1,107 @@
@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion
set "ROOT=%~dp0"
set "TOOLS=%ROOT%tools\"
:: ============================================================
:: 1. 检查 tools\ 工具链
:: ============================================================
echo [dstalk] 检查工具链...
if not exist "%TOOLS%cmake\bin\cmake.exe" (
echo [ERROR] CMake 未找到,请先运行: tools\setup.bat
pause & exit /b 1
)
if not exist "%TOOLS%ninja\ninja.exe" (
echo [ERROR] Ninja 未找到,请先运行: tools\setup.bat
pause & exit /b 1
)
if not exist "%TOOLS%llvm\bin\clang.exe" (
echo [ERROR] LLVM/Clang 未找到,请先运行: tools\setup.bat
pause & exit /b 1
)
if not exist "%TOOLS%conan2\conan.exe" (
echo [ERROR] Conan2 未找到,请先运行: tools\setup.bat
pause & exit /b 1
)
:: ============================================================
:: 2. 加载 tools\ 环境
:: ============================================================
call "%TOOLS%env.bat"
:: ============================================================
:: 3. 检测并加载 MSVC 环境
:: ============================================================
set "VCVARS="
for %%v in (2022 2019 2017) do (
for %%e in (Professional Community Enterprise BuildTools) do (
if exist "C:\Program Files (x86)\Microsoft Visual Studio\%%v\%%e\VC\Auxiliary\Build\vcvarsall.bat" (
set "VCVARS=C:\Program Files (x86)\Microsoft Visual Studio\%%v\%%e\VC\Auxiliary\Build\vcvarsall.bat"
)
if exist "C:\Program Files\Microsoft Visual Studio\%%v\%%e\VC\Auxiliary\Build\vcvarsall.bat" (
set "VCVARS=C:\Program Files\Microsoft Visual Studio\%%v\%%e\VC\Auxiliary\Build\vcvarsall.bat"
)
)
)
if "%VCVARS%"=="" (
echo [ERROR] 未找到 Visual Studio Build Tools
echo 请安装: https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022
pause & exit /b 1
)
echo [dstalk] 加载 MSVC 环境...
call "%VCVARS%" x64 >nul 2>&1
:: ============================================================
:: 4. 强制使用 tools\ 内的编译器 (覆盖 MSVC 的 cl.exe)
:: ============================================================
set "CC=%TOOLS%llvm\bin\clang.exe"
set "CXX=%TOOLS%llvm\bin\clang++.exe"
cd /d "%ROOT%"
:: ============================================================
:: 5. Conan 安装依赖
:: ============================================================
if not exist "%ROOT%build\conan_toolchain.cmake" (
echo [dstalk] Conan 安装依赖...
call "%TOOLS%conan2\conan.exe" install deps/ -of build --build=missing
if !errorlevel! neq 0 (
echo [ERROR] Conan 安装失败
pause & exit /b 1
)
) else (
echo [dstalk] Conan 依赖已就绪
)
:: ============================================================
:: 6. CMake 配置 + Ninja 编译
:: ============================================================
echo [dstalk] CMake 配置 + 编译...
"%TOOLS%cmake\bin\cmake.exe" -S "%ROOT%" -B "%ROOT%build" -G Ninja ^
-DCMAKE_C_COMPILER="%TOOLS%llvm\bin\clang.exe" ^
-DCMAKE_CXX_COMPILER="%TOOLS%llvm\bin\clang++.exe" ^
-DCMAKE_TOOLCHAIN_FILE="%ROOT%build\conan_toolchain.cmake" ^
-DCMAKE_BUILD_TYPE=Release
if !errorlevel! neq 0 (
echo [ERROR] CMake 配置失败
pause & exit /b 1
)
"%TOOLS%cmake\bin\cmake.exe" --build "%ROOT%build"
if !errorlevel! neq 0 (
echo [ERROR] 编译失败
pause & exit /b 1
)
echo.
echo ============================================
echo 编译成功!
echo build\dstalk-core\dstalk.dll
echo build\dstalk-cli\dstalk-cli.exe
echo build\dstalk-gui\dstalk-gui.exe
echo ============================================
pause