diff --git a/.gitignore b/.gitignore index bfd0f69e..68a306ac 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ *.sln.docstates *.zip *.code-workspace +!FlingEngine.code-workspace # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs @@ -300,4 +301,11 @@ CTestTestfile.cmake _deps ## VSCode -**/.vscode +# Track our checked-in workspace config (settings/tasks/launch/extensions); +# ignore everything else VSCode writes into .vscode/ (e.g. per-user overrides, ipch). +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/cmake-variants.json diff --git a/.vscode/cmake-variants.json b/.vscode/cmake-variants.json new file mode 100644 index 00000000..e02f435a --- /dev/null +++ b/.vscode/cmake-variants.json @@ -0,0 +1,28 @@ +{ + "buildType": { + "default": "debug", + "description": "The CMake build type", + "choices": { + "debug": { + "short": "Debug", + "long": "Full debug info, no optimizations", + "buildType": "Debug" + }, + "release": { + "short": "Release", + "long": "Optimized, no debug info", + "buildType": "Release" + }, + "relwithdebinfo": { + "short": "RelWithDebInfo", + "long": "Optimized, with debug info", + "buildType": "RelWithDebInfo" + }, + "minsizerel": { + "short": "MinSizeRel", + "long": "Optimized for smallest size", + "buildType": "MinSizeRel" + } + } + } +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..55bdbcf0 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "ms-vscode.cmake-tools", + "ms-vscode.cpptools", + "twxs.cmake" + ] +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..4c319140 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,53 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug Sandbox", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/Sandbox/bin/Sandbox", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "Build Sandbox", + "windows": { + "type": "cppvsdbg", + "program": "${workspaceFolder}\\build\\Sandbox\\bin\\${command:cmake.buildType}\\Sandbox.exe" + } + }, + { + "name": "Debug FlingTests", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/build/FlingTests/bin/FlingTests", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "Build FlingTests", + "windows": { + "type": "cppvsdbg", + "program": "${workspaceFolder}\\build\\FlingTests\\bin\\${command:cmake.buildType}\\FlingTests.exe" + } + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..d4596e30 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,9 @@ +{ + "cmake.sourceDirectory": "${workspaceFolder}", + "cmake.buildDirectory": "${workspaceFolder}/build", + "cmake.configureOnOpen": true, + "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", + "files.associations": { + "*.inl": "cpp" + } +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..1a1cfaa7 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,61 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "CMake: Configure", + "type": "shell", + "command": "cmake", + "args": ["-S", ".", "-B", "build"], + "problemMatcher": [] + }, + { + "label": "Build FlingEngine", + "type": "shell", + "command": "cmake", + "args": ["--build", "build", "--target", "FlingEngine", "--config", "${command:cmake.buildType}", "--parallel"], + "group": "build", + "problemMatcher": ["$gcc", "$msCompile"] + }, + { + "label": "Build Sandbox", + "type": "shell", + "command": "cmake", + "args": ["--build", "build", "--target", "Sandbox", "--config", "${command:cmake.buildType}", "--parallel"], + "group": "build", + "problemMatcher": ["$gcc", "$msCompile"] + }, + { + "label": "Build FlingTests", + "type": "shell", + "command": "cmake", + "args": ["--build", "build", "--target", "FlingTests", "--config", "${command:cmake.buildType}", "--parallel"], + "group": "build", + "problemMatcher": ["$gcc", "$msCompile"] + }, + { + "label": "Build All", + "type": "shell", + "command": "cmake", + "args": ["--build", "build", "--config", "${command:cmake.buildType}", "--parallel"], + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": ["$gcc", "$msCompile"] + }, + { + "label": "Run FlingTests", + "type": "shell", + "command": "${workspaceFolder}/build/FlingTests/bin/FlingTests", + "windows": { + "command": "${workspaceFolder}\\build\\FlingTests\\bin\\${command:cmake.buildType}\\FlingTests.exe" + }, + "dependsOn": "Build FlingTests", + "group": { + "kind": "test", + "isDefault": true + }, + "problemMatcher": [] + } + ] +} diff --git a/FlingEngine.code-workspace b/FlingEngine.code-workspace new file mode 100644 index 00000000..db0fd4e0 --- /dev/null +++ b/FlingEngine.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": {} +} diff --git a/Init.bat b/Init.bat index b5a2f25f..ce241625 100644 --- a/Init.bat +++ b/Init.bat @@ -24,3 +24,7 @@ git submodule update --init --recursive :: Run cmake to generate the local x64 files in the build folder ::cd "../.." cmake . -A x64 -B build + +echo. +echo Done! Open FlingEngine.code-workspace in VS Code to build/run/debug +echo the FlingEngine, Sandbox, and FlingTests targets from the Run and Debug menu. diff --git a/Init.sh b/Init.sh index 61596153..f1159e8e 100755 --- a/Init.sh +++ b/Init.sh @@ -34,3 +34,7 @@ if command -v claude >/dev/null 2>&1; then esac fi fi + +echo +echo Done! Open FlingEngine.code-workspace in VS Code to build/run/debug +echo the FlingEngine, Sandbox, and FlingTests targets from the Run and Debug menu. diff --git a/README.md b/README.md index 4b8fb67d..f6d79b05 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,17 @@ build\Sandbox\bin\Debug\Sandbox.exe See [`Skills/building.md`](Skills/building.md) for switching build types (Debug/Release/ shipping) and other day-to-day build details. +### Building and debugging in VS Code + +After running `Init.bat`/`Init.sh`, open [`FlingEngine.code-workspace`](FlingEngine.code-workspace) +in VS Code (install the recommended `CMake Tools` and `C/C++` extensions if prompted). The +`Run and Debug` panel has ready-made configurations — **Debug Sandbox** and **Debug FlingTests** — +that build the right target and launch it under the debugger. `Ctrl+Shift+B` builds all three +targets (`FlingEngine`, `Sandbox`, `FlingTests`); per-target build tasks are also available via +`Tasks: Run Task`. Click the build-type entry in the bottom status bar (or run `CMake: Select +Variant`) to switch between Debug, Release, RelWithDebInfo, and MinSizeRel — no need to +re-run `Init.bat`/`Init.sh`; the extension reconfigures automatically. + #### Packaging a project For ease of development and iteration the file paths to Assets (shaders, textures, models, etc) are all