Skip to content

Commit 1d939e1

Browse files
committed
vscode debug settings
1 parent 7ddf533 commit 1d939e1

File tree

3 files changed

+149
-0
lines changed

3 files changed

+149
-0
lines changed

premake-core.code-workspace

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{
2+
"folders": [
3+
{
4+
"name": "root",
5+
"path": ".",
6+
}
7+
],
8+
"settings": {
9+
"files.exclude": {
10+
"build": true,
11+
"bin": true,
12+
"MyLocation": true,
13+
}
14+
},
15+
"tasks": {
16+
"version": "2.0.0",
17+
"tasks": [
18+
{
19+
"label": "bootstrap",
20+
"type": "shell",
21+
"windows": {
22+
"command": "Bootstrap.bat"
23+
},
24+
"linux": {
25+
"command": "make",
26+
"args": [
27+
"-f",
28+
"Bootstrap.mak",
29+
"linux",
30+
"PLATFORM=x64",
31+
"CONFIG=release"
32+
]
33+
},
34+
"osx": {
35+
"command": "make",
36+
"args": [
37+
"-f",
38+
"Bootstrap.mak",
39+
"macosx",
40+
"PLATFORM=x64",
41+
"CONFIG=release"
42+
]
43+
},
44+
"problemMatcher": []
45+
}
46+
]
47+
},
48+
"launch": {
49+
"version": "0.2.0",
50+
"configurations": [
51+
{
52+
"name": "test",
53+
"type": "lua-local",
54+
"request": "launch",
55+
"cwd": "${workspaceFolder}",
56+
"program": {
57+
"command": "bin/release/premake5",
58+
},
59+
"args": [
60+
"test",
61+
],
62+
},
63+
{
64+
"name": "test-all",
65+
"type": "lua-local",
66+
"request": "launch",
67+
"cwd": "${workspaceFolder}",
68+
"program": {
69+
"command": "bin/release/premake5"
70+
},
71+
"args": [
72+
"test",
73+
"--test-all",
74+
]
75+
},
76+
{
77+
"name": "test-only",
78+
"type": "lua-local",
79+
"request": "launch",
80+
"cwd": "${workspaceFolder}",
81+
"program": {
82+
"command": "bin/release/premake5"
83+
},
84+
"args": [
85+
"test",
86+
"--test-only=${input:test_suite_name}"
87+
],
88+
}
89+
],
90+
"inputs": [
91+
{
92+
"type": "promptString",
93+
"id": "test_suite_name",
94+
"description": "test suite name",
95+
}
96+
]
97+
},
98+
"extensions": {
99+
"recommendations": [
100+
"tomblind.local-lua-debugger-vscode",
101+
"editorconfig.editorconfig",
102+
]
103+
},
104+
}

tests/test_premake.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
-- Copyright (c) 2008-2015 Jason Perkins and the Premake project
55
--
66

7+
-- Start local lua debugger
8+
-- https://marketplace.visualstudio.com/items?itemName=tomblind.local-lua-debugger-vscode
9+
if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE") == "1" then
10+
require("lldebugger").start()
11+
end
712

813
local suite = test.declare("premake")
914

website/docs/Debugging-Scripts.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,43 @@ Since Premake's update to 5.3, the only debugger that seems to be able to debug
1212
* 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.
1313
* 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.
1414
* An example command line would be `C:/my_project_folder/premake5.exe vs2015 --scripts=C:/premake_repo/ --debugger`
15+
16+
## Visual Studio Code
17+
18+
* [Download Visual Studio Code](https://code.visualstudio.com/) and install it
19+
* Install [Local Lua Debugger](https://marketplace.visualstudio.com/items?itemName=tomblind.local-lua-debugger-vscode) plugin
20+
* Add the following text to the top of the premake5.lua file in your project.
21+
```lua
22+
if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE") == "1" then
23+
require("lldebugger").start()
24+
end
25+
```
26+
* Create `launch.json` according to the [debugger settings](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations) and modify it as follows.
27+
```json
28+
{
29+
"version": "0.2.0",
30+
"configurations": [
31+
{
32+
"name": "premake_debug",
33+
"type": "lua-local",
34+
"request": "launch",
35+
"cwd": "${workspaceFolder}",
36+
"program": {
37+
// path to premake5.exe
38+
// If you want to debug including premake5.exe internals, use debug build premake5.exe
39+
"command": "C:/my_project_folder/premake5.exe",
40+
},
41+
"args": [
42+
"vs2022",
43+
"--verbose",
44+
// path to root script file
45+
"--file=${workspaceFolder}/premake5.lua"
46+
],
47+
},
48+
]
49+
}
50+
```
51+
* Open the lua file you want to debug and [set a breakpoint](https://code.visualstudio.com/docs/editor/debugging#_breakpoints).
52+
* Open Debug Console (Press Ctrl+Shift+Y)
53+
* Press F5 key to start debugging.
54+

0 commit comments

Comments
 (0)