Skip to content

Commit 2201d5e

Browse files
committed
* fix build using Qt IDE installed via aqt
- use crash reporter on release build only
1 parent 03240ab commit 2201d5e

5 files changed

Lines changed: 76 additions & 40 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ assert.log
4949
/Prj/Qt**
5050
/Prj/Build**
5151
/Scripts/premake5**
52+
/Qt
5253
/Qt**

Prj/premake5.lua

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,22 +118,35 @@ project "iDebugTool"
118118
"Iphlpapi",
119119
"Ws2_32",
120120
"Ole32",
121-
"Dbghelp",
122-
"exchndl",
123121
"mingw-patch",
124122
}
125-
libdirs
126-
{
127-
"../Prebuilt/drmingw-win64/lib",
128-
}
129123
includedirs
130124
{
131-
"../Prebuilt/drmingw-win64/include",
132125
"../Externals/mingw-patch",
133126
}
134-
local drmingw = "$$PWD/../../../Prebuilt/drmingw-win64/bin"
135-
prelinkcommands {"python " .. copyext .. " mgwhelp.dll " .. drmingw .. " " .. copydst}
136-
prelinkcommands {"python " .. copyext .. " exchndl.dll " .. drmingw .. " " .. copydst}
127+
128+
filter {"Release*"}
129+
defines
130+
{
131+
"MINGW_REPORTER",
132+
}
133+
links
134+
{
135+
"Dbghelp",
136+
"exchndl",
137+
}
138+
libdirs
139+
{
140+
"../Prebuilt/drmingw-win64/lib",
141+
}
142+
includedirs
143+
{
144+
"../Prebuilt/drmingw-win64/include",
145+
}
146+
local drmingw = "$$PWD/../../../Prebuilt/drmingw-win64/bin"
147+
prelinkcommands {"python " .. copyext .. " mgwhelp.dll " .. drmingw .. " " .. copydst}
148+
prelinkcommands {"python " .. copyext .. " exchndl.dll " .. drmingw .. " " .. copydst}
149+
filter {}
137150
else
138151
links
139152
{

Prj/qt.lua

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ function qt.parse_links(prj)
118118
table.insert(links["Common"], link)
119119
end
120120
end
121+
122+
-- for precompiled
123+
for cfg in project.eachconfig(prj) do
124+
local filtered_links = qt.remove_item_by_list(cfg.links, prj.links)
125+
if #filtered_links > 0 then
126+
for _,link in ipairs(filtered_links) do
127+
table.insert(links[cfg.buildcfg], link)
128+
end
129+
end
130+
end
121131
end
122132

123133
function qt.add_links(tab, datatable)
@@ -137,19 +147,22 @@ function qt.add_libdirs(tab, datatable, prj)
137147
if #datatable > 0 then
138148
_p(tab, 'LIBS += \\')
139149
for k,v in ipairs(datatable) do
140-
local relative_str = path.getrelative(prj.location .. "/" .. prj.name, v)
150+
-- Currently, qmake unstable for libdirs using relative path
151+
local relative_str = v -- path.getrelative(prj.location .. "/" .. prj.name, v)
141152
if k ~= #datatable then
142153
relative_str = relative_str .. ' \\'
143154
end
144155
_p(tab + 1, '-L' .. relative_str)
156+
145157
end
146158
_p('')
147159
end
148160
end
149161

150162
function qt.add_targetdir(tab, prj)
151163
if prj.targetdir then
152-
local relative_str = path.getrelative(prj.location .. "/" .. prj.name, prj.targetdir)
164+
-- unstable relative path beetween ide and cli
165+
local relative_str = prj.targetdir -- path.getrelative(prj.location .. "/" .. prj.name, prj.targetdir)
153166
_p(tab, 'DESTDIR = ' .. relative_str)
154167
end
155168
end
@@ -168,6 +181,19 @@ function qt.get_targetname(prj)
168181
return outname
169182
end
170183

184+
function qt.add_commands(tab, flagname, datatable)
185+
if #datatable > 0 then
186+
_p(tab, flagname .. ' += \\')
187+
for k,v in ipairs(datatable) do
188+
if k ~= #datatable then
189+
v = v .. ' && \\'
190+
end
191+
_p(tab + 1, v)
192+
end
193+
_p('')
194+
end
195+
end
196+
171197
function qt.remove_item_by_list(full_table, remove_list)
172198
for i=1, #full_table do
173199
for k,v in ipairs(full_table) do
@@ -285,28 +311,9 @@ function qt.project_pro(prj)
285311
end
286312
_p('')
287313
end
288-
289-
if #prj.prelinkcommands > 0 then
290-
_p('QMAKE_PRE_LINK += \\')
291-
for k,v in ipairs(prj.prelinkcommands) do
292-
if k ~= #prj.prelinkcommands then
293-
v = v .. ' &&\\'
294-
end
295-
_p(1, v)
296-
end
297-
_p('')
298-
end
299-
300-
if #prj.postbuildcommands > 0 then
301-
_p('QMAKE_POST_LINK += \\')
302-
for k,v in ipairs(prj.postbuildcommands) do
303-
if k ~= #prj.postbuildcommands then
304-
v = v .. ' \\'
305-
end
306-
_p(1, v)
307-
end
308-
_p('')
309-
end
314+
315+
qt.add_commands(0, 'QMAKE_PRE_LINK', prj.prelinkcommands)
316+
qt.add_commands(0, 'QMAKE_POST_LINK', prj.postbuildcommands)
310317

311318
-- links
312319
qt.parse_links(prj)
@@ -346,6 +353,12 @@ function qt.project_pro(prj)
346353

347354
local includedirs = qt.remove_item_by_list(cfg.includedirs, prj.includedirs)
348355
qt.add_includedirs(1, includedirs, cfg)
356+
357+
local prelinkcommands = qt.remove_item_by_list(cfg.prelinkcommands, prj.prelinkcommands)
358+
qt.add_commands(1, 'QMAKE_PRE_LINK', prelinkcommands)
359+
360+
local postbuildcommands = qt.remove_item_by_list(cfg.postbuildcommands, prj.postbuildcommands)
361+
qt.add_commands(1, 'QMAKE_POST_LINK', postbuildcommands)
349362
_p('}')
350363
_p('')
351364
end

Scripts/make.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def Premake():
206206
def InstallAQT():
207207
global qt_dir
208208
qt_platform = "linux" if "linux" in sys.platform else "windows"
209-
qt_dir = os.path.abspath(base_dir + "/Qt/")
209+
qt_dir = os.path.abspath("{}/Qt_{}/".format(base_dir, qt_platform))
210210
qt_list = os.listdir(qt_dir) if os.path.exists(qt_dir) else {}
211211
if qt_version not in qt_list:
212212
utils.call([sys.executable, "-m", "pip", "install", "aqtinstall"], base_dir)
@@ -220,11 +220,19 @@ def InstallAQT():
220220
if (compiler_name + nodotversion.replace(".","") + "_" + compiler_arch) not in qt_list and "linux" not in sys.platform:
221221
utils.call([sys.executable, "-m", "aqt", "install-tool", qt_platform, "desktop", aqt_compiler, "--outputdir", qt_dir], base_dir)
222222
if is_aqtcreator and "QtCreator" not in qt_list:
223-
utils.call([sys.executable, "-m", "aqt", "install-tool", qt_platform, "desktop", "tools_" + aqt_creator, "qt.tools." + aqt_creator, "--outputdir", qt_dir], base_dir)
223+
qtcreator_dir = os.path.abspath(qt_dir + "/Tools/QtCreator/")
224+
utils.call([sys.executable, "-m", "aqt", "install-tool", qt_platform, "desktop", "tools_" + aqt_creator, "qt.tools." + aqt_creator, "--outputdir", qt_dir if "linux" in sys.platform else qtcreator_dir], base_dir)
224225
if "linux" not in sys.platform:
225226
utils.call([sys.executable, "-m", "aqt", "install-tool", qt_platform, "desktop", "tools_" + aqt_creator, "qt.tools.qtcreatorcdbext", "--outputdir", qt_dir], base_dir)
226227

227228

229+
def SetupBuildEnvironment():
230+
nodotversion = compiler_version
231+
compiler_dir = qt_dir + "/Tools/" + compiler_name + nodotversion.replace(".","") + "_" + compiler_arch + "/bin/"
232+
split = [ x for x in os.environ["PATH"].split(os.pathsep) if "mingw" not in x ]
233+
os.environ["PATH"] = os.pathsep.join(split) + os.pathsep + os.pathsep.join([os.path.abspath(compiler_dir)])
234+
235+
228236
def Build():
229237
cprint("Build '"+ prj_type + "' started...", 'yellow', attrs=['reverse', 'blink'])
230238
prj_path = prj_dir + "/" + prj_type + "/" + prj_name + ".pro"
@@ -235,7 +243,7 @@ def Build():
235243
compiler_dir = qt_dir + "/Tools/" + compiler_name + nodotversion.replace(".","") + "_" + compiler_arch + "/bin/"
236244
make_path = ("make" if "linux" in sys.platform else (compiler_dir + "mingw32-make")) + exe_ext
237245
build_final = build_dir + "/" + prj_type + "/bin/"
238-
os.environ["PATH"] += os.pathsep + os.pathsep.join([compiler_dir])
246+
SetupBuildEnvironment()
239247

240248
cprint("Generate makefile from qmake...", 'yellow', attrs=['reverse', 'blink'])
241249
if not os.path.exists(build_cache):
@@ -301,7 +309,8 @@ def OpenCreator():
301309
nodotversion = compiler_version
302310
mingw_dir = qt_dir + "/Tools/" + compiler_name + nodotversion.replace(".","") + "_" + compiler_arch + "/bin"
303311
os.environ["PATH"] += os.pathsep + os.pathsep.join([mingw_dir])
304-
312+
313+
SetupBuildEnvironment()
305314
utils.call([CreatorPath, prj_path], base_dir)
306315

307316

Src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#include "mainwindow.h"
22
#include <QApplication>
33
#include <QMessageBox>
4-
#if defined(WIN32)
4+
#if defined(MINGW_REPORTER)
55
#include "exchndl.h"
66
#include "utils.h"
77
#endif
88

99
int main(int argc, char *argv[])
1010
{
1111
QApplication a(argc, argv);
12-
#if defined(WIN32)
12+
#if defined(MINGW_REPORTER)
1313
QString filename = QCoreApplication::applicationName() + "_CrashReports.txt";
1414
CheckDrMinGWReports(filename, [](QString filepath, int count){
1515
QString message = QString("Sorry, %1 has crashed in %2 time(s). A log file was written to:\n\n%3\n\n").arg(QCoreApplication::applicationName()).arg(count).arg(filepath);

0 commit comments

Comments
 (0)