Skip to content

Commit

Permalink
vscode debug settings
Browse files Browse the repository at this point in the history
  • Loading branch information
hanagasira committed Apr 20, 2023
1 parent 7ddf533 commit 076fc61
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 0 deletions.
104 changes: 104 additions & 0 deletions premake-core.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"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",
]
},
"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",
]
},
}
5 changes: 5 additions & 0 deletions tests/test_premake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
40 changes: 40 additions & 0 deletions website/docs/Debugging-Scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 076fc61

Please sign in to comment.