diff --git a/premake-core.code-workspace b/premake-core.code-workspace new file mode 100644 index 0000000000..a7ae076b5c --- /dev/null +++ b/premake-core.code-workspace @@ -0,0 +1,118 @@ +{ + "folders": [ + { + "name": "root", + "path": ".", + } + ], + "settings": { + "files.exclude": { + "build": true, + "bin": true, + "MyLocation": true, + } + }, + "tasks": { + "version": "2.0.0", + "tasks": [ + { + "label": "bootstrap", + "type": "shell", + "windows": { + "command": "Bootstrap.bat", + }, + "linux": { + "command": "make", + "args": [ + "-f", + "Bootstrap.mak", + "linux", + "PLATFORM=x64", + "CONFIG=release", + ] + }, + "osx": { + "command": "make", + "args": [ + "-f", + "Bootstrap.mak", + "macosx", + "PLATFORM=x64", + "CONFIG=release", + ] + }, + "group": { + "kind": "build", + }, + "problemMatcher": [] + }, + { + "label": "open", + "type": "shell", + "windows": { + "command": "C:/Program Files (x86)/Common Files/Microsoft Shared/MSEnv/VSLauncher.exe", + "args": [ + "build/bootstrap/Premake5.sln", + ] + }, + "problemMatcher": [] + } + ] + }, + "launch": { + "version": "0.2.0", + "configurations": [ + { + "name": "test", + "type": "lua-local", + "request": "launch", + "cwd": "${workspaceFolder}", + "program": { + "command": "bin/release/premake5", + }, + "args": [ + "test", + ] + }, + { + "name": "test-all", + "type": "lua-local", + "request": "launch", + "cwd": "${workspaceFolder}", + "program": { + "command": "bin/release/premake5", + }, + "args": [ + "test", + "--test-all", + ] + }, + { + "name": "test-only", + "type": "lua-local", + "request": "launch", + "cwd": "${workspaceFolder}", + "program": { + "command": "bin/release/premake5", + }, + "args": [ + "test", + "--test-only=${input:test_suite_name}", + ] + } + ], + "inputs": [ + { + "type": "promptString", + "id": "test_suite_name", + "description": "test suite name", + } + ] + }, + "extensions": { + "recommendations": [ + "tomblind.local-lua-debugger-vscode", + "editorconfig.editorconfig", + ] + }, +} diff --git a/tests/test_premake.lua b/tests/test_premake.lua index 5eec58a07d..3e877e3a7b 100644 --- a/tests/test_premake.lua +++ b/tests/test_premake.lua @@ -4,6 +4,11 @@ -- Copyright (c) 2008-2015 Jason Perkins and the Premake project -- +-- Start local lua debugger +-- https://marketplace.visualstudio.com/items?itemName=tomblind.local-lua-debugger-vscode +if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE") == "1" then + require("lldebugger").start() +end local suite = test.declare("premake") diff --git a/website/docs/Debugging-Scripts.md b/website/docs/Debugging-Scripts.md index 61baf16de8..f36712d4e4 100644 --- a/website/docs/Debugging-Scripts.md +++ b/website/docs/Debugging-Scripts.md @@ -12,3 +12,43 @@ Since Premake's update to 5.3, the only debugger that seems to be able to debug * There's also a Project tab. Right-click the root folder and select **Project Directory > Choose...** to select the root of the premake repository. Open the lua file you want to debug (you can start with _premake_init.lua) and set a breakpoint. * Run premake with your desired command line and append `--scripts=path_to_premake --debugger` path_to_premake is the root of the repository where src lives. This isn't necessary if you run premake in the same directory as the src folder. If all goes well premake should think for a moment and the debugger should flash indicating that it has broken execution. * An example command line would be `C:/my_project_folder/premake5.exe vs2015 --scripts=C:/premake_repo/ --debugger` + +## Visual Studio Code + +* [Download Visual Studio Code](https://code.visualstudio.com/) and install it +* Install [Local Lua Debugger](https://marketplace.visualstudio.com/items?itemName=tomblind.local-lua-debugger-vscode) plugin +* Add the following text to the top of the premake5.lua file in your project. +```lua +if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE") == "1" then + require("lldebugger").start() +end +``` +* Create `launch.json` according to the [debugger settings](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations) and modify it as follows. +```json +{ + "version": "0.2.0", + "configurations": [ + { + "name": "premake_debug", + "type": "lua-local", + "request": "launch", + "cwd": "${workspaceFolder}", + "program": { + // path to premake5.exe + // If you want to debug including premake5.exe internals, use debug build premake5.exe + "command": "C:/my_project_folder/premake5.exe", + }, + "args": [ + "vs2022", + "--verbose", + // path to root script file + "--file=${workspaceFolder}/premake5.lua" + ], + }, + ] +} +``` +* Open the lua file you want to debug and [set a breakpoint](https://code.visualstudio.com/docs/editor/debugging#_breakpoints). +* Open Debug Console (Press Ctrl+Shift+Y) +* Press F5 key to start debugging. +