summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qmake/project.cpp20
-rw-r--r--tests/auto/tools/qmake/testdata/functions/functions.pro5
2 files changed, 24 insertions, 1 deletions
diff --git a/qmake/project.cpp b/qmake/project.cpp
index d4065a1450..b26796bb1c 100644
--- a/qmake/project.cpp
+++ b/qmake/project.cpp
@@ -82,7 +82,7 @@ enum ExpandFunc { E_MEMBER=1, E_FIRST, E_LAST, E_CAT, E_FROMFILE, E_EVAL, E_LIST
E_FIND, E_SYSTEM, E_UNIQUE, E_QUOTE, E_ESCAPE_EXPAND,
E_UPPER, E_LOWER, E_FILES, E_PROMPT, E_RE_ESCAPE, E_VAL_ESCAPE, E_REPLACE,
E_SIZE, E_SORT_DEPENDS, E_RESOLVE_DEPENDS, E_ENUMERATE_VARS,
- E_SHADOWED, E_CLEAN_PATH, E_NATIVE_PATH };
+ E_SHADOWED, E_ABSOLUTE_PATH, E_RELATIVE_PATH, E_CLEAN_PATH, E_NATIVE_PATH };
QHash<QString, ExpandFunc> qmake_expandFunctions()
{
static QHash<QString, ExpandFunc> *qmake_expand_functions = 0;
@@ -120,6 +120,8 @@ QHash<QString, ExpandFunc> qmake_expandFunctions()
qmake_expand_functions->insert("resolve_depends", E_RESOLVE_DEPENDS);
qmake_expand_functions->insert("enumerate_vars", E_ENUMERATE_VARS);
qmake_expand_functions->insert("shadowed", E_SHADOWED);
+ qmake_expand_functions->insert("absolute_path", E_ABSOLUTE_PATH);
+ qmake_expand_functions->insert("relative_path", E_RELATIVE_PATH);
qmake_expand_functions->insert("clean_path", E_CLEAN_PATH);
qmake_expand_functions->insert("native_path", E_NATIVE_PATH);
}
@@ -2578,6 +2580,22 @@ QMakeProject::doProjectExpand(QString func, QList<QStringList> args_list,
else if (val.startsWith(Option::mkfile::source_root))
ret += Option::mkfile::build_root + val.mid(Option::mkfile::source_root.length());
break; }
+ case E_ABSOLUTE_PATH:
+ if (args.count() > 2)
+ fprintf(stderr, "%s:%d absolute_path(path[, base]) requires one or two arguments.\n",
+ parser.file.toLatin1().constData(), parser.line_no);
+ else
+ ret += QDir::cleanPath(QDir(args.count() > 1 ? args.at(1) : QString())
+ .absoluteFilePath(args.at(0)));
+ break;
+ case E_RELATIVE_PATH:
+ if (args.count() > 2)
+ fprintf(stderr, "%s:%d relative_path(path[, base]) requires one or two arguments.\n",
+ parser.file.toLatin1().constData(), parser.line_no);
+ else
+ ret += QDir::cleanPath(QDir(args.count() > 1 ? args.at(1) : QString())
+ .relativeFilePath(args.at(0)));
+ break;
case E_CLEAN_PATH:
if (args.count() != 1)
fprintf(stderr, "%s:%d clean_path(path) requires one argument.\n",
diff --git a/tests/auto/tools/qmake/testdata/functions/functions.pro b/tests/auto/tools/qmake/testdata/functions/functions.pro
index 39ba2ac9bb..426814466d 100644
--- a/tests/auto/tools/qmake/testdata/functions/functions.pro
+++ b/tests/auto/tools/qmake/testdata/functions/functions.pro
@@ -131,3 +131,8 @@ testReplace($$format_number(13, width=5 padsign zeropad), " 0013", "zero-padded
testReplace($$clean_path("c:$${DIR_SEPARATOR}crazy//path/../trolls"), "c:/crazy/trolls", "clean_path")
testReplace($$native_path("/crazy/trolls"), "$${DIR_SEPARATOR}crazy$${DIR_SEPARATOR}trolls", "native_path")
+
+testReplace($$absolute_path("crazy/trolls"), "$$PWD/crazy/trolls", "absolute_path")
+testReplace($$absolute_path("crazy/trolls", "/fake/path"), "/fake/path/crazy/trolls", "absolute_path with base")
+testReplace($$relative_path($$_PRO_FILE_PWD_), $$basename($$_PRO_FILE_), "relative_path")
+testReplace($$relative_path("/fake/trolls", "/fake/path"), "../trolls", "relative_path with base")