From 5d55ec9343c9b8ebe523c6e86d8f2773a15419bd Mon Sep 17 00:00:00 2001 From: Janick Bernet Date: Wed, 21 Dec 2011 14:30:04 +0100 Subject: [PATCH 1/2] Fixed @ in inference rule not suppressing command output. --- src/jomlib/commandexecutor.cpp | 2 +- src/jomlib/makefile.cpp | 8 ++++---- src/jomlib/makefile.h | 7 ++++++- src/jomlib/parser.cpp | 6 ++---- tests/tests.cpp | 6 +++--- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/jomlib/commandexecutor.cpp b/src/jomlib/commandexecutor.cpp index 9155c8e..bab4d37 100644 --- a/src/jomlib/commandexecutor.cpp +++ b/src/jomlib/commandexecutor.cpp @@ -179,7 +179,7 @@ void CommandExecutor::executeCurrentCommandLine() int jomCallIdx = commandLine.indexOf(m_pTarget->makefile()->options()->fullAppPath); bool spawnJOM = (jomCallIdx >= 0); - if (!cmd.m_silent && !m_pTarget->makefile()->options()->suppressExecutedCommandsDisplay) { + if (!cmd.isSilent() && !m_pTarget->makefile()->options()->suppressExecutedCommandsDisplay) { QByteArray output = commandLine.toLocal8Bit(); output.prepend('\t'); output.append('\n'); diff --git a/src/jomlib/makefile.cpp b/src/jomlib/makefile.cpp index 66d1e95..304d659 100644 --- a/src/jomlib/makefile.cpp +++ b/src/jomlib/makefile.cpp @@ -44,16 +44,16 @@ InlineFile::InlineFile(const InlineFile& rhs) Command::Command() : m_maxExitCode(0), - m_silent(false), - m_singleExecution(false) + m_singleExecution(false), + m_silent(false) { } Command::Command(const Command& rhs) : m_maxExitCode(rhs.m_maxExitCode), m_commandLine(rhs.m_commandLine), - m_silent(rhs.m_silent), - m_singleExecution(rhs.m_singleExecution) + m_singleExecution(rhs.m_singleExecution), + m_silent(rhs.m_silent) { foreach (InlineFile* inlineFile, rhs.m_inlineFiles) m_inlineFiles.append(new InlineFile(*inlineFile)); diff --git a/src/jomlib/makefile.h b/src/jomlib/makefile.h index bd5f375..6368d16 100644 --- a/src/jomlib/makefile.h +++ b/src/jomlib/makefile.h @@ -48,11 +48,16 @@ public: Command(const Command& rhs); ~Command(); + bool isSilent() const { return m_silent || m_commandLine.startsWith(QLatin1Char('@')); } + void setSilent(const bool silent) { m_silent = silent; } + QString m_commandLine; QList m_inlineFiles; unsigned char m_maxExitCode; // greatest allowed exit code - bool m_silent; bool m_singleExecution; // Execute this command for each dependent, if the command contains $** or $?. + +private: + bool m_silent; }; class CommandContainer { diff --git a/src/jomlib/parser.cpp b/src/jomlib/parser.cpp index 6f23fcc..2b695ba 100644 --- a/src/jomlib/parser.cpp +++ b/src/jomlib/parser.cpp @@ -409,8 +409,9 @@ void Parser::parseCommandLine(const QString& cmdLine, QList& commands, { commands.append(Command()); Command& cmd = commands.last(); + if (m_ignoreExitCodes) cmd.m_maxExitCode = 255; - cmd.m_silent = m_silentCommands; + cmd.setSilent(m_silentCommands); if (!inferenceRule) cmd.m_commandLine = m_preprocessor->macroTable()->expandMacros(cmdLine.trimmed()); @@ -430,9 +431,6 @@ void Parser::parseCommandLine(const QString& cmdLine, QList& commands, } else { cmd.m_maxExitCode = 255; } - } else if (cmd.m_commandLine.startsWith(QLatin1Char('@'))) { - cmd.m_commandLine = cmd.m_commandLine.remove(0, 1); - cmd.m_silent = true; } else if (cmd.m_commandLine.startsWith(QLatin1Char('!'))) { cmd.m_commandLine = cmd.m_commandLine.remove(0, 1); cmd.m_singleExecution = true; diff --git a/tests/tests.cpp b/tests/tests.cpp index 109f4c9..a387381 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -336,13 +336,13 @@ void ParserTest::dotDirectives() QVERIFY(target != 0); QCOMPARE(target->m_commands.count(), 1); cmd = target->m_commands.takeFirst(); - QCOMPARE(cmd.m_silent, false); + QCOMPARE(cmd.isSilent(), false); target = mkfile->target(QLatin1String("silence_two")); QVERIFY(target != 0); QCOMPARE(target->m_commands.count(), 1); cmd = target->m_commands.takeFirst(); - QCOMPARE(cmd.m_silent, true); + QCOMPARE(cmd.isSilent(), true); target = mkfile->target(QLatin1String("silence_three")); QVERIFY(target != 0); @@ -568,7 +568,7 @@ void ParserTest::commandModifiers() QVERIFY(target); QCOMPARE(target->m_commands.count(), 5); Command cmd = target->m_commands.at(0); - QCOMPARE(cmd.m_silent, true); + QCOMPARE(cmd.isSilent(), true); cmd = target->m_commands.at(1); QCOMPARE((int)cmd.m_maxExitCode, 255); -- 1.7.4.msysgit.0