forked from MiniFalafel/premake-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvscode_tasks.lua
77 lines (61 loc) · 1.85 KB
/
vscode_tasks.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
-- TASK GENERATION
-- Aliases
local p = premake
local vscode = p.modules.vscode
-- Initialize tasks
vscode.tasks = {}
local tasks = vscode.tasks
-- Task build functions
function tasks.buildSolutionTask(wks)
local solutionFile = p.filename(wks, ".sln")
local enablePreReleases = _OPTIONS["enable_prereleases"]
local vswhere = '"C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vswhere.exe" -latest';
if enablePreReleases then
vswhere = vswhere .. ' -prerelease'
end
vswhere = vswhere .. ' -find MSBuild'
local msBuildPath, err = os.outputof(vswhere)
msBuildPath = path.normalize(path.join(msBuildPath, "Current", "Bin", "MSBuild.exe"))
for cfg in p.workspace.eachconfig(wks) do
p.push('{')
p.w('"type": "shell",')
p.w('"label": "BUILD-%s",', cfg.name)
p.w('"command": "%s",', msBuildPath)
p.w('"args": ["%s", "-p:Configuration=%s"],', solutionFile, cfg.name)
p.w('"problemMatcher": "$msCompile",')
p.w('"group": "build",')
p.pop('},')
end
end
function tasks.buildMakefileTask(wks)
for cfg in p.workspace.eachconfig(wks) do
p.push('{')
p.w('"type": "shell",')
p.w('"label": "BUILD-%s",', cfg.name)
p.w('"command": "make",')
p.w('"args": ["config=%s"],', string.lower(cfg.name))
p.w('"problemMatcher": "$gcc",')
p.w('"group": "build",')
p.pop('},')
end
end
tasks.buildTasks = function(wks)
if _TARGET_OS == "windows" then
return {
tasks.buildSolutionTask
}
else
return {
tasks.buildMakefileTask
}
end
end
-- COMBINED GENERATION
function tasks.generate(wks)
p.push('"tasks": {')
p.w('"version": "2.0.0",')
p.push('"tasks": [')
p.callArray(tasks.buildTasks, wks)
p.pop(']')
p.pop('},')
end