Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QDir::listSeparator() and make windeployqt work in linux-mingw. #63

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qmake/generators/mac/pbuilder_pbx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,7 @@ ProjectBuilderMakefileGenerator::findProgram(const ProString &prog)
{
QString ret = prog.toQString();
if(QDir::isRelativePath(ret)) {
QStringList paths = QString(qgetenv("PATH")).split(':');
QStringList paths = QString(qgetenv("PATH")).split(QDir::listSeparator());
for(int i = 0; i < paths.size(); ++i) {
QString path = paths.at(i) + "/" + prog;
if(exists(path)) {
Expand Down
4 changes: 1 addition & 3 deletions qmake/library/ioutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ QString IoUtils::binaryAbsLocation(const QString &argv0)
} else { // in the PATH
QByteArray pEnv = qgetenv("PATH");
QDir currentDir = QDir::current();
QStringList paths = QString::fromLocal8Bit(pEnv).split(QDir::listSeparator());
#ifdef Q_OS_WIN
QStringList paths = QString::fromLocal8Bit(pEnv).split(QLatin1String(";"));
paths.prepend(QLatin1String("."));
#else
QStringList paths = QString::fromLocal8Bit(pEnv).split(QLatin1String(":"));
#endif
for (QStringList::const_iterator p = paths.constBegin(); p != paths.constEnd(); ++p) {
if ((*p).isEmpty())
Expand Down
2 changes: 1 addition & 1 deletion qmake/library/qmakeevaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ static ProString msvcArchitecture(const QString &vcInstallDir, const QString &pa
QString vcBinDir = vcInstallDir;
if (vcBinDir.endsWith(QLatin1Char('\\')))
vcBinDir.chop(1);
const auto dirs = pathVar.split(QLatin1Char(';'), Qt::SkipEmptyParts);
const auto dirs = pathVar.split(QDir::listSeparator(), Qt::SkipEmptyParts);
for (const QString &dir : dirs) {
if (!dir.startsWith(vcBinDir, Qt::CaseInsensitive))
continue;
Expand Down
9 changes: 2 additions & 7 deletions qmake/library/qmakeglobals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,8 @@ QMakeGlobals::QMakeGlobals()
#ifdef PROEVALUATOR_DEBUG
debugLevel = 0;
#endif
#ifdef Q_OS_WIN
dirlist_sep = QLatin1Char(';');
dir_sep = QLatin1Char('\\');
#else
dirlist_sep = QLatin1Char(':');
dir_sep = QLatin1Char('/');
#endif
dirlist_sep = QDir::listSeparator();
dir_sep = QDir::separator();
}

QMakeGlobals::~QMakeGlobals()
Expand Down
6 changes: 3 additions & 3 deletions src/corelib/plugin/qsystemlibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,16 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect

if (!onlySystemDirectory) {
const QString PATH(QLatin1String(qgetenv("PATH").constData()));
searchOrder << PATH.split(QLatin1Char(';'), Qt::SkipEmptyParts);
searchOrder << PATH.split(QDir::listSeparator(), Qt::SkipEmptyParts);
}
QString fileName = QString::fromWCharArray(libraryName);
fileName.append(QLatin1String(".dll"));

// Start looking in the order specified
for (int i = 0; i < searchOrder.count(); ++i) {
QString fullPathAttempt = searchOrder.at(i);
if (!fullPathAttempt.endsWith(QLatin1Char('\\'))) {
fullPathAttempt.append(QLatin1Char('\\'));
if (!fullPathAttempt.endsWith(QDir::separator())) {
fullPathAttempt.append(QDir::separator());
}
fullPathAttempt.append(fileName);
HINSTANCE inst = ::LoadLibrary(reinterpret_cast<const wchar_t *>(fullPathAttempt.utf16()));
Expand Down
8 changes: 1 addition & 7 deletions src/tools/androiddeployqt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2499,13 +2499,7 @@ bool createAndroidProject(const Options &options)
QString findInPath(const QString &fileName)
{
const QString path = QString::fromLocal8Bit(qgetenv("PATH"));
#if defined(Q_OS_WIN32)
QLatin1Char separator(';');
#else
QLatin1Char separator(':');
#endif

const QStringList paths = path.split(separator);
const QStringList paths = path.split(QDir::listSeparator());
for (const QString &path : paths) {
QFileInfo fileInfo(path + QLatin1Char('/') + fileName);
if (fileInfo.exists() && fileInfo.isFile() && fileInfo.isExecutable())
Expand Down
9 changes: 6 additions & 3 deletions src/tools/windeployqt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,15 @@ static Platform platformFromMkSpec(const QString &xSpec)
{
if (xSpec == QLatin1String("linux-g++"))
return Unix;
if (xSpec.startsWith(QLatin1String("win32-"))) {
if (xSpec.startsWith(QLatin1String("win32-")) || xSpec.startsWith(QLatin1String("mingw-"))) {
if (xSpec.contains(QLatin1String("clang-g++")))
return WindowsDesktopClangMinGW;
if (xSpec.contains(QLatin1String("clang-msvc++")))
return WindowsDesktopClangMsvc;
return xSpec.contains(QLatin1String("g++")) ? WindowsDesktopMinGW : WindowsDesktopMsvc;
if (xSpec.contains(QLatin1String("g++"))
return WindowsDesktopMinGW;
if (xSpec.contains(QLatin1String("msvc++")))
return WindowsDesktopMsvc;
}
return UnknownPlatform;
}
Expand Down Expand Up @@ -1648,7 +1651,7 @@ int main(int argc, char **argv)
const QByteArray qtBinPath = QFile::encodeName(QDir::toNativeSeparators(QCoreApplication::applicationDirPath()));
QByteArray path = qgetenv("PATH");
if (!path.contains(qtBinPath)) { // QTBUG-39177, ensure Qt is in the path so that qt.conf is taken into account.
path += ';';
path += QDir::listSeparator();
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this is the BUG. THis bug fixes windeployqt under linux.

Please tell me how can I make the fix for Qt 5.15.x ? is it possible ?

path += qtBinPath;
qputenv("PATH", path);
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/windeployqt/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ QString normalizeFileName(const QString &name)
// Find a tool binary in the Windows SDK 8
QString findSdkTool(const QString &tool)
{
QStringList paths = QString::fromLocal8Bit(qgetenv("PATH")).split(QLatin1Char(';'));
QStringList paths = QString::fromLocal8Bit(qgetenv("PATH")).split(QDir::listSeparator());
const QByteArray sdkDir = qgetenv("WindowsSdkDir");
if (!sdkDir.isEmpty())
paths.prepend(QDir::cleanPath(QString::fromLocal8Bit(sdkDir)) + QLatin1String("/Tools/x64"));
Expand Down
2 changes: 1 addition & 1 deletion tests/auto/tools/windeployqt/tst_windeployqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ void tst_windeployqt::deploy()
const QString qtBinDir = QDir::toNativeSeparators(QLibraryInfo::path(QLibraryInfo::BinariesPath));
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
const QString pathKey = QLatin1String("PATH");
const QChar pathSeparator(QLatin1Char(';')); // ### fixme: Qt 5.6: QDir::listSeparator()
const QChar pathSeparator(QDir::listSeparator());
const QString origPath = env.value(pathKey);
QString newPath;
const QStringList pathElements = origPath.split(pathSeparator, Qt::SkipEmptyParts);
Expand Down