feat(setup): add setup script for development environment and build directory management

This commit is contained in:
whaffman 2025-09-23 20:35:04 +00:00
parent a279e92408
commit 169bcf96c4
5 changed files with 71 additions and 3 deletions

View File

@ -15,7 +15,6 @@
"usernamehw.errorlens",
"llvm-vs-code-extensions.vscode-clangd",
"ms-vscode.hexeditor",
"eamodio.gitlens",
"ms-vscode-remote.remote-containers"
],
@ -37,7 +36,13 @@
"files.associations": {
"*.hpp": "cpp",
"*.tpp": "cpp"
},
"vscode" : {
"settings" : {
"remote.SSH.forwardAgent": true
}
}
}
}
},
@ -68,7 +73,11 @@
// Container features
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/sshd:1": {
"version": "latest",
"forwardPorts": [22]
}
},
// Mount points for better performance

2
.gitignore vendored
View File

@ -1,5 +1,7 @@
*.o
*.a
build
build-*
.cache
webserv.log
compile_commands.json

8
.vscode/tasks.json vendored
View File

@ -118,6 +118,14 @@
"args": ["re"],
"group": "build",
"detail": "Full clean and rebuild"
},
{
"label": "Clean All Environments",
"type": "shell",
"command": "rm",
"args": ["-rf", "build", "build-*"],
"group": "build",
"detail": "Clean build directories from all environments"
}
]
}

View File

@ -1,5 +1,11 @@
# Variables
BUILD_DIR = build
# Detect if we're in a dev container or local development
ifeq ($(shell whoami),vscode)
BUILD_DIR = build-container
else
BUILD_DIR = build-local
endif
CMAKE = cmake
CMAKE_BUILD = cmake --build
CMAKE_FLAGS = -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

43
setup.sh Executable file
View File

@ -0,0 +1,43 @@
#!/bin/bash
# Development Environment Setup Script
# This script sets up the build environment for both local and container development
set -e # Exit on any error
echo "🚀 Setting up webserv development environment..."
# Detect environment
if [ "$(whoami)" = "vscode" ]; then
BUILD_DIR="build-container"
ENVIRONMENT="Dev Container"
else
BUILD_DIR="build-local"
ENVIRONMENT="Local"
fi
echo "📍 Environment detected: $ENVIRONMENT"
echo "🔧 Using build directory: $BUILD_DIR"
# Clean old build directories if they exist
echo "🧹 Cleaning old build artifacts..."
rm -rf build build-* 2>/dev/null || true
# Create fresh build directory
echo "📁 Creating build directory: $BUILD_DIR"
cmake -B "$BUILD_DIR" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_BUILD_TYPE=Release
# Create symlink for compile_commands.json at workspace root for clangd
if [ -f "$BUILD_DIR/compile_commands.json" ]; then
echo "🔗 Creating compile_commands.json symlink for clangd..."
ln -sf "$BUILD_DIR/compile_commands.json" compile_commands.json
fi
echo "✅ Environment setup complete!"
echo ""
echo "Next steps:"
echo " • Run 'make all' to build the project"
echo " • Run 'make run' to start the server"
echo " • Use VS Code tasks (Ctrl+Shift+P > Tasks: Run Task) for build operations"