diff options
author | Brad King <brad.king@kitware.com> | 2016-11-21 15:02:02 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-11-21 15:02:02 (GMT) |
commit | 95cfb5457959cb221af60a63a39bc152bb024e58 (patch) | |
tree | cad4b7676cd8e42ad053a537caa314356d1082f4 /Source | |
parent | 45d74e9ad32592856852f92471c658256b619e6a (diff) | |
parent | 80ebc55a7ce934ee357c30713bcb96b209e97963 (diff) | |
download | CMake-95cfb5457959cb221af60a63a39bc152bb024e58.zip CMake-95cfb5457959cb221af60a63a39bc152bb024e58.tar.gz CMake-95cfb5457959cb221af60a63a39bc152bb024e58.tar.bz2 |
Merge topic 'capture-clang-tidy-errors'
80ebc55a cmake: Report if the <LANG>_CLANG_TIDY tool exits with non-zero
ce1abfa4 cmake: If ldd for LINK_WHAT_YOU_USE fails to run then report why
44de6157 cmake: Comment why we ignore the include-what-you-use return code
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmcmd.cxx | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 1db147a..f1ce75a 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -327,6 +327,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) iwyu_cmd.insert(iwyu_cmd.end(), orig_cmd.begin() + 1, orig_cmd.end()); // Run the iwyu command line. Capture its stderr and hide its stdout. + // Ignore its return code because the tool always returns non-zero. std::string stdErr; if (!cmSystemTools::RunSingleCommand(iwyu_cmd, CM_NULLPTR, &stdErr, &ret, CM_NULLPTR, @@ -357,14 +358,21 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Run the tidy command line. Capture its stdout and hide its stderr. std::string stdOut; - if (!cmSystemTools::RunSingleCommand(tidy_cmd, &stdOut, CM_NULLPTR, - &ret, CM_NULLPTR, + std::string stdErr; + if (!cmSystemTools::RunSingleCommand(tidy_cmd, &stdOut, &stdErr, &ret, + CM_NULLPTR, cmSystemTools::OUTPUT_NONE)) { - std::cerr << "Error running '" << tidy_cmd[0] << "'\n"; + std::cerr << "Error running '" << tidy_cmd[0] << "': " << stdErr + << "\n"; return 1; } // Output the stdout from clang-tidy to stderr std::cerr << stdOut; + // If clang-tidy exited with an error do the same. + if (ret != 0) { + std::cerr << stdErr; + return ret; + } } if (!lwyu.empty()) { // Construct the ldd -r -u (link what you use lwyu) command line @@ -377,11 +385,15 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Run the ldd -u -r command line. // Capture its stdout and hide its stderr. + // Ignore its return code because the tool always returns non-zero + // if there are any warnings, but we just want to warn. std::string stdOut; - if (!cmSystemTools::RunSingleCommand(lwyu_cmd, &stdOut, CM_NULLPTR, - &ret, CM_NULLPTR, + std::string stdErr; + if (!cmSystemTools::RunSingleCommand(lwyu_cmd, &stdOut, &stdErr, &ret, + CM_NULLPTR, cmSystemTools::OUTPUT_NONE)) { - std::cerr << "Error running '" << lwyu_cmd[0] << "'\n"; + std::cerr << "Error running '" << lwyu_cmd[0] << "': " << stdErr + << "\n"; return 1; } |