diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5eccf66..844480e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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 diff --git a/.gitignore b/.gitignore index afa4e9a..2e8fe45 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ *.o *.a build +build-* .cache webserv.log +compile_commands.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json index ca93617..a0f489f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -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" } ] } diff --git a/Makefile b/Makefile index b8594c5..f1eabe3 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..2d2ffce --- /dev/null +++ b/setup.sh @@ -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" \ No newline at end of file