From f97913f2da5b4c46056b7d16ca30a3ae7874bbf7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 20 Apr 2012 15:37:25 +0200 Subject: add $$clean_path() function just QDir::cleanPath() Change-Id: I2d51e2385939d8926c00f296537ab7f6757d9a79 Reviewed-by: Marius Storm-Olsen --- qmake/project.cpp | 10 +++++++++- tests/auto/tools/qmake/testdata/functions/functions.pro | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/qmake/project.cpp b/qmake/project.cpp index 24ea3a0257..88d55aef7f 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_SHADOWED, E_CLEAN_PATH }; QHash qmake_expandFunctions() { static QHash *qmake_expand_functions = 0; @@ -120,6 +120,7 @@ QHash 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("clean_path", E_CLEAN_PATH); } return *qmake_expand_functions; } @@ -2576,6 +2577,13 @@ QMakeProject::doProjectExpand(QString func, QList 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_CLEAN_PATH: + if (args.count() != 1) + fprintf(stderr, "%s:%d clean_path(path) requires one argument.\n", + parser.file.toLatin1().constData(), parser.line_no); + else + ret += QDir::cleanPath(args.at(0)); + break; default: { fprintf(stderr, "%s:%d: Unknown replace function: %s\n", parser.file.toLatin1().constData(), parser.line_no, diff --git a/tests/auto/tools/qmake/testdata/functions/functions.pro b/tests/auto/tools/qmake/testdata/functions/functions.pro index 2972128948..e5dde93a91 100644 --- a/tests/auto/tools/qmake/testdata/functions/functions.pro +++ b/tests/auto/tools/qmake/testdata/functions/functions.pro @@ -127,3 +127,5 @@ testReplace($$format_number(13, width=5 alwayssign), "$$spc +13", "always signed testReplace($$format_number(13, width=5 alwayssign zeropad), "+0013", "zero-padded always signed number format") testReplace($$format_number(13, width=5 padsign), " $$spc 13", "sign-padded number format") testReplace($$format_number(13, width=5 padsign zeropad), " 0013", "zero-padded sign-padded number format") + +testReplace($$clean_path("c:$${DIR_SEPARATOR}crazy//path/../trolls"), "c:/crazy/trolls", "clean_path") -- cgit v1.2.3