summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-11-09 14:37:53 (GMT)
committerBrad King <brad.king@kitware.com>2017-11-10 15:41:50 (GMT)
commit2201ecec44adcc490c7481a52a88d6543bc5dd7b (patch)
treebfb03c4a40e8ad65e82604af79abe86acdc89283
parent45da558742bad36be518e8d95dee0d0ec3793a64 (diff)
downloadCMake-2201ecec44adcc490c7481a52a88d6543bc5dd7b.zip
CMake-2201ecec44adcc490c7481a52a88d6543bc5dd7b.tar.gz
CMake-2201ecec44adcc490c7481a52a88d6543bc5dd7b.tar.bz2
Windows: Do not report manifest tool update notification as failure
A diagnostic message added in commit v3.10.0-rc1~59^2 (Windows: Improve link-time error messages when rc or mt fail, 2017-09-22) incorrectly reports the `mt /notify_update` special return code as a failure. Fix the logic to consider the special return codes as success. Fixes: #17444
-rw-r--r--Source/cmcmd.cxx37
1 files changed, 23 insertions, 14 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index b4772a9..69339b4 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -1576,9 +1576,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";
@@ -1588,18 +1590,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 || !retCodeSuccess) {
*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)
@@ -1612,7 +1613,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,
@@ -1710,6 +1711,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:
@@ -1781,9 +1789,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;
}
@@ -1836,7 +1844,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;