diff options
author | Brad King <brad.king@kitware.com> | 2017-11-10 12:31:11 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-11-10 12:31:55 (GMT) |
commit | 6d20c44f3df2b642235b64ba4be789cd9e2b5362 (patch) | |
tree | 39c499bdd595d019ca55435f266b3fd48f8bd4aa /Source/cmcmd.cxx | |
parent | 0d7086e3daa67d6679f5ab01d9b187c333cca627 (diff) | |
parent | 18eae3f04db49608348283b4860e9eede69bf0a8 (diff) | |
download | CMake-6d20c44f3df2b642235b64ba4be789cd9e2b5362.zip CMake-6d20c44f3df2b642235b64ba4be789cd9e2b5362.tar.gz CMake-6d20c44f3df2b642235b64ba4be789cd9e2b5362.tar.bz2 |
Merge topic 'windows-mt-update-quiet'
18eae3f0 Windows: Do not report manifest tool update notification as failure
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1470
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r-- | Source/cmcmd.cxx | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index ef75b01..24c67c6 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1577,9 +1577,11 @@ std::ostream& operator<<(std::ostream& stream, stream.flags(flags); return stream; } + static bool RunCommand(const char* comment, std::vector<std::string>& command, bool verbose, NumberFormat exitFormat, - int* retCodeOut = nullptr) + int* retCodeOut = nullptr, + bool (*retCodeOkay)(int) = nullptr) { if (verbose) { std::cout << comment << ":\n"; @@ -1589,18 +1591,17 @@ static bool RunCommand(const char* comment, std::vector<std::string>& command, int retCode = 0; bool commandResult = cmSystemTools::RunSingleCommand( command, &output, &output, &retCode, nullptr, cmSystemTools::OUTPUT_NONE); - bool returnValue; + bool const retCodeSuccess = + retCode == 0 || (retCodeOkay && retCodeOkay(retCode)); + bool const success = commandResult && retCodeSuccess; if (retCodeOut) { - if (!commandResult) { - *retCodeOut = (retCode == 0) ? -1 : retCode; - } else { + if (commandResult || !retCodeOkay) { *retCodeOut = retCode; + } else { + *retCodeOut = -1; } - returnValue = true; // always return true if retCodeOut is requested - } else { - returnValue = commandResult && (retCode == 0); } - if (!commandResult || retCode) { + if (!success) { std::cout << comment << ": command \"" << cmJoin(command, " ") << "\" failed (exit code " << NumberFormatter(exitFormat, retCode) @@ -1613,7 +1614,7 @@ static bool RunCommand(const char* comment, std::vector<std::string>& command, std::cout << output; } } - return returnValue; + return success; } bool cmVSLink::Parse(std::vector<std::string>::const_iterator argBeg, @@ -1711,6 +1712,13 @@ int cmVSLink::Link() return LinkNonIncremental(); } +static bool mtRetIsUpdate(int mtRet) +{ + // 'mt /notify_update' returns a special value (differing between + // Windows and POSIX hosts) when it updated the manifest file. + return mtRet == 0x41020001 || mtRet == 0xbb; +} + int cmVSLink::LinkIncremental() { // This follows the steps listed here: @@ -1782,9 +1790,9 @@ int cmVSLink::LinkIncremental() // Run the manifest tool to create the final manifest. int mtRet = this->RunMT("/out:" + this->ManifestFile, true); - // If mt returns 1090650113 (or 187 on a posix host) then it updated the - // manifest file so we need to embed it again. Otherwise we are done. - if (mtRet != 1090650113 && mtRet != 187) { + // If mt returns a special value then it updated the manifest file so + // we need to embed it again. Otherwise we are done. + if (!mtRetIsUpdate(mtRet)) { return mtRet; } @@ -1837,7 +1845,8 @@ int cmVSLink::RunMT(std::string const& out, bool notify) mtCommand.push_back("/notify_update"); } int mtRet = 0; - if (!RunCommand("MT", mtCommand, this->Verbose, FORMAT_HEX, &mtRet)) { + if (!RunCommand("MT", mtCommand, this->Verbose, FORMAT_HEX, &mtRet, + mtRetIsUpdate)) { return -1; } return mtRet; |