Skip to content

Commit d0ddad6

Browse files
committed
Replace INCLUDE by PYTHONQT_INCLUDE env var
- avoids accidental inclusion of system-defined include dirs
1 parent 47a0cf4 commit d0ddad6

File tree

3 files changed

+28
-21
lines changed

3 files changed

+28
-21
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,6 @@ jobs:
323323
run: |
324324
cd generator
325325
set QTDIR=%Qt5_Dir%
326-
set INCLUDE=
327326
pythonqt_generator
328327
329328
- name: Upload Wrappers

.github/workflows/build_latest.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ jobs:
7979
shell: bash
8080
run: |
8181
cd generator
82-
unset INCLUDE
8382
if [[ ${{ matrix.os }} == 'windows' && ${{ matrix.qt-version }} =~ '5.1' ]]; then export QTDIR=$Qt5_Dir; fi
8483
UBSAN_OPTIONS="halt_on_error=1" \
8584
ASAN_OPTIONS="detect_leaks=0:detect_stack_use_after_return=1:fast_unwind_on_malloc=0" \

generator/main.cpp

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,37 @@ namespace
6666
QStringList includes;
6767
includes << QString(".");
6868

69-
#if defined(Q_OS_WIN32)
70-
const char *path_splitter = ";";
71-
#else
72-
const char *path_splitter = ":";
73-
#endif
69+
QChar pathSplitter = QDir::listSeparator();
7470

75-
// Environment INCLUDE
76-
QString includePath = getenv("INCLUDE");
71+
// Environment PYTHONQT_INCLUDE
72+
QString includePath = getenv("PYTHONQT_INCLUDE");
7773
if (!includePath.isEmpty())
78-
includes += includePath.split(path_splitter);
74+
includes += includePath.split(pathSplitter, Qt::SkipEmptyParts);
7975

8076
// Includes from the command line
8177
if (!commandLineIncludes.isEmpty())
82-
includes += commandLineIncludes.split(path_splitter);
78+
includes += commandLineIncludes.split(pathSplitter, Qt::SkipEmptyParts);
79+
for (auto it = includes.begin(); it != includes.end();)
80+
{
81+
if (!QDir(*it).exists())
82+
{
83+
qWarning("Include path %s does not exist, ignoring it.", it->toUtf8().constData());
84+
it = includes.erase(it);
85+
}
86+
else
87+
{
88+
++it;
89+
}
90+
}
8391

8492
// Include Qt
85-
QString qtdir = getenv ("QTDIR");
86-
if (qtdir.isEmpty()) {
93+
QString qtdir = getenv("QTDIR");
94+
if (qtdir.isEmpty() || !QDir(qtdir).exists(qtdir))
95+
{
96+
QString reason = "The QTDIR environment variable " + qtdir.isEmpty() ?
97+
"is not set. " : "points to a non-existing directory. ";
8798
#if defined(Q_OS_MAC)
88-
qWarning("QTDIR environment variable not set. Assuming standard binary install using frameworks.");
99+
qWarning((reason + "Assuming standard binary install using frameworks.").toUtf8().constData());
89100
QString frameworkDir = "/Library/Frameworks";
90101
includes << (frameworkDir + "/QtXml.framework/Headers");
91102
includes << (frameworkDir + "/QtNetwork.framework/Headers");
@@ -94,9 +105,11 @@ namespace
94105
includes << (frameworkDir + "/QtOpenGL.framework/Headers");
95106
includes << frameworkDir;
96107
#else
97-
qWarning("QTDIR environment variable not set. This may cause problems with finding the necessary include files.");
108+
qWarning((reason + "This may cause problems with finding the necessary include files.").toUtf8().constData());
98109
#endif
99-
} else {
110+
}
111+
else
112+
{
100113
std::cout << "-------------------------------------------------------------" << std::endl;
101114
std::cout << "Using QT at: " << qtdir.toLocal8Bit().constData() << std::endl;
102115
std::cout << "-------------------------------------------------------------" << std::endl;
@@ -353,11 +366,7 @@ int main(int argc, char *argv[])
353366

354367

355368
void displayHelp(GeneratorSet* generatorSet) {
356-
#if defined(Q_OS_WIN32)
357-
char path_splitter = ';';
358-
#else
359-
char path_splitter = ':';
360-
#endif
369+
const auto path_splitter = QDir::listSeparator().toLatin1();
361370
printf("Usage:\n generator [options] header-file typesystem-file\n\n");
362371
printf("Available options:\n\n");
363372
printf("General:\n");

0 commit comments

Comments
 (0)