add $$absolute_path() and $$relative_path()
just exposes QDir::fooFilePath() wrapped into QDir::cleanPath() Change-Id: I7a7644084825fd8092a9910ac20f695c4d9351f6 Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
This commit is contained in:
parent
d8e6c49bfa
commit
09e01856b0
@ -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",
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user