Skip to content

Latest commit

 

History

History
409 lines (305 loc) · 10.6 KB

File metadata and controls

409 lines (305 loc) · 10.6 KB
Based on the search results and your project structure[1], here's a comprehensive README file for your C++ template: # 🚀 vOS - Universal C++ Project Template A powerful, cross-platform C++ project template that seamlessly supports both Windows local development and Docker containerized environments. Built for maximum flexibility with dynamic path detection and zero-configuration setup. ![Language](https://img.shields.io/badge](https://img.shields.io/badge](https://img.shields.io/badge - 🔧 **Dynamic Configuration** - Automatically detects project name and root paths - 🪟 **Windows Native Support** - Complete Visual Studio 2022 integration with batch scripts - 🐳 **Docker Ready** - Full containerized development environment - 🎯 **VS Code Integration** - Complete IDE setup with debugging and tasks - 📦 **vcpkg Package Management** - Modern C++ dependencies with features - 🏗️ **CMake + Ninja** - Fast, reliable cross-platform build system - 🔄 **Multi-Platform** - Works on Windows 11, Linux, macOS - ⚡ **Zero Configuration** - Copy and use as template immediately - 🛠️ **Multiple Build Modes** - Release, Debug, and custom configurations ## 📁 Project Structure ``` vOS/ ├── 📁 .devcontainer/ # VS Code dev container config │ └── devcontainer.json ├── 📁 .vscode/ # VS Code workspace settings │ ├── launch.json # Debug configurations │ └── tasks.json # Build and run tasks ├── 📁 scripts/ # Windows development scripts │ ├── build.bat # Build project │ ├── start.bat # Build and run │ ├── debug.bat # Debug build with VS debugger │ ├── clean.bat # Clean build artifacts │ └── setup.ps1 # PowerShell automation script ├── 📁 src/ # Source code directory │ └── main.cpp # Application entry point ├── 🐳 docker-compose.yml # Docker development services ├── 🐳 Dockerfile # Multi-stage container build ├── 🔧 Makefile # Cross-platform build targets ├── 📦 vcpkg.json # Package dependencies & features ├── ⚙️ CMakeLists.txt # CMake configuration └── 📄 .env # Environment variables ``` ## 🚀 Quick Start ### Option 1: Windows Local Development (Recommended) **Prerequisites:** - Windows 10/11 - Visual Studio 2022 (Community/Professional/Enterprise) - CMake 3.15+ (included with VS) - Ninja build system (included with VS) **Commands:** ```cmd # Build the project scripts\build.bat # Build and run application scripts\start.bat # Debug build with Visual Studio debugger scripts\debug.bat # Clean build artifacts scripts\clean.bat ``` ### Option 2: Docker Development (Any OS) **Prerequisites:** - Docker Desktop - Docker Compose **Commands:** ```bash # Start interactive development environment docker-compose up dev # Inside container - available commands: cmake-build # Configure and build cmake-start # Build and run cmake-clean # Clean artifacts cmake-info # Show project information ``` ### Option 3: Makefile (Linux/macOS/Windows with Make) ```bash # Build project make build # Build and run make start # Clean make clean # Docker development make docker-dev # Show all targets make help ``` ## 🛠️ Development Workflows ### Windows Development Scripts #### **Batch Files Method** ```cmd # Complete workflow scripts\build.bat # Configure and build scripts\start.bat # Build and run scripts\debug.bat # Debug build + launch debugger scripts\clean.bat # Clean build artifacts ``` #### **PowerShell Method** ```powershell # Alternative PowerShell interface scripts\setup.ps1 build # Build project scripts\setup.ps1 start # Build and run scripts\setup.ps1 clean # Clean artifacts scripts\setup.ps1 configure # Configure only ``` #### **VS Code Integration** - Open project in VS Code - **Ctrl+Shift+B** - Default build task - **F5** - Debug with breakpoints - **Ctrl+Shift+P** → "Tasks: Run Task": - Build (Windows) - Run (Windows) - Debug Build (Windows) - Clean (Windows) - Docker Build - Docker Dev ### Docker Development #### **Interactive Development** ```bash # Method 1: Direct interactive session docker-compose up dev # Method 2: Background + enter docker-compose up -d dev docker-compose exec dev bash # Inside container: cmake-build # Build project cmake-start # Build and run cmake-clean # Clean cmake-info # Project details exit # Leave container # Stop services docker-compose down ``` #### **One-Shot Operations** ```bash # Build only docker-compose up build # Run production container docker-compose up app # Background production docker-compose up -d app ``` ## 📦 Package Management with vcpkg ### **Available Features** The template includes pre-configured vcpkg features: ```json { "features": { "json": { "description": "JSON support", "dependencies": ["nlohmann-json"] }, "fmt": { "description": "Formatting library", "dependencies": ["fmt"] }, "testing": { "description": "Testing framework", "dependencies": ["catch2"] } } } ``` ### **Enable Features** ```cmd # Install with JSON support vcpkg install --feature-flags=versions --x-manifest-root=. --feature json # Install with formatting library vcpkg install --feature-flags=versions --x-manifest-root=. --feature fmt # Install testing framework vcpkg install --feature-flags=versions --x-manifest-root=. --feature testing ``` ### **Add New Dependencies** Edit `vcpkg.json`: ```json { "dependencies": ["boost-filesystem", "opencv4", "sqlite3"] } ``` ## 🔧 Template Customization ### **Using as Template** 1. Copy/clone this project structure 2. Rename the project folder (name auto-detected) 3. Start coding - everything works automatically! ### **Project Name Detection** The template automatically detects project name from folder: - Folder: `MyAwesomeProject` → Executable: `MyAwesomeProject.exe` - No manual configuration needed ### **Adding Source Files** Simply add `.cpp` files to `src/` directory: ``` src/ ├── main.cpp ├── utils.cpp ├── networking/ │ └── client.cpp └── gui/ └── window.cpp ``` ### **Custom Build Configurations** ```cmake # Debug with extra flags cmake -B build_debug -S . -G Ninja -DCMAKE_BUILD_TYPE=Debug # Release with optimizations cmake -B build_release -S . -G Ninja -DCMAKE_BUILD_TYPE=Release # Custom configuration cmake -B build_custom -S . -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo ``` ## 🎯 Environment-Specific Features ### **Windows Features** - ✅ Visual Studio 2022 auto-detection (Enterprise/Professional/Community) - ✅ Developer Command Prompt integration - ✅ Visual Studio debugger launch (`debug.bat`) - ✅ vcpkg integration - ✅ PowerShell and Batch script support ### **Docker Features** - ✅ Multi-stage builds (builder + runtime) - ✅ Development container with tools - ✅ Production-ready minimal container - ✅ Volume mounting for live development - ✅ Build cache optimization ### **VS Code Features** - ✅ Integrated tasks for build/run/debug - ✅ Debug configuration with breakpoints - ✅ Dev container support - ✅ IntelliSense and code completion - ✅ Terminal integration ## 📋 Command Reference ### **Windows Commands** | Command | Description | | -------------------- | -------------------------------- | | `scripts\build.bat` | Configure and build project | | `scripts\start.bat` | Build and run application | | `scripts\debug.bat` | Debug build + launch VS debugger | | `scripts\clean.bat` | Clean all build artifacts | | `scripts\setup.ps1 ` | PowerShell interface | ### **Docker Commands** | Command | Description | | ------------------------- | ----------------------------------- | | `docker-compose up dev` | Interactive development environment | | `docker-compose up build` | Build project only | | `docker-compose up app` | Run production container | | `docker-compose down` | Stop all services | ### **Container Commands** (Inside dev container) | Command | Description | | ------------- | --------------------------- | | `cmake-build` | Configure and build project | | `cmake-start` | Build and run application | | `cmake-clean` | Clean build artifacts | | `cmake-info` | Show project information | ### **Make Commands** | Command | Description | | ----------------- | ------------------------ | | `make build` | Build project | | `make start` | Build and run | | `make clean` | Clean artifacts | | `make docker-dev` | Start Docker development | | `make help` | Show all targets | ## 🛡️ System Requirements ### **Windows Development** - Windows 10/11 (64-bit) - Visual Studio 2022 (any edition) - 8GB+ RAM recommended - 2GB+ disk space ### **Docker Development** - Docker Desktop 4.0+ - 4GB+ RAM allocated to Docker - 2GB+ disk space for images - Windows/Linux/macOS support ### **General** - C++17 compatible compiler - CMake 3.15 or later - Git (for cloning/version control) ## 🐛 Troubleshooting ### **Windows Issues** ```cmd # CMake not found # Solution: Install Visual Studio 2022 with C++ workload # Ninja not found # Solution: Run from "Developer Command Prompt for VS 2022" # Build fails # Solution: Clean and rebuild scripts\clean.bat scripts\build.bat ``` ### **Docker Issues** ```bash # Container won't start # Solution: Ensure Docker Desktop is running docker --version # Build cache issues # Solution: Clean build and restart docker-compose down -v docker-compose up dev --build # Permission denied # Solution: Check Docker daemon status ``` ### **Common Solutions** ```cmd # Complete reset - Windows scripts\clean.bat rmdir /s /q build scripts\build.bat # Complete reset - Docker docker-compose down -v docker system prune -f docker-compose up dev --build ``` # Test commit from personal account