forked from Gaztin/premake-qmake
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqmake.lua
More file actions
86 lines (74 loc) · 1.48 KB
/
qmake.lua
File metadata and controls
86 lines (74 loc) · 1.48 KB
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
-- Fix for when the module isn't embedded
include("_preload.lua")
include("qmake_project.lua")
include("qmake_workspace.lua")
local p = premake
local qmake = p.extensions.qmake
--
-- New fields
--
p.api.register {
name = "qtmodules",
scope = "config",
kind = "list"
}
--
-- Utility functions
--
function qmake.eachconfig(prj)
local configs = {}
local function alreadyExists(cfg)
for i = 1, #configs do
if configs[i].buildcfg == cfg.buildcfg then
return true
end
end
return false
end
for cfg in p.project.eachconfig(prj) do
if not alreadyExists(cfg) then
table.insert(configs, cfg)
end
end
local i = 0
return function()
i = i + 1
return configs[i]
end
end
function qmake.pushVariable(name)
p.eol(" \\\n")
p.push('%s +=', name)
end
function qmake.popVariable()
p.pop()
p.eol("\n")
p.outln('')
end
function qmake.fileConfigs(cfg, exts)
local fconfigs = {}
local tr = p.project.getsourcetree(cfg.project)
if #tr.children > 0 then
p.tree.traverse(tr, {
onleaf = function(node)
local fcfg = p.fileconfig.getconfig(node, cfg)
if fcfg and path.hasextension(node.name, exts) then
table.insert(fconfigs, fcfg)
end
end
})
end
return fconfigs;
end
function qmake.configName(cfg)
local buildcfg = cfg.buildcfg:lower()
if buildcfg == "debug" or buildcfg == "release" then
return buildcfg
else
local debugsymbols = {
["On"] = "debug",
["Full"] = "debug",
}
return debugsymbols[cfg.symbols] or "release"
end
end