diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2012-04-05 12:45:23 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2012-06-19 16:39:55 +0200 |
commit | 7da934d7768f425370b2de7c380bad481ecc65a6 (patch) | |
tree | 816199ca0d29314337d39efdd806ebbddde6ab22 | |
parent | b5003978090da3fa6056873013f814a650b20f7a (diff) |
add mkpath() function
Change-Id: I8809b9ee4e85fbe8cec95641d659f237c5f51a26
Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
-rw-r--r-- | qmake/project.cpp | 16 | ||||
-rw-r--r-- | tests/auto/tools/qmake/testdata/functions/functions.pro | 4 |
2 files changed, 19 insertions, 1 deletions
diff --git a/qmake/project.cpp b/qmake/project.cpp index 2aebd1e140..2a7094376f 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -124,7 +124,7 @@ enum TestFunc { T_REQUIRES=1, T_GREATERTHAN, T_LESSTHAN, T_EQUALS, T_RETURN, T_BREAK, T_NEXT, T_DEFINED, T_CONTAINS, T_INFILE, T_COUNT, T_ISEMPTY, T_INCLUDE, T_LOAD, T_DEBUG, T_ERROR, T_MESSAGE, T_WARNING, T_LOG, - T_IF, T_OPTION, T_CACHE, T_WRITE_FILE, T_TOUCH }; + T_IF, T_OPTION, T_CACHE, T_MKPATH, T_WRITE_FILE, T_TOUCH }; QHash<QString, TestFunc> qmake_testFunctions() { static QHash<QString, TestFunc> *qmake_test_functions = 0; @@ -161,6 +161,7 @@ QHash<QString, TestFunc> qmake_testFunctions() qmake_test_functions->insert("log", T_LOG); qmake_test_functions->insert("option", T_OPTION); qmake_test_functions->insert("cache", T_CACHE); + qmake_test_functions->insert("mkpath", T_MKPATH); qmake_test_functions->insert("write_file", T_WRITE_FILE); qmake_test_functions->insert("touch", T_TOUCH); } @@ -3074,6 +3075,19 @@ QMakeProject::doProjectTest(QString func, QList<QStringList> args_list, QHash<QS #endif } return true; } + case T_MKPATH: + if (args.count() != 1) { + fprintf(stderr, "%s:%d: mkpath(name) requires one argument.\n", + parser.file.toLatin1().constData(), parser.line_no); + return false; + } + if (!QDir::current().mkpath(args.at(0))) { + fprintf(stderr, "%s:%d: ERROR creating directory %s\n", + parser.file.toLatin1().constData(), parser.line_no, + QDir::toNativeSeparators(args.at(0)).toLatin1().constData()); + return false; + } + return true; case T_WRITE_FILE: { if (args.count() > 3) { fprintf(stderr, "%s:%d: write_file(name, [content var, [append]]) requires one to three arguments.\n", diff --git a/tests/auto/tools/qmake/testdata/functions/functions.pro b/tests/auto/tools/qmake/testdata/functions/functions.pro index 1da7fd923b..219e683e1f 100644 --- a/tests/auto/tools/qmake/testdata/functions/functions.pro +++ b/tests/auto/tools/qmake/testdata/functions/functions.pro @@ -99,3 +99,7 @@ write_file($$fn, mooadd, append)|message("FAILED: write_file() failed (append)") moo += $$mooadd mooout = $$cat($$fn, line) equals(moo, $$mooout)|message("FAILED: write_file() wrote something wrong when appending") + +pn = $$OUT_PWD/testpath/subdir +mkpath($$pn)|message("FAILED: mkpath() failed") +exists($$pn)|message("FAILED: mkpath() didn't create anything") |