Update Conan setup to use Python venv.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -20,7 +20,7 @@ deps/.conan/
|
||||
tools/cmake/
|
||||
tools/ninja/
|
||||
tools/llvm/
|
||||
tools/conan2/
|
||||
tools/.venv/
|
||||
|
||||
# IDE
|
||||
.vs/
|
||||
|
||||
10
README.md
10
README.md
@@ -77,16 +77,16 @@ AI 编程助手需要长期驻留、频繁交互,性能特征值得用系统
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1. 安装工具链(全自动,存入 tools\,不依赖系统环境)
|
||||
### 1. 安装工具链(全自动,存入 tools\,需系统已安装 Python 3.10+)
|
||||
|
||||
```bash
|
||||
cd tools
|
||||
setup.bat # 下载 CMake + Ninja + LLVM/Clang + Conan2 到当前目录
|
||||
setup.bat # 下载 CMake + Ninja + LLVM/Clang,并在 tools/.venv 安装 Conan2
|
||||
```
|
||||
|
||||
> 网络不畅时可手动下载放入对应目录:[Conan2](https://conan.org.cn/downloads) | [Ninja](https://github.com/ninja-build/ninja/releases) | [CMake](https://cmake.org/download/) | [LLVM](https://github.com/llvm/llvm-project/releases)
|
||||
> 网络不畅时可手动下载放入对应目录:[Ninja](https://github.com/ninja-build/ninja/releases) | [CMake](https://cmake.org/download/) | [LLVM](https://github.com/llvm/llvm-project/releases)
|
||||
>
|
||||
> 目录结构要求: `tools/cmake/bin/cmake.exe` / `tools/ninja/ninja.exe` / `tools/llvm/bin/clang.exe` / `tools/conan2/conan.exe`
|
||||
> 目录结构要求: `tools/cmake/bin/cmake.exe` / `tools/ninja/ninja.exe` / `tools/llvm/bin/clang.exe` / `tools/.venv/Scripts/conan.exe`
|
||||
|
||||
### 2. 编译
|
||||
|
||||
@@ -301,7 +301,7 @@ model = "deepseek-v4"
|
||||
|------|------|
|
||||
| C++ 开发效率低于脚本语言 | Boost 库弥补;核心 API 稳定后开发速度不会慢于竞品 |
|
||||
| OpenSSL 跨版本兼容性 | Conan2 锁定版本,消除环境差异 |
|
||||
| SDL3 仍在迭代 | 锁定具体版本 (3.2.10),升级前充分测试 |
|
||||
| SDL3 仍在迭代 | 锁定具体版本 (3.2.14),升级前充分测试 |
|
||||
| AI API 协议变更 | 适配层独立模块,变更时只改一处 |
|
||||
|
||||
---
|
||||
|
||||
18
build.bat
18
build.bat
@@ -22,8 +22,9 @@ 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" (
|
||||
if not exist "%TOOLS%.venv\Scripts\conan.exe" (
|
||||
echo [ERROR] Conan2 未找到,请先运行: tools\setup.bat
|
||||
echo 需要已安装 Python 3.10+
|
||||
pause & exit /b 1
|
||||
)
|
||||
|
||||
@@ -66,17 +67,15 @@ 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 [dstalk] Conan 安装/刷新依赖...
|
||||
call "%TOOLS%.venv\Scripts\conan.exe" install deps/ -of build --build=missing -s compiler.cppstd=20 -c tools.cmake.cmaketoolchain:generator=Ninja
|
||||
if !errorlevel! neq 0 (
|
||||
echo [ERROR] Conan 安装失败
|
||||
pause & exit /b 1
|
||||
)
|
||||
) else (
|
||||
echo [dstalk] Conan 依赖已就绪
|
||||
)
|
||||
|
||||
set "CONAN_GENERATORS=%ROOT%build\build\Release\generators"
|
||||
|
||||
:: ============================================================
|
||||
:: 6. CMake 配置 + Ninja 编译
|
||||
:: ============================================================
|
||||
@@ -84,7 +83,8 @@ 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_TOOLCHAIN_FILE="%CONAN_GENERATORS%\conan_toolchain.cmake" ^
|
||||
-DCMAKE_PREFIX_PATH="%CONAN_GENERATORS%" ^
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
if !errorlevel! neq 0 (
|
||||
echo [ERROR] CMake 配置失败
|
||||
|
||||
2
deps/conanfile.txt
vendored
2
deps/conanfile.txt
vendored
@@ -1,7 +1,7 @@
|
||||
[requires]
|
||||
boost/1.86.0
|
||||
openssl/3.4.1
|
||||
sdl/3.2.10
|
||||
sdl/3.2.14
|
||||
|
||||
[generators]
|
||||
CMakeDeps
|
||||
|
||||
@@ -10,6 +10,6 @@ if exist "%TOOLS%ninja" set "PATH=%TOOLS%ninja;%PATH%"
|
||||
if exist "%TOOLS%llvm\bin" set "PATH=%TOOLS%llvm\bin;%PATH%"
|
||||
if exist "%TOOLS%llvm\bin\clang.exe" set "CC=%TOOLS%llvm\bin\clang.exe"
|
||||
if exist "%TOOLS%llvm\bin\clang++.exe" set "CXX=%TOOLS%llvm\bin\clang++.exe"
|
||||
if exist "%TOOLS%conan2" set "PATH=%TOOLS%conan2;%PATH%"
|
||||
if exist "%TOOLS%.venv\Scripts" set "PATH=%TOOLS%.venv\Scripts;%PATH%"
|
||||
|
||||
echo [dstalk] tools\ 工具链已加载
|
||||
|
||||
@@ -105,28 +105,52 @@ if exist "%TOOLS%llvm\bin\clang.exe" (
|
||||
)
|
||||
|
||||
:: ============================================================
|
||||
:: 4. Conan2 (独立安装器)
|
||||
:: 4. Python venv + Conan2
|
||||
:: ============================================================
|
||||
echo [4/5] Conan2 ...
|
||||
if exist "%TOOLS%conan2\conan.exe" (
|
||||
echo [OK] 已存在
|
||||
) else (
|
||||
mkdir "%TOOLS%conan2" 2>nul
|
||||
curl -L -o "%TOOLS%conan2\conan-installer.exe" "https://github.com/conan-io/conan/releases/latest/download/conan-2-win-64.exe" 2>nul
|
||||
if !errorlevel! neq 0 (
|
||||
echo [FAIL] 请手动下载: https://conan.org.cn/downloads
|
||||
) else (
|
||||
"%TOOLS%conan2\conan-installer.exe" /S /D="%TOOLS%conan2"
|
||||
del "%TOOLS%conan2\conan-installer.exe" 2>nul
|
||||
echo [OK] Conan2
|
||||
echo [4/5] Python venv + Conan2 ...
|
||||
set "PYTHON="
|
||||
for %%p in (python python3) do (
|
||||
if not defined PYTHON (
|
||||
where %%p >nul 2>nul
|
||||
if !errorlevel! equ 0 set "PYTHON=%%p"
|
||||
)
|
||||
)
|
||||
if not defined PYTHON (
|
||||
echo [FAIL] 未找到 Python 3.10+
|
||||
echo 请先安装 Python,并确保 python.exe 在 PATH 中
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if not exist "%TOOLS%.venv\Scripts\python.exe" (
|
||||
call %PYTHON% -m venv "%TOOLS%.venv"
|
||||
if !errorlevel! neq 0 (
|
||||
echo [FAIL] 创建 Python venv 失败
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
call "%TOOLS%.venv\Scripts\python.exe" -m pip install --upgrade pip
|
||||
if !errorlevel! neq 0 (
|
||||
echo [FAIL] pip 更新失败
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
call "%TOOLS%.venv\Scripts\python.exe" -m pip install "conan>=2,<3"
|
||||
if !errorlevel! neq 0 (
|
||||
echo [FAIL] Conan2 安装失败
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo [OK] Conan2
|
||||
|
||||
:: ============================================================
|
||||
:: 5. 配置 Conan profile
|
||||
:: ============================================================
|
||||
echo [5/5] 配置 Conan ...
|
||||
call "%TOOLS%conan2\conan.exe" profile detect --force 2>nul
|
||||
call "%TOOLS%.venv\Scripts\conan.exe" profile detect --force 2>nul
|
||||
if errorlevel 1 (
|
||||
echo [WARN] Conan profile 配置失败 (可能首次运行需手动配置)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user