-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconfigurations.lua
160 lines (134 loc) · 4.43 KB
/
configurations.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
--
-- Copyright 2023 Milos Tosic. All rights reserved.
-- License: http://www.opensource.org/licenses/BSD-2-Clause
--
local params = { ... }
local SOURCE_FILES = params[1] or false
local IS_LIBRARY = params[2] or false
local IS_SHARED_LIBRARY = params[3] or false
local COPY_QT_DLLS = params[4] or false
local WITH_QT = params[5] or false
local EXECUTABLE = params[6] or false
local PROJECT_NAME = params[7] or project().name
dofile (RTM_SCRIPTS_DIR .. "embedded_files.lua")
dofile (RTM_SCRIPTS_DIR .. "qtpresets6.lua")
assert(loadfile(RTM_SCRIPTS_DIR .. "toolchain.lua"))( EXECUTABLE )
function setSubConfig(_platform, _configuration, _is64bit)
commonConfig(_platform, _configuration, IS_LIBRARY, IS_SHARED_LIBRARY, EXECUTABLE)
shaderConfigure(_platform, _configuration, PROJECT_NAME, shaderFiles)
local prefix = ""
if _configuration == "debug" then
prefix = "d"
end
if WITH_QT then
configuration { _configuration }
qtAddedFiles = qtConfigure(_platform, _configuration, PROJECT_NAME, mocFiles, qrcFiles, uiFiles, tsFiles, libsToLink, COPY_QT_DLLS, _is64bit, prefix )
end
if _G["projectExtraConfig_" .. project().name] then
_G["projectExtraConfig_" .. project().name]()
end
end
function setConfig(_configuration)
local currPlatforms = platforms()
for _,platform in ipairs(currPlatforms) do
setSubConfig(platform, _configuration, "x64" == platform)
end
end
local qtAddedFiles = {}
configuration {}
local all_configs = configurations()
for _,config in ipairs(all_configs) do
configuration { config }
targetsuffix ("_" .. config)
defines { ExtraDefines[config] }
flags { ExtraFlags[config] }
setConfig(config)
end
configuration {}
function vpathFilter(_string, _find)
-- lib samples
local pathPos = string.find(_string, "/samples/")
if pathPos ~= nil then
local vpath = string.sub(_string, pathPos + string.len("/samples/"), string.findlast(_string, "/"))
local replaceStart = string.find(vpath, "/")
return "src" .. string.sub(vpath, replaceStart, string.len(vpath))
end
-- lib tests
local pathPos = string.find(_string, "/test/")
if pathPos ~= nil then
local vpath = string.sub(_string, pathPos + string.len("/test/"), string.len(_string))
local slash = string.findlast(vpath, "/")
if slash ~= nil then
return "src/" .. string.sub(vpath, 1, slash)
end
return "src"
end
-- lib tools
local pathPos = string.find(_find, "_tool_")
if pathPos ~= nil then
local projectDirName = "/" .. string.sub(_find, pathPos + string.len("_tool_"), string.len(_find)) .. "/"
local vpath = string.sub(_string, string.find(_string, projectDirName) + string.len(projectDirName), string.len(_string))
local slash = string.findlast(vpath, "/")
if slash ~= nil then
return "src/" .. string.sub(vpath, 1, slash)
end
return "src"
end
--
local pos = string.find(_string, _find)
if pos ~= nil then
local rem = string.sub(_string, pos + string.len(_find) + 1)
pos = string.findlast(rem, "/")
if pos ~= nil then
return string.sub(rem, 1, pos-1)
end
end
local lsPos = string.findlast(_string, "/") - 1
local plPos = string.findlast(_string, "/", lsPos) + 1
local name = string.sub(_string, plPos, lsPos)
if name == "inc" then
return "inc"
end
return "src"
end
SOURCE_FILES = mergeTables(SOURCE_FILES, qtAddedFiles)
for _,srcFilePattern in ipairs(SOURCE_FILES) do
local srcFiles = os.matchfiles(srcFilePattern)
if string.find(srcFilePattern, "%*%*") == nil then
srcFiles = { srcFilePattern }
end
for _,srcFile in ipairs(srcFiles) do
if string.endswith(srcFile, ".ui") then
vpaths { ["qt/forms"] = srcFile }
end
if string.endswith(srcFile, ".qrc") then
vpaths { ["qt/resources"] = srcFile }
end
local filtered = false
if string.endswith(srcFile, "_ui.h") then
filtered = true
vpaths { ["qt/generated/ui"] = srcFile }
end
if string.endswith(srcFile, "_moc.cpp") then
filtered = true
vpaths { ["qt/generated/moc"] = srcFile }
end
if string.endswith(srcFile, "_qrc.cpp") then
filtered = true
vpaths { ["qt/generated/qrc"] = srcFile }
end
if string.endswith(srcFile, ".ts") then
vpaths { ["qt/translation"] = srcFile }
end
if string.endswith(srcFile, ".h") or
string.endswith(srcFile, ".hpp") or
string.endswith(srcFile, ".inl") or
string.endswith(srcFile, ".c") or
string.endswith(srcFile, ".cc") or
string.endswith(srcFile, ".cpp") then
if not filtered then
vpaths { [vpathFilter(srcFile, PROJECT_NAME)] = srcFile }
end
end
end
end