summaryrefslogtreecommitdiffstats
path: root/qmake/library/qmakeglobals.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2017-07-28 13:25:27 +0200
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2018-01-18 13:46:54 +0000
commite86f3c018833141776db2d15772ba53995656eac (patch)
tree2375bf7d4276968c783fe02e3d4482683937d194 /qmake/library/qmakeglobals.cpp
parent3149d0fb13bacc20b75ad8ca650c71df9edd8734 (diff)
qmake: require a drive in a DOS path for it to be absolute
For Q_OS_WIN, a path is only truly absolute if it includes a drive letter; merely starting with a slash is not enough. (We can't support UNC paths, so don't even try: qmake runs various commands in the source directory using CMD.exe, which doesn't support UNC as PWD.) This requires, when resolving a path relative to a root, transcribing the root's drive to such not-quite-absolute paths. Changed QMakeGlobals, $$absolute_path() and $$relative_path() to now use IoUtils::resolvePath() rather than delegating to QDir's absolute path method, since that doesn't correctly recognize the need for a drive letter (and qmake did run into problems with some paths, from splitPathList and a failing test, as a result). Moved existing ioUtils tests for handling of relative / absolute paths out into separate functions and expanded significantly. Fixed some existing tests to use an absolute path where one is needed; added two tests involving driveless (but rooted) paths; and fixed the test init to set a value for QT_HOST_DATA/src property (the lack of which lead to an assertion failure with this fix). Task-number: QTBUG-50839 Change-Id: I2bfc13c1bfbe1ae09997274622ea55cb3de31b43 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'qmake/library/qmakeglobals.cpp')
-rw-r--r--qmake/library/qmakeglobals.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/qmake/library/qmakeglobals.cpp b/qmake/library/qmakeglobals.cpp
index b6dc8b20b6..d733d479cf 100644
--- a/qmake/library/qmakeglobals.cpp
+++ b/qmake/library/qmakeglobals.cpp
@@ -68,6 +68,7 @@
#endif
QT_BEGIN_NAMESPACE
+using namespace QMakeInternal; // for IoUtils
#define fL1S(s) QString::fromLatin1(s)
@@ -96,9 +97,9 @@ QString QMakeGlobals::cleanSpec(QMakeCmdLineParserState &state, const QString &s
{
QString ret = QDir::cleanPath(spec);
if (ret.contains(QLatin1Char('/'))) {
- QString absRet = QDir(state.pwd).absoluteFilePath(ret);
+ QString absRet = IoUtils::resolvePath(state.pwd, ret);
if (QFile::exists(absRet))
- ret = QDir::cleanPath(absRet);
+ ret = absRet;
}
return ret;
}
@@ -126,10 +127,10 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments(
user_template_prefix = arg;
break;
case ArgCache:
- cachefile = args[*pos] = QDir::cleanPath(QDir(state.pwd).absoluteFilePath(arg));
+ cachefile = args[*pos] = IoUtils::resolvePath(state.pwd, arg);
break;
case ArgQtConf:
- qtconf = args[*pos] = QDir::cleanPath(QDir(state.pwd).absoluteFilePath(arg));
+ qtconf = args[*pos] = IoUtils::resolvePath(state.pwd, arg);
break;
default:
if (arg.startsWith(QLatin1Char('-'))) {
@@ -259,11 +260,11 @@ QStringList QMakeGlobals::splitPathList(const QString &val) const
{
QStringList ret;
if (!val.isEmpty()) {
- QDir bdir;
+ QString cwd(QDir::currentPath());
const QStringList vals = val.split(dirlist_sep);
ret.reserve(vals.length());
for (const QString &it : vals)
- ret << QDir::cleanPath(bdir.absoluteFilePath(it));
+ ret << IoUtils::resolvePath(cwd, it);
}
return ret;
}
@@ -318,7 +319,7 @@ bool QMakeGlobals::initProperties()
return false;
data = proc.readAll();
#else
- if (FILE *proc = QT_POPEN(QString(QMakeInternal::IoUtils::shellQuote(qmake_abslocation)
+ if (FILE *proc = QT_POPEN(QString(IoUtils::shellQuote(qmake_abslocation)
+ QLatin1String(" -query")).toLocal8Bit(), QT_POPEN_READ)) {
char buff[1024];
while (!feof(proc))