summaryrefslogtreecommitdiff
path: root/src/shared/proparser/qmakebuiltins.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-03-14 15:35:34 +0000
commit912dd8df64c05fcdcbc9d862a41052654dd07546 (patch)
tree90d118cd06daeaf8f7f9e1a19e6ed47715326362 /src/shared/proparser/qmakebuiltins.cpp
parenta13776d84860e7a517d7eeb024c95c1e1a1eec21 (diff)
downloadqt-creator-912dd8df64c05fcdcbc9d862a41052654dd07546.tar.gz
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). Change-Id: I2bfc13c1bfbe1ae09997274622ea55cb3de31b43 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> (cherry picked from qtbase/e86f3c018833141776db2d15772ba53995656eac) Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/shared/proparser/qmakebuiltins.cpp')
-rw-r--r--src/shared/proparser/qmakebuiltins.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/shared/proparser/qmakebuiltins.cpp b/src/shared/proparser/qmakebuiltins.cpp
index 5bfbdca8d6..9d9afdd2af 100644
--- a/src/shared/proparser/qmakebuiltins.cpp
+++ b/src/shared/proparser/qmakebuiltins.cpp
@@ -1174,9 +1174,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
if (args.count() > 2) {
evalError(fL1S("absolute_path(path[, base]) requires one or two arguments."));
} else {
- QString rstr = QDir::cleanPath(
- QDir(args.count() > 1 ? args.at(1).toQString(m_tmp2) : currentDirectory())
- .absoluteFilePath(args.at(0).toQString(m_tmp1)));
+ QString arg = args.at(0).toQString(m_tmp1);
+ QString baseDir = args.count() > 1 ? args.at(1).toQString(m_tmp2) : currentDirectory();
+ QString rstr = arg.isEmpty() ? baseDir : IoUtils::resolvePath(baseDir, arg);
ret << (rstr.isSharedWith(m_tmp1)
? args.at(0)
: args.count() > 1 && rstr.isSharedWith(m_tmp2)
@@ -1188,9 +1188,10 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
if (args.count() > 2) {
evalError(fL1S("relative_path(path[, base]) requires one or two arguments."));
} else {
- QDir baseDir(args.count() > 1 ? args.at(1).toQString(m_tmp2) : currentDirectory());
- QString rstr = baseDir.relativeFilePath(baseDir.absoluteFilePath(
- args.at(0).toQString(m_tmp1)));
+ QString arg = args.at(0).toQString(m_tmp1);
+ QString baseDir = args.count() > 1 ? args.at(1).toQString(m_tmp2) : currentDirectory();
+ QString absArg = arg.isEmpty() ? baseDir : IoUtils::resolvePath(baseDir, arg);
+ QString rstr = QDir(baseDir).relativeFilePath(absArg);
ret << (rstr.isSharedWith(m_tmp1) ? args.at(0) : ProString(rstr).setSource(args.at(0)));
}
break;