From 57ca8d2698f1eaf30f1110ba47445c04d2bcd0f7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 11 Dec 2015 12:08:47 +0100 Subject: make write_file() capable of making files (not) executable Change-Id: I9ca96bc3408160261781697a3471c1f446c86c3a Reviewed-by: Joerg Bornemann --- qmake/library/qmakebuiltins.cpp | 27 +++++++++++++++++++-------- qmake/library/qmakeevaluator.h | 2 +- qmake/library/qmakevfs.cpp | 17 ++++++++++++++--- qmake/library/qmakevfs.h | 2 +- 4 files changed, 35 insertions(+), 13 deletions(-) (limited to 'qmake') diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index f57d9c89a7..e8be2f42fd 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -358,10 +358,10 @@ static QMakeEvaluator::VisitReturn parseJsonInto(const QByteArray &json, const Q QMakeEvaluator::VisitReturn QMakeEvaluator::writeFile(const QString &ctx, const QString &fn, QIODevice::OpenMode mode, - const QString &contents) + bool exe, const QString &contents) { QString errStr; - if (!m_vfs->writeFile(fn, mode, contents, &errStr)) { + if (!m_vfs->writeFile(fn, mode, exe, contents, &errStr)) { evalError(fL1S("Cannot write %1file %2: %3") .arg(ctx, QDir::toNativeSeparators(fn), errStr)); return ReturnFalse; @@ -1543,22 +1543,33 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( } case T_WRITE_FILE: { if (args.count() > 3) { - evalError(fL1S("write_file(name, [content var, [append]]) requires one to three arguments.")); + evalError(fL1S("write_file(name, [content var, [append] [exe]]) requires one to three arguments.")); return ReturnFalse; } QIODevice::OpenMode mode = QIODevice::Truncate; + bool exe = false; QString contents; if (args.count() >= 2) { const ProStringList &vals = values(args.at(1).toKey()); if (!vals.isEmpty()) contents = vals.join(QLatin1Char('\n')) + QLatin1Char('\n'); - if (args.count() >= 3) - if (!args.at(2).toQString(m_tmp1).compare(fL1S("append"), Qt::CaseInsensitive)) - mode = QIODevice::Append; + if (args.count() >= 3) { + foreach (const ProString &opt, split_value_list(args.at(2).toQString(m_tmp2))) { + opt.toQString(m_tmp3); + if (m_tmp3 == QLatin1String("append")) { + mode = QIODevice::Append; + } else if (m_tmp3 == QLatin1String("exe")) { + exe = true; + } else { + evalError(fL1S("write_file(): invalid flag %1.").arg(m_tmp3)); + return ReturnFalse; + } + } + } } QString path = resolvePath(args.at(0).toQString(m_tmp1)); path.detach(); // make sure to not leak m_tmp1 into the map of written files. - return writeFile(QString(), path, mode, contents); + return writeFile(QString(), path, mode, exe, contents); } case T_TOUCH: { if (args.count() != 2) { @@ -1769,7 +1780,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( valuesRef(ProKey("_QMAKE_STASH_")) << ProString(fn); } } - return writeFile(fL1S("cache "), fn, QIODevice::Append, varstr); + return writeFile(fL1S("cache "), fn, QIODevice::Append, false, varstr); } default: evalError(fL1S("Function '%1' is not implemented.").arg(function.toQString(m_tmp1))); diff --git a/qmake/library/qmakeevaluator.h b/qmake/library/qmakeevaluator.h index 8995d49582..b61c066193 100644 --- a/qmake/library/qmakeevaluator.h +++ b/qmake/library/qmakeevaluator.h @@ -235,7 +235,7 @@ public: QMultiMap &rootSet) const; VisitReturn writeFile(const QString &ctx, const QString &fn, QIODevice::OpenMode mode, - const QString &contents); + bool exe, const QString &contents); #ifndef QT_BOOTSTRAPPED void runProcess(QProcess *proc, const QString &command) const; #endif diff --git a/qmake/library/qmakevfs.cpp b/qmake/library/qmakevfs.cpp index 613e4e90d7..d23d1f06ff 100644 --- a/qmake/library/qmakevfs.cpp +++ b/qmake/library/qmakevfs.cpp @@ -52,8 +52,8 @@ QMakeVfs::QMakeVfs() { } -bool QMakeVfs::writeFile(const QString &fn, QIODevice::OpenMode mode, const QString &contents, - QString *errStr) +bool QMakeVfs::writeFile(const QString &fn, QIODevice::OpenMode mode, bool exe, + const QString &contents, QString *errStr) { #ifndef PROEVALUATOR_FULL # ifdef PROEVALUATOR_THREAD_SAFE @@ -75,8 +75,16 @@ bool QMakeVfs::writeFile(const QString &fn, QIODevice::OpenMode mode, const QStr QByteArray bytes = contents.toLocal8Bit(); QFile cfile(fn); if (!(mode & QIODevice::Append) && cfile.open(QIODevice::ReadOnly | QIODevice::Text)) { - if (cfile.readAll() == bytes) + if (cfile.readAll() == bytes) { + if (exe) { + cfile.setPermissions(cfile.permissions() + | QFile::ExeUser | QFile::ExeGroup | QFile::ExeOther); + } else { + cfile.setPermissions(cfile.permissions() + & ~(QFile::ExeUser | QFile::ExeGroup | QFile::ExeOther)); + } return true; + } cfile.close(); } if (!cfile.open(mode | QIODevice::WriteOnly | QIODevice::Text)) { @@ -89,6 +97,9 @@ bool QMakeVfs::writeFile(const QString &fn, QIODevice::OpenMode mode, const QStr *errStr = cfile.errorString(); return false; } + if (exe) + cfile.setPermissions(cfile.permissions() + | QFile::ExeUser | QFile::ExeGroup | QFile::ExeOther); return true; #endif } diff --git a/qmake/library/qmakevfs.h b/qmake/library/qmakevfs.h index 8eeae15dcc..1bc11d3593 100644 --- a/qmake/library/qmakevfs.h +++ b/qmake/library/qmakevfs.h @@ -52,7 +52,7 @@ class QMAKE_EXPORT QMakeVfs public: QMakeVfs(); - bool writeFile(const QString &fn, QIODevice::OpenMode mode, const QString &contents, QString *errStr); + bool writeFile(const QString &fn, QIODevice::OpenMode mode, bool exe, const QString &contents, QString *errStr); bool readFile(const QString &fn, QString *contents, QString *errStr); bool exists(const QString &fn); -- cgit v1.2.3 From 75e45cc2df06e9d85f4646146b34f8baf945ad03 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 7 Jan 2015 09:30:52 +0100 Subject: Add missing includes. After 90e7cc172a7521396bb2d49720ee4ceb9a9390b3, QStringList no longer includes QDataStream. This also reverts commit c1be0fbe7d17b67c330c0c90eb9ba8a0536c2121, which did the same in a worse way. Change-Id: Ib10622b0da3b3450d29fc65dc5356fde75444a8f Reviewed-by: Olivier Goffart (cherry picked from qttools/376501ae5a86859821c0e89b2e8fbc9906d11e07) Reviewed-by: Friedemann Kleint --- qmake/library/qmakeevaluator.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'qmake') diff --git a/qmake/library/qmakeevaluator.h b/qmake/library/qmakeevaluator.h index b61c066193..0a653ad664 100644 --- a/qmake/library/qmakeevaluator.h +++ b/qmake/library/qmakeevaluator.h @@ -41,7 +41,6 @@ #include "qmakeparser.h" #include "ioutils.h" -#include #include #include #include @@ -52,6 +51,8 @@ #include #ifndef QT_BOOTSTRAPPED # include +#else +# include #endif #ifdef PROEVALUATOR_THREAD_SAFE # include -- cgit v1.2.3 From 86b2b5319d6654f6bc51e8b561c160eba39202a0 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 2 Sep 2013 16:52:47 +0200 Subject: make CONFIG feature evaluation failure non-fatal in cumulative mode while we evaluate the features themselves in precise mode (which is the reason why they can error out), we do not want them to terminate cumulative project evaluation. Change-Id: I70f3e1bcb2ca04a70c74ff484749ca92c1cf6372 Reviewed-by: hjk Reviewed-by: Oswald Buddenhagen (cherry picked from qttools/90ee4094161b427c32581bca2f5286edb4fffdb1) Reviewed-by: Joerg Bornemann --- qmake/library/qmakeevaluator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qmake') diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index e220d59517..4c5ce2e097 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -1306,7 +1306,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateConfigFeatures() config.detach(); processed.insert(config); VisitReturn vr = evaluateFeatureFile(config, true); - if (vr == ReturnError) + if (vr == ReturnError && !m_cumulative) return vr; if (vr == ReturnTrue) { finished = false; -- cgit v1.2.3 From e5f3b653f0f5c7214041654e2132ac0781258499 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 2 Sep 2013 16:43:49 +0200 Subject: add enablers for printing project errors in cumulative mode this doesn't actually do anything in qmake. Change-Id: Ia14953a5a9dc31af56ad6c338017dd5b85bb4494 Reviewed-by: hjk Reviewed-by: Oswald Buddenhagen (cherry picked from qttools/08d0cb6f8e90a818bf6d3bec7a6d00f16419b8c0) Reviewed-by: Joerg Bornemann --- qmake/library/qmakebuiltins.cpp | 8 ++++++-- qmake/library/qmakeevaluator.h | 4 +++- qmake/library/qmakeparser.h | 5 +++-- qmake/option.cpp | 3 ++- qmake/option.h | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) (limited to 'qmake') diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index e8be2f42fd..02cd8a2760 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -1470,8 +1470,12 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional( fputs(msg.toLatin1().constData(), stderr); #endif } else { - m_handler->fileMessage(fL1S("Project %1: %2") - .arg(function.toQString(m_tmp1).toUpper(), msg)); + m_handler->fileMessage( + (func_t == T_ERROR ? QMakeHandler::ErrorMessage : + func_t == T_WARNING ? QMakeHandler::WarningMessage : + QMakeHandler::InfoMessage) + | (m_cumulative ? QMakeHandler::CumulativeEvalMessage : 0), + fL1S("Project %1: %2").arg(function.toQString(m_tmp1).toUpper(), msg)); } } return (func_t == T_ERROR && !m_cumulative) ? ReturnError : ReturnTrue; diff --git a/qmake/library/qmakeevaluator.h b/qmake/library/qmakeevaluator.h index 0a653ad664..9560f71587 100644 --- a/qmake/library/qmakeevaluator.h +++ b/qmake/library/qmakeevaluator.h @@ -68,6 +68,8 @@ public: enum { SourceEvaluator = 0x10, + CumulativeEvalMessage = 0x1000, + EvalWarnLanguage = SourceEvaluator | WarningMessage | WarnLanguage, EvalWarnDeprecated = SourceEvaluator | WarningMessage | WarnDeprecated, @@ -75,7 +77,7 @@ public: }; // error(), warning() and message() from .pro file - virtual void fileMessage(const QString &msg) = 0; + virtual void fileMessage(int type, const QString &msg) = 0; enum EvalFileType { EvalProjectFile, EvalIncludeFile, EvalConfigFile, EvalFeatureFile, EvalAuxFile }; virtual void aboutToEval(ProFile *parent, ProFile *proFile, EvalFileType type) = 0; diff --git a/qmake/library/qmakeparser.h b/qmake/library/qmakeparser.h index dfea1ddfdf..7fa4f62a96 100644 --- a/qmake/library/qmakeparser.h +++ b/qmake/library/qmakeparser.h @@ -50,8 +50,9 @@ class QMAKE_EXPORT QMakeParserHandler public: enum { CategoryMask = 0xf00, - WarningMessage = 0x000, - ErrorMessage = 0x100, + InfoMessage = 0x100, + WarningMessage = 0x200, + ErrorMessage = 0x300, SourceMask = 0xf0, SourceParser = 0, diff --git a/qmake/option.cpp b/qmake/option.cpp index da59616e5c..46bfa33dd3 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -601,8 +601,9 @@ void EvalHandler::message(int type, const QString &msg, const QString &fileName, fprintf(stderr, "%s%s\n", qPrintable(pfx), qPrintable(msg)); } -void EvalHandler::fileMessage(const QString &msg) +void EvalHandler::fileMessage(int type, const QString &msg) { + Q_UNUSED(type) fprintf(stderr, "%s\n", qPrintable(msg)); } diff --git a/qmake/option.h b/qmake/option.h index 663f096072..cb3eb1341a 100644 --- a/qmake/option.h +++ b/qmake/option.h @@ -67,7 +67,7 @@ class EvalHandler : public QMakeHandler { public: void message(int type, const QString &msg, const QString &fileName, int lineNo); - void fileMessage(const QString &msg); + void fileMessage(int type, const QString &msg); void aboutToEval(ProFile *, ProFile *, EvalFileType); void doneWithEval(ProFile *); -- cgit v1.2.3 From 1568b09f1c1be5a8891e7cc75288c6a2b6bf60de Mon Sep 17 00:00:00 2001 From: Frank Meerkoetter Date: Wed, 30 Dec 2015 20:44:33 +0100 Subject: Correctly flag WinPhone Fixes coverity CID21703. Change-Id: If9587c7cc49768066273a97fc56c3a662104f439 Reviewed-by: Andrew Knight Reviewed-by: Maurice Kalinowski --- qmake/generators/win32/msbuild_objectmodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qmake') diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index aad6e6e878..8e2be589cd 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -628,7 +628,7 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool) << tagValue("Platform", tool.SingleProjects.at(i).PlatformName) << closetag(); isWinRT = isWinRT || tool.SingleProjects.at(i).Configuration.WinRT; - isWinPhone = isWinPhone = tool.SingleProjects.at(i).Configuration.WinPhone; + isWinPhone = isWinPhone || tool.SingleProjects.at(i).Configuration.WinPhone; } xml << closetag() -- cgit v1.2.3 From e0cc6e5b8e1be3ce292060d3b0f7f92e1bde82c1 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Mon, 4 Jan 2016 15:27:16 +0100 Subject: winphone: Invoke windeployqt twice unconditionally for vcproj In 50bf54c invoking windeployqt was only required in release mode as MDILXapCompile was not invoked for debug builds with Visual Studio 2013. However, Visual Studio 2015 invokes MDILXapCompile for debug and release. Hence we have to use this workaround unconditionally. Also we cannot limit this to msvc2015 host specs only, as older projects still might be loaded with Visual Studio 2015 causing the build to break. Task-number: QTBUG-49815 Change-Id: Ia120a392967319b945a9746ad489f2db0eed7156 Reviewed-by: Joerg Bornemann Reviewed-by: Oliver Wolff --- qmake/generators/win32/msvc_vcproj.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qmake') diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 1e187075c8..465c8fc312 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -1428,11 +1428,11 @@ void VcprojGenerator::initWinDeployQtTool() // itself contains the original subdirectories as parameters and hence the // call fails. // Neither there is a way to disable this behavior for Windows Phone, nor - // to influence the parameters. Hence the only way to get a release build + // to influence the parameters. Hence the only way to get a build // done is to recreate the directory structure manually by invoking // windeployqt a second time, so that the MDILXapCompile call succeeds and // deployment continues. - if (conf.WinPhone && conf.Name == QStringLiteral("Release|ARM")) { + if (conf.WinPhone) { conf.windeployqt.CommandLine = commandLine + QStringLiteral(" -list relative -dir \"$(MSBuildProjectDirectory)\\") + var("OBJECTS_DIR") -- cgit v1.2.3 From 282f15feaae4c525602d537ab65cb61987eb5f7f Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 23 Nov 2015 14:14:46 +0100 Subject: rewrite qtAddToolEnv() the primary purpose is making env var prepend mode work for unset variables on windows. this is achieved by using a conditional and delayed variable expansion. however, the latter is disabled by default and can be locally enabled only in batch files. therefore, write wrapper scripts and substitute them for the actual commands. we do this also on unix, both for consistency and simply because the commands look much less confusing. this change is slightly backwards-incompatible, as invoking qtAddToolEnv() multiple times on the same command will now make a total mess. also, invoking it on a command that contains 'make' macro expansions isn't a good idea, so testcase.prf needed an adjustment. the function is an undocumented internal, so Nobody Should Care (TM). this also reverts 80ebedecf9, as it's obsolete now. Change-Id: I8394b77868b495abcf27b688996ca74c40b80994 Reviewed-by: Simon Hausmann --- qmake/generators/win32/msvc_objectmodel.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'qmake') diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp index 339dae953a..18457ac5ad 100644 --- a/qmake/generators/win32/msvc_objectmodel.cpp +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -2399,11 +2399,7 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info) if (!CustomBuildTool.Description.isEmpty()) CustomBuildTool.Description += ", "; CustomBuildTool.Description += cmd_name; - // Execute custom build steps in an environment variable scope to prevent unwanted - // side effects for downstream build steps - CustomBuildTool.CommandLine += QLatin1String("setlocal"); CustomBuildTool.CommandLine += VCToolBase::fixCommandLine(cmd.trimmed()); - CustomBuildTool.CommandLine += QLatin1String("endlocal"); int space = cmd.indexOf(' '); QFileInfo finf(cmd.left(space)); if (CustomBuildTool.ToolPath.isEmpty()) -- cgit v1.2.3