-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpremake5.lua
94 lines (85 loc) · 2.73 KB
/
premake5.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
-- Define the workspace and project name dynamically
local projectName = "cpp-project"
workspace(projectName)
configurations {"Debug", "Release"}
architecture "x64"
location "out/build"
-- Define the project using the dynamically set projectName
project(projectName)
kind "ConsoleApp"
language "C++"
targetdir "out/bin/%{cfg.buildcfg}"
objdir "out/obj/%{cfg.buildcfg}"
files {"src/**.cpp", "include/**.h"}
includedirs {"include"}
-- Debug settings
filter "configurations:Debug"
defines {"DEBUG"}
symbols "On"
-- Release settings
filter "configurations:Release"
defines {"NDEBUG"}
optimize "On"
-- Function to dynamically write the launch.json file using the projectName variable
local function writeLaunchJson()
local launchJson =
[[
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Debug",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/out/bin/Debug/]] ..
projectName ..
[[",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "just build"
},
{
"name": "Launch Release",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/out/bin/Release/]] ..
projectName ..
[[",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "just build-release"
}
]
}
]]
-- Write to the .vscode/launch.json file
local file = io.open(".vscode/launch.json", "w")
file:write(launchJson)
file:close()
end
-- Call the function to generate the dynamic launch.json with the current project name
writeLaunchJson()