feat: Improve CMake configuration and build environment verification

- Enabled JSON support by default in CMake to resolve Windows build issues.
- Added checks for the existence of the JSON library and its target, providing clear error messages if missing.
- Updated README with instructions for building with AI features.
- Enhanced the build environment verification script for better feedback on setup issues and added checks for agent folder structure.
- Introduced new CMake presets for AI-enabled builds and collaboration support.
This commit is contained in:
scawful
2025-10-04 19:43:05 -04:00
parent 226bcf8686
commit 588db01df6
5 changed files with 402 additions and 299 deletions

View File

@@ -72,8 +72,9 @@ option(YAZE_USE_MODULAR_BUILD "Use modularized library build system for faster b
# Enables: JSON parsing, YAML config, httplib for API calls, prompt builder
option(Z3ED_AI "Enable z3ed AI agent features (Gemini/Ollama integration)" OFF)
# YAZE_WITH_JSON: JSON support (auto-enabled by Z3ED_AI)
option(YAZE_WITH_JSON "Enable JSON support for AI integrations" OFF)
# YAZE_WITH_JSON: JSON support (bundled header-only library, minimal overhead)
# Enabled by default to avoid Windows build issues with agent history codec
option(YAZE_WITH_JSON "Enable JSON support for AI integrations" ON)
# YAZE_WITH_GRPC: gRPC for GUI automation (auto-enables JSON)
option(YAZE_WITH_GRPC "Enable gRPC-based ImGuiTestHarness for automated GUI testing (experimental)" OFF)
@@ -166,7 +167,30 @@ target_include_directories(yaze_common INTERFACE ${CMAKE_SOURCE_DIR}/third_party
if(YAZE_WITH_JSON)
set(JSON_BuildTests OFF CACHE INTERNAL "Disable nlohmann_json tests")
# Verify JSON library exists
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/third_party/json/CMakeLists.txt")
message(FATAL_ERROR
"JSON library not found in third_party/json/\n"
"This is required when YAZE_WITH_JSON=ON.\n"
"Please ensure the repository is fully cloned with submodules."
)
endif()
add_subdirectory(${CMAKE_SOURCE_DIR}/third_party/json ${CMAKE_BINARY_DIR}/third_party/json EXCLUDE_FROM_ALL)
# Verify the target was created
if(NOT TARGET nlohmann_json::nlohmann_json)
message(FATAL_ERROR
"Failed to create nlohmann_json::nlohmann_json target.\n"
"The JSON library subdirectory was added but the target is missing.\n"
"Please check third_party/json/CMakeLists.txt for errors."
)
endif()
message(STATUS "✓ JSON support enabled (nlohmann/json)")
message(STATUS " - Include directory: ${CMAKE_SOURCE_DIR}/third_party/json/include")
message(STATUS " - Target available: nlohmann_json::nlohmann_json")
endif()
# Platform-specific configurations
@@ -180,11 +204,34 @@ elseif(YAZE_PLATFORM_WINDOWS)
if(DEFINED CMAKE_TOOLCHAIN_FILE AND EXISTS "${CMAKE_TOOLCHAIN_FILE}")
include(cmake/vcpkg.cmake)
message(STATUS "Using vcpkg integration")
message(STATUS " - Toolchain: ${CMAKE_TOOLCHAIN_FILE}")
else()
message(STATUS "vcpkg not available - using system packages")
message(STATUS "vcpkg not available - using system packages or bundled dependencies")
message(STATUS " Tip: Set VCPKG_ROOT environment variable to enable vcpkg")
endif()
target_compile_definitions(yaze_common INTERFACE WINDOWS)
# Windows-specific build guidance
message(STATUS "===========================================")
message(STATUS "Windows Build Configuration:")
message(STATUS " - Generator: ${CMAKE_GENERATOR}")
message(STATUS " - Architecture: ${CMAKE_GENERATOR_PLATFORM}")
message(STATUS " - JSON Support: ${YAZE_WITH_JSON}")
message(STATUS " - AI Features: ${Z3ED_AI}")
message(STATUS " - gRPC Support: ${YAZE_WITH_GRPC}")
message(STATUS "===========================================")
# Helpful messages about build configuration
if(NOT Z3ED_AI)
message(STATUS "Note: AI agent features disabled (JSON is enabled)")
message(STATUS " To enable AI: cmake --preset windows-ai-debug")
endif()
if(NOT YAZE_WITH_JSON)
message(STATUS "Warning: JSON disabled - some features may not compile")
message(STATUS " Recommend keeping JSON enabled (it's header-only)")
endif()
# Windows-specific architecture detection and configuration
if(CMAKE_SYSTEM_PROCESSOR MATCHES "ARM64|aarch64")
target_compile_definitions(yaze_common INTERFACE YAZE_ARCH_ARM64)

View File

@@ -220,7 +220,7 @@
{
"name": "windows-debug",
"displayName": "Windows Debug",
"description": "Windows-specific debug configuration with vcpkg",
"description": "Windows debug build (JSON enabled by default, AI features disabled)",
"inherits": "debug",
"condition": {
"type": "equals",
@@ -287,6 +287,42 @@
"YAZE_TEST_ROM_PATH": "${sourceDir}/zelda3.sfc"
}
},
{
"name": "windows-ai-debug",
"displayName": "Windows AI Debug",
"description": "Windows debug build with AI agent features (JSON enabled)",
"inherits": "windows-debug",
"cacheVariables": {
"Z3ED_AI": "ON",
"YAZE_WITH_JSON": "ON",
"YAZE_BUILD_Z3ED": "ON",
"YAZE_BUILD_TESTS": "ON"
}
},
{
"name": "windows-ai-release",
"displayName": "Windows AI Release",
"description": "Windows release build with AI agent features (JSON enabled)",
"inherits": "windows-release",
"cacheVariables": {
"Z3ED_AI": "ON",
"YAZE_WITH_JSON": "ON",
"YAZE_BUILD_Z3ED": "ON"
}
},
{
"name": "windows-collab-debug",
"displayName": "Windows Collaboration Debug",
"description": "Windows debug build with full collaboration support (JSON + gRPC)",
"inherits": "windows-debug",
"cacheVariables": {
"Z3ED_AI": "ON",
"YAZE_WITH_JSON": "ON",
"YAZE_WITH_GRPC": "ON",
"YAZE_BUILD_Z3ED": "ON",
"YAZE_BUILD_TESTS": "ON"
}
},
{
"name": "windows-arm64-debug",
"displayName": "Windows ARM64 Debug",
@@ -500,6 +536,27 @@
"displayName": "Windows z3ed Agent Test Build",
"configuration": "Debug",
"jobs": 12
},
{
"name": "windows-ai-debug",
"configurePreset": "windows-ai-debug",
"displayName": "Windows AI Debug Build",
"configuration": "Debug",
"jobs": 12
},
{
"name": "windows-ai-release",
"configurePreset": "windows-ai-release",
"displayName": "Windows AI Release Build",
"configuration": "Release",
"jobs": 12
},
{
"name": "windows-collab-debug",
"configurePreset": "windows-collab-debug",
"displayName": "Windows Collaboration Debug Build",
"configuration": "Debug",
"jobs": 12
}
],
"testPresets": [

View File

@@ -45,6 +45,12 @@ cd yaze
# Build with CMake
cmake --preset debug # macOS
cmake -B build && cmake --build build # Linux/Windows
# Windows-specific
scripts\verify-build-environment.ps1 # Verify your setup
cmake --preset windows-debug # Basic build
cmake --preset windows-ai-debug # With AI features
cmake --build build --config Debug # Build
```
### Applications

View File

@@ -1,6 +1,7 @@
#!/bin/bash
# YAZE Build Environment Verification Script for macOS/Linux
# YAZE Build Environment Verification Script for Unix/macOS
# This script verifies the build environment is properly configured and ready to build
# Run this before building to catch common configuration issues early
set -e
@@ -12,89 +13,82 @@ BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Flags
VERBOSE=0
FIX_ISSUES=0
CLEAN_CACHE=0
issues_found=()
warnings=()
successes=()
# Counters
ISSUES_FOUND=()
WARNINGS=()
SUCCESS=()
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--verbose|-v)
VERBOSE=1
shift
;;
--fix|-f)
FIX_ISSUES=1
shift
;;
--clean|-c)
CLEAN_CACHE=1
shift
;;
--help|-h)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --verbose, -v Show detailed output"
echo " --fix, -f Automatically fix issues"
echo " --clean, -c Clean CMake cache"
echo " --help, -h Show this help message"
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
case $1 in
-v|--verbose)
VERBOSE=1
shift
;;
-f|--fix)
FIX_ISSUES=1
shift
;;
-c|--clean)
CLEAN_CACHE=1
shift
;;
-h|--help)
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " -v, --verbose Verbose output"
echo " -f, --fix Automatically fix issues"
echo " -c, --clean Clean CMake cache"
echo " -h, --help Show this help message"
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
print_status() {
local type=$1
local message=$2
function write_status() {
local message="$1"
local type="${2:-Info}"
local timestamp=$(date +"%H:%M:%S")
case $type in
success)
case "$type" in
Success)
echo -e "[$timestamp] ${GREEN}${NC} $message"
;;
error)
Error)
echo -e "[$timestamp] ${RED}${NC} $message"
;;
warning)
Warning)
echo -e "[$timestamp] ${YELLOW}${NC} $message"
;;
info)
Info)
echo -e "[$timestamp] ${CYAN}${NC} $message"
;;
step)
echo ""
echo -e "[$timestamp] ${BLUE}${NC} ${BLUE}$message${NC}"
Step)
echo -e "\n[$timestamp] ${BLUE}${NC} $message"
;;
esac
}
check_command() {
if command -v "$1" &> /dev/null; then
return 0
else
return 1
function test_command() {
command -v "$1" &> /dev/null
}
function get_cmake_version() {
if test_command cmake; then
cmake --version 2>&1 | head -n1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+'
fi
}
get_cmake_version() {
local version=$(cmake --version 2>/dev/null | head -n1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -n1)
if [ -n "$version" ]; then
echo "$version"
else
echo "unknown"
fi
}
check_git_submodules() {
function test_git_submodules() {
local submodules=(
"src/lib/SDL"
"src/lib/abseil-cpp"
@@ -104,136 +98,159 @@ check_git_submodules() {
"third_party/httplib"
)
local all_present=0
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local root_dir="$(cd "$script_dir/.." && pwd)"
local all_present=1
for submodule in "${submodules[@]}"; do
if [ ! -d "$root_dir/$submodule" ] || [ -z "$(ls -A "$root_dir/$submodule")" ]; then
print_status error "Submodule missing or empty: $submodule"
issues_found+=("Missing submodule: $submodule")
all_present=1
elif [ $VERBOSE -eq 1 ]; then
print_status success "Submodule found: $submodule"
if [[ ! -d "$submodule" ]] || [[ -z "$(ls -A "$submodule" 2>/dev/null)" ]]; then
write_status "Submodule missing or empty: $submodule" "Error"
ISSUES_FOUND+=("Missing/empty submodule: $submodule")
all_present=0
elif [[ $VERBOSE -eq 1 ]]; then
write_status "Submodule found: $submodule" "Success"
fi
done
return $all_present
}
function test_cmake_cache() {
local build_dirs=("build" "build_test" "build-grpc-test" "build_rooms")
local cache_issues=0
for dir in "${build_dirs[@]}"; do
if [[ -f "$dir/CMakeCache.txt" ]]; then
local cache_age=$(($(date +%s) - $(stat -f %m "$dir/CMakeCache.txt" 2>/dev/null || stat -c %Y "$dir/CMakeCache.txt" 2>/dev/null)))
local days=$((cache_age / 86400))
if [[ $days -gt 7 ]]; then
write_status "CMake cache in '$dir' is $days days old" "Warning"
WARNINGS+=("Old CMake cache in $dir (consider cleaning)")
cache_issues=1
elif [[ $VERBOSE -eq 1 ]]; then
write_status "CMake cache in '$dir' is recent" "Success"
fi
fi
done
return $cache_issues
}
function test_agent_folder_structure() {
write_status "Verifying agent folder structure..." "Step"
local agent_files=(
"src/app/editor/agent/agent_editor.h"
"src/app/editor/agent/agent_editor.cc"
"src/app/editor/agent/agent_chat_widget.h"
"src/app/editor/agent/agent_chat_widget.cc"
"src/app/editor/agent/agent_chat_history_codec.h"
"src/app/editor/agent/agent_chat_history_codec.cc"
"src/app/editor/agent/agent_collaboration_coordinator.h"
"src/app/editor/agent/agent_collaboration_coordinator.cc"
"src/app/editor/agent/network_collaboration_coordinator.h"
"src/app/editor/agent/network_collaboration_coordinator.cc"
)
local old_system_files=(
"src/app/editor/system/agent_chat_widget.h"
"src/app/editor/system/agent_collaboration_coordinator.h"
)
local all_present=1
local has_old_structure=0
for file in "${agent_files[@]}"; do
if [[ ! -f "$file" ]]; then
write_status "Agent file missing: $file" "Error"
ISSUES_FOUND+=("Missing agent file: $file (may need to rebuild)")
all_present=0
elif [[ $VERBOSE -eq 1 ]]; then
write_status "Agent file found: $file" "Success"
fi
done
# Check for old structure (indicates stale cache)
for file in "${old_system_files[@]}"; do
if [[ -f "$file" ]]; then
write_status "Old agent file still present: $file" "Warning"
WARNINGS+=("Old agent structure detected (CMake cache needs cleaning)")
has_old_structure=1
fi
done
if [[ $all_present -eq 1 && $has_old_structure -eq 0 ]]; then
write_status "Agent folder structure is correct" "Success"
SUCCESS+=("Agent refactoring structure verified")
return 0
elif [[ $has_old_structure -eq 1 ]]; then
write_status "Stale agent files detected - CMake cache should be cleaned" "Warning"
return 1
fi
return $all_present
}
check_cmake_cache() {
local build_dirs=("build" "build_test" "build-grpc-test")
local cache_issues=0
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local root_dir="$(cd "$script_dir/.." && pwd)"
function clean_cmake_cache() {
write_status "Cleaning CMake cache and build directories..." "Step"
local build_dirs=("build" "build_test" "build-grpc-test" "build_rooms")
local cleaned=0
for dir in "${build_dirs[@]}"; do
local cache_path="$root_dir/$dir/CMakeCache.txt"
if [ -f "$cache_path" ]; then
local cache_age=$(($(date +%s) - $(stat -f %m "$cache_path" 2>/dev/null || stat -c %Y "$cache_path")))
local cache_days=$((cache_age / 86400))
if [ $cache_days -gt 7 ]; then
print_status warning "CMake cache in '$dir' is $cache_days days old"
warnings+=("Old CMake cache in $dir (consider cleaning)")
cache_issues=1
elif [ $VERBOSE -eq 1 ]; then
print_status success "CMake cache in '$dir' is recent"
if [[ -d "$dir" ]]; then
write_status "Removing $dir..." "Info"
if rm -rf "$dir" 2>/dev/null; then
cleaned=1
write_status " ✓ Removed $dir" "Success"
else
write_status " ✗ Failed to remove $dir" "Error"
WARNINGS+=("Could not fully clean $dir")
fi
fi
done
return $cache_issues
}
check_dependency_compatibility() {
print_status step "Testing dependency configuration..."
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local root_dir="$(cd "$script_dir/.." && pwd)"
# Check gRPC configuration
local grpc_path="$root_dir/cmake/grpc.cmake"
if [ -f "$grpc_path" ]; then
if grep -q "CMAKE_DISABLE_FIND_PACKAGE_Protobuf TRUE" "$grpc_path"; then
print_status success "gRPC isolation configured correctly"
else
print_status warning "gRPC may conflict with system protobuf"
warnings+=("gRPC not properly isolated from system packages")
fi
fi
# Check httplib
if [ -d "$root_dir/third_party/httplib" ]; then
print_status success "httplib found in third_party"
successes+=("httplib header-only library available")
fi
# Check json library
if [ -d "$root_dir/third_party/json/include" ]; then
print_status success "nlohmann/json found in third_party"
successes+=("nlohmann/json header-only library available")
fi
}
clean_cmake_cache() {
print_status step "Cleaning CMake cache..."
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local root_dir="$(cd "$script_dir/.." && pwd)"
local build_dirs=("build" "build_test" "build-grpc-test")
for dir in "${build_dirs[@]}"; do
if [ -d "$root_dir/$dir" ]; then
print_status info "Removing $dir..."
rm -rf "$root_dir/$dir"
# Clean CMake generated files in root
local cmake_files=("CMakeCache.txt" "cmake_install.cmake" "compile_commands.json")
for file in "${cmake_files[@]}"; do
if [[ -f "$file" ]]; then
write_status "Removing root $file..." "Info"
rm -f "$file" 2>/dev/null
fi
done
print_status success "CMake cache cleaned"
}
sync_git_submodules() {
print_status step "Syncing git submodules..."
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local root_dir="$(cd "$script_dir/.." && pwd)"
cd "$root_dir"
print_status info "Running: git submodule sync --recursive"
git submodule sync --recursive
print_status info "Running: git submodule update --init --recursive"
git submodule update --init --recursive
print_status success "Submodules synced successfully"
}
test_cmake_configuration() {
print_status step "Testing CMake configuration..."
local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
local root_dir="$(cd "$script_dir/.." && pwd)"
local test_build_dir="$root_dir/build_test_config"
print_status info "Configuring CMake (this may take a moment)..."
if cmake -B "$test_build_dir" -S "$root_dir" \
-DCMAKE_BUILD_TYPE=Debug \
-DYAZE_MINIMAL_BUILD=ON \
-DYAZE_BUILD_TESTS=OFF &>/dev/null; then
print_status success "CMake configuration successful"
successes+=("CMake configuration test passed")
# Cleanup test build
rm -rf "$test_build_dir"
return 0
if [[ $cleaned -eq 1 ]]; then
write_status "CMake cache cleaned successfully" "Success"
SUCCESS+=("Build directories cleaned - fresh build recommended")
else
print_status error "CMake configuration failed"
issues_found+=("CMake configuration test failed")
return 1
write_status "No build directories found to clean" "Info"
fi
}
function sync_git_submodules() {
write_status "Syncing git submodules..." "Step"
write_status "Running: git submodule sync --recursive" "Info"
if git submodule sync --recursive &> /dev/null; then
write_status "Running: git submodule update --init --recursive" "Info"
if git submodule update --init --recursive; then
write_status "Submodules synced successfully" "Success"
return 0
fi
fi
write_status "Failed to sync submodules" "Error"
return 1
}
function test_dependency_compatibility() {
write_status "Testing dependency configuration..." "Step"
# Check httplib configuration
if [[ -f "third_party/httplib/CMakeLists.txt" ]]; then
write_status "httplib found in third_party" "Success"
SUCCESS+=("httplib header-only library available")
fi
# Check json library
if [[ -d "third_party/json/include" ]]; then
write_status "nlohmann/json found in third_party" "Success"
SUCCESS+=("nlohmann/json header-only library available")
fi
}
@@ -243,182 +260,164 @@ test_cmake_configuration() {
echo ""
echo -e "${CYAN}╔════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${CYAN} YAZE Build Environment Verification (macOS/Linux) ${NC}"
echo -e "${CYAN}║ YAZE Build Environment Verification for Unix/macOS/Linux ║${NC}"
echo -e "${CYAN}╚════════════════════════════════════════════════════════════════╝${NC}"
echo ""
start_time=$(date +%s)
START_TIME=$(date +%s)
# Change to script directory
cd "$(dirname "$0")/.."
# Step 1: Check CMake
print_status step "Checking CMake installation..."
if check_command cmake; then
write_status "Checking CMake installation..." "Step"
if test_command cmake; then
cmake_version=$(get_cmake_version)
write_status "CMake found: version $cmake_version" "Success"
if [ "$cmake_version" != "unknown" ]; then
print_status success "CMake found: version $cmake_version"
# Check version
major=$(echo "$cmake_version" | cut -d. -f1)
minor=$(echo "$cmake_version" | cut -d. -f2)
# Validate that we got numeric values
if [[ "$major" =~ ^[0-9]+$ ]] && [[ "$minor" =~ ^[0-9]+$ ]]; then
if [ "$major" -lt 3 ] || ([ "$major" -eq 3 ] && [ "$minor" -lt 16 ]); then
print_status error "CMake version too old (need 3.16+)"
issues_found+=("CMake version $cmake_version is below minimum 3.16")
fi
else
print_status warning "Could not parse CMake version: $cmake_version"
warnings+=("Unable to verify CMake version requirement (need 3.16+)")
fi
else
print_status warning "CMake found but version could not be determined"
warnings+=("CMake version could not be parsed - ensure version 3.16+ is installed")
# Parse version
IFS='.' read -ra VERSION_PARTS <<< "$cmake_version"
major=${VERSION_PARTS[0]}
minor=${VERSION_PARTS[1]}
if [[ $major -lt 3 ]] || [[ $major -eq 3 && $minor -lt 16 ]]; then
write_status "CMake version too old (need 3.16+)" "Error"
ISSUES_FOUND+=("CMake version $cmake_version is below minimum 3.16")
fi
else
print_status error "CMake not found in PATH"
issues_found+=("CMake not installed or not in PATH")
write_status "CMake not found in PATH" "Error"
ISSUES_FOUND+=("CMake not installed or not in PATH")
fi
# Step 2: Check Git
print_status step "Checking Git installation..."
if check_command git; then
write_status "Checking Git installation..." "Step"
if test_command git; then
git_version=$(git --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
print_status success "Git found: version $git_version"
write_status "Git found: version $git_version" "Success"
else
print_status error "Git not found in PATH"
issues_found+=("Git not installed or not in PATH")
write_status "Git not found in PATH" "Error"
ISSUES_FOUND+=("Git not installed or not in PATH")
fi
# Step 3: Check Platform-Specific Tools
print_status step "Checking platform-specific tools..."
if [[ "$OSTYPE" == "darwin"* ]]; then
if check_command xcodebuild; then
xcode_version=$(xcodebuild -version | head -n1)
print_status success "Xcode found: $xcode_version"
else
print_status warning "Xcode not found (optional but recommended)"
warnings+=("Xcode Command Line Tools not installed")
fi
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
if check_command gcc || check_command clang; then
print_status success "C++ compiler found"
else
print_status error "No C++ compiler found"
issues_found+=("Install build-essential or clang")
fi
# Check for GTK (needed for NFD on Linux)
if pkg-config --exists gtk+-3.0; then
print_status success "GTK+3 found"
else
print_status warning "GTK+3 not found (needed for file dialogs)"
warnings+=("Install libgtk-3-dev for native file dialogs")
fi
# Step 3: Check Build Tools
write_status "Checking build tools..." "Step"
if test_command make; then
write_status "Make found" "Success"
elif test_command ninja; then
write_status "Ninja found" "Success"
else
write_status "No build tool found (make or ninja)" "Warning"
WARNINGS+=("Neither make nor ninja found")
fi
# Step 4: Check Git Submodules
print_status step "Checking git submodules..."
if check_git_submodules; then
print_status success "All required submodules present"
# Step 4: Check Compiler
if test_command clang++; then
clang_version=$(clang++ --version | head -n1)
write_status "Clang++ found: $clang_version" "Success"
elif test_command g++; then
gpp_version=$(g++ --version | head -n1)
write_status "G++ found: $gpp_version" "Success"
else
print_status error "Some submodules are missing or empty"
if [ $FIX_ISSUES -eq 1 ]; then
write_status "No C++ compiler found" "Error"
ISSUES_FOUND+=("No C++ compiler (clang++ or g++) found")
fi
# Step 5: Check Git Submodules
write_status "Checking git submodules..." "Step"
if test_git_submodules; then
write_status "All required submodules present" "Success"
else
write_status "Some submodules are missing or empty" "Error"
if [[ $FIX_ISSUES -eq 1 ]]; then
sync_git_submodules
# Re-check after sync
if ! check_git_submodules; then
print_status warning "Submodule sync completed but some issues remain"
fi
test_git_submodules
else
# Auto-fix without confirmation
print_status info "Automatically syncing submodules..."
write_status "Automatically syncing submodules..." "Info"
if sync_git_submodules; then
print_status success "Submodules synced successfully"
# Re-check after sync
check_git_submodules
test_git_submodules
else
print_status error "Failed to sync submodules automatically"
print_status info "Run with --fix to try again, or manually run: git submodule update --init --recursive"
write_status "Run with --fix to try again, or manually: git submodule update --init --recursive" "Info"
fi
fi
fi
# Step 5: Check CMake Cache
print_status step "Checking CMake cache..."
if check_cmake_cache; then
print_status success "CMake cache is up to date"
# Step 6: Check CMake Cache
write_status "Checking CMake cache..." "Step"
if test_cmake_cache; then
write_status "CMake cache is up to date" "Success"
else
if [ $CLEAN_CACHE -eq 1 ]; then
if [[ $CLEAN_CACHE -eq 1 ]]; then
clean_cmake_cache
elif [ $FIX_ISSUES -eq 1 ]; then
# Ask for confirmation before cleaning cache
echo ""
echo -e "${YELLOW}CMake cache is older than 7 days. Clean it?${NC}"
echo -e "${CYAN}This will remove build/, build_test/, and build-grpc-test/ directories.${NC}"
read -p "Continue? (Y/n) " -n 1 -r
echo ""
elif [[ $FIX_ISSUES -eq 1 ]]; then
read -p "CMake cache is old. Clean it? (Y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then
clean_cmake_cache
else
print_status info "Skipping cache clean"
fi
else
print_status warning "CMake cache is older than 7 days (consider cleaning)"
print_status info "Run with --clean to remove old cache files"
write_status "Run with --clean to remove old cache files" "Info"
fi
fi
# Step 6: Check Dependencies
check_dependency_compatibility
# Step 7: Check Dependencies
test_dependency_compatibility
# Step 7: Test CMake Configuration (if requested)
if [ $VERBOSE -eq 1 ] || [ $FIX_ISSUES -eq 1 ]; then
test_cmake_configuration
# Step 8: Check Agent Folder Structure
if test_agent_folder_structure; then
: # Structure is OK
else
write_status "Agent folder structure has issues" "Warning"
if [[ $CLEAN_CACHE -eq 1 ]] || [[ $FIX_ISSUES -eq 1 ]]; then
write_status "Cleaning CMake cache due to structural changes..." "Info"
clean_cmake_cache
write_status "Please rebuild the project after cache cleaning" "Info"
else
write_status "Run with --clean to fix structural issues" "Info"
fi
fi
# ============================================================================
# Summary Report
# ============================================================================
end_time=$(date +%s)
duration=$((end_time - start_time))
END_TIME=$(date +%s)
DURATION=$((END_TIME - START_TIME))
echo ""
echo -e "${CYAN}╔════════════════════════════════════════════════════════════════╗${NC}"
echo -e "${CYAN}║ Verification Summary ║${NC}"
echo -e "${CYAN}╚════════════════════════════════════════════════════════════════╝${NC}"
echo ""
echo "Duration: $duration seconds"
echo "Duration: ${DURATION} seconds"
echo ""
if [ ${#successes[@]} -gt 0 ]; then
echo -e "${GREEN}✓ Successes (${#successes[@]}):${NC}"
for item in "${successes[@]}"; do
if [[ ${#SUCCESS[@]} -gt 0 ]]; then
echo -e "${GREEN}✓ Successes (${#SUCCESS[@]}):${NC}"
for item in "${SUCCESS[@]}"; do
echo -e " ${GREEN}${NC} $item"
done
echo ""
fi
if [ ${#warnings[@]} -gt 0 ]; then
echo -e "${YELLOW}⚠ Warnings (${#warnings[@]}):${NC}"
for item in "${warnings[@]}"; do
if [[ ${#WARNINGS[@]} -gt 0 ]]; then
echo -e "${YELLOW}⚠ Warnings (${#WARNINGS[@]}):${NC}"
for item in "${WARNINGS[@]}"; do
echo -e " ${YELLOW}${NC} $item"
done
echo ""
fi
if [ ${#issues_found[@]} -gt 0 ]; then
echo -e "${RED}✗ Issues Found (${#issues_found[@]}):${NC}"
for item in "${issues_found[@]}"; do
if [[ ${#ISSUES_FOUND[@]} -gt 0 ]]; then
echo -e "${RED}✗ Issues Found (${#ISSUES_FOUND[@]}):${NC}"
for item in "${ISSUES_FOUND[@]}"; do
echo -e " ${RED}${NC} $item"
done
echo ""
echo -e "${YELLOW}Recommended Actions:${NC}"
echo -e " 1. Run: ${CYAN}./scripts/verify-build-environment.sh --fix${NC}"
echo -e " 2. Install missing dependencies"
echo -e " 3. Check build instructions: ${CYAN}docs/02-build-instructions.md${NC}"
echo -e " ${CYAN}1. Run: ./scripts/verify-build-environment.sh --fix${NC}"
echo -e " ${CYAN}2. Install missing dependencies${NC}"
echo -e " ${CYAN}3. Check build instructions: docs/02-build-instructions.md${NC}"
echo ""
exit 1
@@ -429,16 +428,10 @@ else
echo ""
echo -e "${CYAN}Next Steps:${NC}"
if [[ "$OSTYPE" == "darwin"* ]]; then
echo -e " ${BLUE}macOS:${NC}"
echo " cmake --preset debug"
echo " cmake --build build"
else
echo -e " ${BLUE}Linux:${NC}"
echo " cmake -B build -DCMAKE_BUILD_TYPE=Debug"
echo " cmake --build build"
fi
echo -e " ${CYAN}Command Line Workflow:${NC}"
echo -e " ${NC}cmake -B build -DCMAKE_BUILD_TYPE=Debug${NC}"
echo -e " ${NC}cmake --build build --parallel \$(nproc)${NC}"
echo ""
exit 0
fi
fi

View File

@@ -842,7 +842,7 @@ absl::Status ModernCLI::HandleCollabCommand(const std::vector<std::string>& args
if (const char* yaze_root = std::getenv("YAZE_ROOT")) {
server_dir = std::string(yaze_root);
} else {
// Assume we're in build directory, server is ../yaze-collab-server
// Assume we're in build directory, server is ../yaze-server
server_dir = "..";
}
@@ -853,11 +853,11 @@ absl::Status ModernCLI::HandleCollabCommand(const std::vector<std::string>& args
std::string command;
#ifdef _WIN32
// Windows: Use cmd.exe to run npm start
command = "cd /D \"" + server_dir + "\\..\\yaze-collab-server\" && set PORT=" +
command = "cd /D \"" + server_dir + "\\..\\yaze-server\" && set PORT=" +
port + " && npm start";
#else
// Unix: Use bash script
command = "cd \"" + server_dir + "/../yaze-collab-server\" && PORT=" +
command = "cd \"" + server_dir + "/../yaze-server\" && PORT=" +
port + " node server.js &";
#endif
@@ -865,7 +865,7 @@ absl::Status ModernCLI::HandleCollabCommand(const std::vector<std::string>& args
if (result != 0) {
std::cout << "⚠️ Note: Server may not be installed. To install:\n";
std::cout << " cd yaze-collab-server && npm install\n";
std::cout << " cd yaze-server && npm install\n";
return absl::InternalError("Failed to start collaboration server");
}