W17: extract ai_common shared module + fix anthropic data race + brace bugs
- New plugins_upper/ai_common/ static library: shared PluginConfig, ToolCallAccum, StreamContext, secure_zero, extract_host_port, serialize_tool_calls, free_chat_result - Refactored openai/anthropic plugins to use dstalk_ai:: namespace from ai_common - Fixed anthropic g_config raw pointer → std::atomic (data race) - Added SSE parse error counter with threshold abort (kMaxSseParseErrors=5) - Fixed missing closing brace in both plugins' error-body catch block - Updated test targets: ai_common include path + link, using namespace dstalk_ai - plugin_loader_test: added stub_unreg + service_registry.cpp for unregister_service - Includes pre-existing uncommitted changes from prior waves Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -8,8 +8,8 @@ set "TOOLS=%~dp0"
|
||||
if exist "%TOOLS%cmake\bin" set "PATH=%TOOLS%cmake\bin;%PATH%"
|
||||
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%llvm\bin\clang-cl.exe" set "CC=%TOOLS%llvm\bin\clang-cl.exe"
|
||||
if exist "%TOOLS%llvm\bin\clang-cl.exe" set "CXX=%TOOLS%llvm\bin\clang-cl.exe"
|
||||
if exist "%TOOLS%.venv\Scripts" set "PATH=%TOOLS%.venv\Scripts;%PATH%"
|
||||
|
||||
echo [dstalk] tools\ 工具链已加载
|
||||
|
||||
141
tools/setup.sh
Normal file
141
tools/setup.sh
Normal file
@@ -0,0 +1,141 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# ============================================================
|
||||
# setup.sh — dstalk toolchain portable installer (Linux / macOS)
|
||||
# Installs CMake, Ninja, and Conan2 into tools/ without
|
||||
# modifying system PATH. Mirrors tools/setup.bat for Windows.
|
||||
# ============================================================
|
||||
|
||||
TOOLS="$(cd "$(dirname "$0")" && pwd)"
|
||||
OS=$(uname -s)
|
||||
ARCH=$(uname -m)
|
||||
|
||||
echo "============================================"
|
||||
echo " dstalk Toolchain — Portable Install"
|
||||
echo " Target: ${TOOLS}"
|
||||
echo " OS: ${OS} / ${ARCH}"
|
||||
echo "============================================"
|
||||
echo ""
|
||||
|
||||
# ============================================================
|
||||
# 0. Check for a C/C++ compiler
|
||||
# ============================================================
|
||||
echo "[0/4] Checking for C/C++ compiler..."
|
||||
if command -v clang &>/dev/null; then
|
||||
echo " [OK] clang found: $(command -v clang)"
|
||||
elif command -v gcc &>/dev/null; then
|
||||
echo " [OK] gcc found: $(command -v gcc)"
|
||||
else
|
||||
echo " [WARN] No C compiler found in PATH."
|
||||
if [ "$OS" = "Darwin" ]; then
|
||||
echo " Install Xcode Command Line Tools: xcode-select --install"
|
||||
else
|
||||
echo " Install build-essential: sudo apt install build-essential"
|
||||
echo " Or clang: sudo apt install clang"
|
||||
fi
|
||||
echo " You can continue setup, but build.sh will fail without a compiler."
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# 1. CMake
|
||||
# ============================================================
|
||||
echo "[1/4] CMake..."
|
||||
if [ -x "${TOOLS}/cmake/bin/cmake" ]; then
|
||||
echo " [OK] Already installed"
|
||||
else
|
||||
mkdir -p "${TOOLS}/cmake"
|
||||
CMAKE_VER="3.31.6"
|
||||
if [ "$OS" = "Darwin" ]; then
|
||||
if [ "$ARCH" = "arm64" ]; then
|
||||
CMAKE_URL="https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake-${CMAKE_VER}-macos-universal.tar.gz"
|
||||
else
|
||||
CMAKE_URL="https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake-${CMAKE_VER}-macos-universal.tar.gz"
|
||||
fi
|
||||
else
|
||||
CMAKE_URL="https://github.com/Kitware/CMake/releases/download/v${CMAKE_VER}/cmake-${CMAKE_VER}-linux-${ARCH}.tar.gz"
|
||||
fi
|
||||
echo " Downloading CMake ${CMAKE_VER}..."
|
||||
curl -L -o "${TOOLS}/cmake/cmake.tar.gz" "${CMAKE_URL}" 2>/dev/null || {
|
||||
echo " [FAIL] Download failed. Install CMake manually:"
|
||||
echo " macOS: brew install cmake"
|
||||
echo " Linux: sudo apt install cmake"
|
||||
}
|
||||
if [ -f "${TOOLS}/cmake/cmake.tar.gz" ]; then
|
||||
tar -xzf "${TOOLS}/cmake/cmake.tar.gz" -C "${TOOLS}/cmake" --strip-components=1
|
||||
rm -f "${TOOLS}/cmake/cmake.tar.gz"
|
||||
# macOS bundle: CMake.app/Contents/bin/cmake → cmake/bin/cmake
|
||||
if [ -d "${TOOLS}/cmake/CMake.app" ]; then
|
||||
cp -R "${TOOLS}/cmake/CMake.app/Contents/"* "${TOOLS}/cmake/"
|
||||
rm -rf "${TOOLS}/cmake/CMake.app"
|
||||
fi
|
||||
echo " [OK] CMake"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# 2. Ninja
|
||||
# ============================================================
|
||||
echo "[2/4] Ninja..."
|
||||
if [ -x "${TOOLS}/ninja/ninja" ]; then
|
||||
echo " [OK] Already installed"
|
||||
else
|
||||
mkdir -p "${TOOLS}/ninja"
|
||||
NINJA_VER="1.12.1"
|
||||
if [ "$OS" = "Darwin" ]; then
|
||||
NINJA_URL="https://github.com/ninja-build/ninja/releases/download/v${NINJA_VER}/ninja-mac.zip"
|
||||
else
|
||||
NINJA_URL="https://github.com/ninja-build/ninja/releases/download/v${NINJA_VER}/ninja-linux.zip"
|
||||
fi
|
||||
echo " Downloading Ninja ${NINJA_VER}..."
|
||||
curl -L -o "${TOOLS}/ninja/ninja.zip" "${NINJA_URL}" 2>/dev/null || {
|
||||
echo " [FAIL] Download failed. Install Ninja manually:"
|
||||
echo " macOS: brew install ninja"
|
||||
echo " Linux: sudo apt install ninja-build"
|
||||
}
|
||||
if [ -f "${TOOLS}/ninja/ninja.zip" ]; then
|
||||
(cd "${TOOLS}/ninja" && unzip -o ninja.zip && rm -f ninja.zip)
|
||||
chmod +x "${TOOLS}/ninja/ninja"
|
||||
echo " [OK] Ninja"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# 3. Python venv + Conan2
|
||||
# ============================================================
|
||||
echo "[3/4] Python venv + Conan2..."
|
||||
PYTHON=""
|
||||
for py in python3 python; do
|
||||
if command -v "$py" &>/dev/null; then
|
||||
PYTHON="$py"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$PYTHON" ]; then
|
||||
echo " [FAIL] Python 3.10+ not found."
|
||||
echo " macOS: brew install python"
|
||||
echo " Linux: sudo apt install python3 python3-venv"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "${TOOLS}/.venv/bin/python" ]; then
|
||||
"$PYTHON" -m venv "${TOOLS}/.venv"
|
||||
fi
|
||||
"${TOOLS}/.venv/bin/python" -m pip install --upgrade pip -q
|
||||
"${TOOLS}/.venv/bin/python" -m pip install 'conan>=2,<3' -q
|
||||
echo " [OK] Conan2"
|
||||
|
||||
# ============================================================
|
||||
# 4. Configure Conan profile
|
||||
# ============================================================
|
||||
echo "[4/4] Configuring Conan profile..."
|
||||
"${TOOLS}/.venv/bin/conan" profile detect --force 2>/dev/null || {
|
||||
echo " [WARN] Conan profile auto-detect failed. You may need to configure manually."
|
||||
}
|
||||
|
||||
echo ""
|
||||
echo "============================================"
|
||||
echo " Done! All tools are ready."
|
||||
echo "============================================"
|
||||
echo ""
|
||||
echo " Next step: run ./build.sh from the project root."
|
||||
Reference in New Issue
Block a user