mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 05:26:58 +08:00
Refactor: Avoid std::endl
where it's not necessary (part 1)
The `std::endl` manupulator, except inserting `\n` character, also performs `os.flush()`, which may leads to undesired effects (like disk I/O in the middle of forming data strings). For the `std::stringstream` it also has no meaning.
This commit is contained in:
@@ -77,7 +77,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
|
|||||||
}
|
}
|
||||||
while (realbuffer[0] == '/' && realbuffer[1] == '/') {
|
while (realbuffer[0] == '/' && realbuffer[1] == '/') {
|
||||||
if ((realbuffer[2] == '\\') && (realbuffer[3] == 'n')) {
|
if ((realbuffer[2] == '\\') && (realbuffer[3] == 'n')) {
|
||||||
helpString += "\n";
|
helpString += '\n';
|
||||||
helpString += &realbuffer[4];
|
helpString += &realbuffer[4];
|
||||||
} else {
|
} else {
|
||||||
helpString += &realbuffer[2];
|
helpString += &realbuffer[2];
|
||||||
@@ -117,8 +117,8 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::ostringstream error;
|
std::ostringstream error;
|
||||||
error << "Parse error in cache file " << cacheFile;
|
error << "Parse error in cache file " << cacheFile << " on line "
|
||||||
error << " on line " << lineno << ". Offending entry: " << realbuffer;
|
<< lineno << ". Offending entry: " << realbuffer;
|
||||||
cmSystemTools::Error(error.str());
|
cmSystemTools::Error(error.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,7 @@ void cmCacheManager::WritePropertyEntries(std::ostream& os, CacheIterator i,
|
|||||||
cmCacheManager::OutputKey(os, key);
|
cmCacheManager::OutputKey(os, key);
|
||||||
os << ":INTERNAL=";
|
os << ":INTERNAL=";
|
||||||
cmCacheManager::OutputValue(os, *value);
|
cmCacheManager::OutputValue(os, *value);
|
||||||
os << "\n";
|
os << '\n';
|
||||||
cmCacheManager::OutputNewlineTruncationWarning(os, key, *value,
|
cmCacheManager::OutputNewlineTruncationWarning(os, key, *value,
|
||||||
messenger);
|
messenger);
|
||||||
}
|
}
|
||||||
@@ -268,31 +268,29 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
|
|||||||
|
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
fout << "# This is the CMakeCache file.\n"
|
fout << "# This is the CMakeCache file.\n"
|
||||||
<< "# For build in directory: " << currentcwd << "\n"
|
"# For build in directory: " << currentcwd << "\n"
|
||||||
<< "# It was generated by CMake: "
|
"# It was generated by CMake: "
|
||||||
<< cmSystemTools::GetCMakeCommand() << std::endl;
|
<< cmSystemTools::GetCMakeCommand()
|
||||||
|
<< "\n"
|
||||||
|
"# You can edit this file to change values found and used by cmake."
|
||||||
|
"\n"
|
||||||
|
"# If you do not want to change any of the values, simply exit the "
|
||||||
|
"editor.\n"
|
||||||
|
"# If you do want to change a value, simply edit, save, and exit "
|
||||||
|
"the editor.\n"
|
||||||
|
"# The syntax for the file is as follows:\n"
|
||||||
|
"# KEY:TYPE=VALUE\n"
|
||||||
|
"# KEY is the name of a variable in the cache.\n"
|
||||||
|
"# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!."
|
||||||
|
"\n"
|
||||||
|
"# VALUE is the current value for the KEY.\n"
|
||||||
|
"\n"
|
||||||
|
"########################\n"
|
||||||
|
"# EXTERNAL cache entries\n"
|
||||||
|
"########################\n"
|
||||||
|
"\n";
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
|
|
||||||
/* clang-format off */
|
|
||||||
fout << "# You can edit this file to change values found and used by cmake."
|
|
||||||
<< std::endl
|
|
||||||
<< "# If you do not want to change any of the values, simply exit the "
|
|
||||||
"editor." << std::endl
|
|
||||||
<< "# If you do want to change a value, simply edit, save, and exit "
|
|
||||||
"the editor." << std::endl
|
|
||||||
<< "# The syntax for the file is as follows:\n"
|
|
||||||
<< "# KEY:TYPE=VALUE\n"
|
|
||||||
<< "# KEY is the name of a variable in the cache.\n"
|
|
||||||
<< "# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT "
|
|
||||||
"TYPE!." << std::endl
|
|
||||||
<< "# VALUE is the current value for the KEY.\n\n";
|
|
||||||
/* clang-format on */
|
|
||||||
|
|
||||||
fout << "########################\n";
|
|
||||||
fout << "# EXTERNAL cache entries\n";
|
|
||||||
fout << "########################\n";
|
|
||||||
fout << "\n";
|
|
||||||
|
|
||||||
for (auto const& i : this->Cache) {
|
for (auto const& i : this->Cache) {
|
||||||
CacheEntry const& ce = i.second;
|
CacheEntry const& ce = i.second;
|
||||||
cmStateEnums::CacheEntryType t = ce.Type;
|
cmStateEnums::CacheEntryType t = ce.Type;
|
||||||
@@ -309,20 +307,20 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
|
|||||||
cmCacheManager::OutputHelpString(fout, "Missing description");
|
cmCacheManager::OutputHelpString(fout, "Missing description");
|
||||||
}
|
}
|
||||||
cmCacheManager::OutputKey(fout, i.first);
|
cmCacheManager::OutputKey(fout, i.first);
|
||||||
fout << ":" << cmState::CacheEntryTypeToString(t) << "=";
|
fout << ':' << cmState::CacheEntryTypeToString(t) << '=';
|
||||||
cmCacheManager::OutputValue(fout, ce.Value);
|
cmCacheManager::OutputValue(fout, ce.Value);
|
||||||
fout << "\n";
|
fout << '\n';
|
||||||
cmCacheManager::OutputNewlineTruncationWarning(fout, i.first, ce.Value,
|
cmCacheManager::OutputNewlineTruncationWarning(fout, i.first, ce.Value,
|
||||||
messenger);
|
messenger);
|
||||||
fout << "\n";
|
fout << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fout << "\n";
|
fout << "\n"
|
||||||
fout << "########################\n";
|
"########################\n"
|
||||||
fout << "# INTERNAL cache entries\n";
|
"# INTERNAL cache entries\n"
|
||||||
fout << "########################\n";
|
"########################\n"
|
||||||
fout << "\n";
|
"\n";
|
||||||
|
|
||||||
for (cmCacheManager::CacheIterator i = this->NewIterator(); !i.IsAtEnd();
|
for (cmCacheManager::CacheIterator i = this->NewIterator(); !i.IsAtEnd();
|
||||||
i.Next()) {
|
i.Next()) {
|
||||||
@@ -338,14 +336,14 @@ bool cmCacheManager::SaveCache(const std::string& path, cmMessenger* messenger)
|
|||||||
cmCacheManager::OutputHelpString(fout, *help);
|
cmCacheManager::OutputHelpString(fout, *help);
|
||||||
}
|
}
|
||||||
cmCacheManager::OutputKey(fout, i.GetName());
|
cmCacheManager::OutputKey(fout, i.GetName());
|
||||||
fout << ":" << cmState::CacheEntryTypeToString(t) << "=";
|
fout << ':' << cmState::CacheEntryTypeToString(t) << '=';
|
||||||
cmCacheManager::OutputValue(fout, i.GetValue());
|
cmCacheManager::OutputValue(fout, i.GetValue());
|
||||||
fout << "\n";
|
fout << '\n';
|
||||||
cmCacheManager::OutputNewlineTruncationWarning(fout, i.GetName(),
|
cmCacheManager::OutputNewlineTruncationWarning(fout, i.GetName(),
|
||||||
i.GetValue(), messenger);
|
i.GetValue(), messenger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fout << "\n";
|
fout << '\n';
|
||||||
fout.Close();
|
fout.Close();
|
||||||
std::string checkCacheFile = cmStrCat(path, "/CMakeFiles");
|
std::string checkCacheFile = cmStrCat(path, "/CMakeFiles");
|
||||||
cmSystemTools::MakeDirectory(checkCacheFile);
|
cmSystemTools::MakeDirectory(checkCacheFile);
|
||||||
@@ -428,7 +426,7 @@ void cmCacheManager::OutputHelpString(std::ostream& fout,
|
|||||||
fout << "\\n";
|
fout << "\\n";
|
||||||
}
|
}
|
||||||
oneLine = helpString.substr(pos, i - pos);
|
oneLine = helpString.substr(pos, i - pos);
|
||||||
fout << oneLine << "\n";
|
fout << oneLine << '\n';
|
||||||
pos = i;
|
pos = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -450,7 +448,7 @@ void cmCacheManager::OutputWarningComment(std::ostream& fout,
|
|||||||
fout << "\\n";
|
fout << "\\n";
|
||||||
}
|
}
|
||||||
oneLine = message.substr(pos, i - pos);
|
oneLine = message.substr(pos, i - pos);
|
||||||
fout << oneLine << "\n";
|
fout << oneLine << '\n';
|
||||||
pos = i;
|
pos = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -517,17 +515,17 @@ cmProp cmCacheManager::GetInitializedCacheValue(const std::string& key) const
|
|||||||
|
|
||||||
void cmCacheManager::PrintCache(std::ostream& out) const
|
void cmCacheManager::PrintCache(std::ostream& out) const
|
||||||
{
|
{
|
||||||
out << "=================================================" << std::endl;
|
out << "=================================================\n"
|
||||||
out << "CMakeCache Contents:" << std::endl;
|
"CMakeCache Contents:\n";
|
||||||
for (auto const& i : this->Cache) {
|
for (auto const& i : this->Cache) {
|
||||||
if (i.second.Type != cmStateEnums::INTERNAL) {
|
if (i.second.Type != cmStateEnums::INTERNAL) {
|
||||||
out << i.first << " = " << i.second.Value << std::endl;
|
out << i.first << " = " << i.second.Value << '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out << "\n\n";
|
out << "\n\n"
|
||||||
out << "To change values in the CMakeCache, " << std::endl
|
"To change values in the CMakeCache, \n"
|
||||||
<< "edit CMakeCache.txt in your output directory.\n";
|
"edit CMakeCache.txt in your output directory.\n"
|
||||||
out << "=================================================" << std::endl;
|
"=================================================\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmCacheManager::AddCacheEntry(const std::string& key, const char* value,
|
void cmCacheManager::AddCacheEntry(const std::string& key, const char* value,
|
||||||
|
@@ -43,8 +43,7 @@ static bool LogErrorsAsMessages;
|
|||||||
if (LogErrorsAsMessages) { \
|
if (LogErrorsAsMessages) { \
|
||||||
std::ostringstream _hresult_oss; \
|
std::ostringstream _hresult_oss; \
|
||||||
_hresult_oss.flags(std::ios::hex); \
|
_hresult_oss.flags(std::ios::hex); \
|
||||||
_hresult_oss << context << " failed HRESULT, hr = 0x" << hr \
|
_hresult_oss << context << " failed HRESULT, hr = 0x" << hr << '\n'; \
|
||||||
<< std::endl; \
|
|
||||||
_hresult_oss.flags(std::ios::dec); \
|
_hresult_oss.flags(std::ios::dec); \
|
||||||
_hresult_oss << __FILE__ << "(" << __LINE__ << ")"; \
|
_hresult_oss << __FILE__ << "(" << __LINE__ << ")"; \
|
||||||
cmSystemTools::Message(_hresult_oss.str()); \
|
cmSystemTools::Message(_hresult_oss.str()); \
|
||||||
@@ -98,32 +97,37 @@ HRESULT InstanceCallMacro(IDispatch* vsIDE, const std::string& macro,
|
|||||||
DISPATCH_METHOD, ¶ms, &result, &excep, &arg);
|
DISPATCH_METHOD, ¶ms, &result, &excep, &arg);
|
||||||
|
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << std::endl;
|
/* clang-format off */
|
||||||
oss << "Invoke(ExecuteCommand)" << std::endl;
|
oss << "\nInvoke(ExecuteCommand)\n"
|
||||||
oss << " Macro: " << macro << std::endl;
|
" Macro: " << macro << "\n"
|
||||||
oss << " Args: " << args << std::endl;
|
" Args: " << args << '\n';
|
||||||
|
/* clang-format on */
|
||||||
|
|
||||||
if (DISP_E_EXCEPTION == hr) {
|
if (DISP_E_EXCEPTION == hr) {
|
||||||
oss << "DISP_E_EXCEPTION EXCEPINFO:" << excep.wCode << std::endl;
|
/* clang-format off */
|
||||||
oss << " wCode: " << excep.wCode << std::endl;
|
oss << "DISP_E_EXCEPTION EXCEPINFO:" << excep.wCode << "\n"
|
||||||
oss << " wReserved: " << excep.wReserved << std::endl;
|
" wCode: " << excep.wCode << "\n"
|
||||||
|
" wReserved: " << excep.wReserved << '\n';
|
||||||
|
/* clang-format on */
|
||||||
if (excep.bstrSource) {
|
if (excep.bstrSource) {
|
||||||
oss << " bstrSource: " << (const char*)(_bstr_t)excep.bstrSource
|
oss << " bstrSource: " << (const char*)(_bstr_t)excep.bstrSource
|
||||||
<< std::endl;
|
<< '\n';
|
||||||
}
|
}
|
||||||
if (excep.bstrDescription) {
|
if (excep.bstrDescription) {
|
||||||
oss << " bstrDescription: "
|
oss << " bstrDescription: "
|
||||||
<< (const char*)(_bstr_t)excep.bstrDescription << std::endl;
|
<< (const char*)(_bstr_t)excep.bstrDescription << '\n';
|
||||||
}
|
}
|
||||||
if (excep.bstrHelpFile) {
|
if (excep.bstrHelpFile) {
|
||||||
oss << " bstrHelpFile: " << (const char*)(_bstr_t)excep.bstrHelpFile
|
oss << " bstrHelpFile: " << (const char*)(_bstr_t)excep.bstrHelpFile
|
||||||
<< std::endl;
|
<< '\n';
|
||||||
}
|
}
|
||||||
oss << " dwHelpContext: " << excep.dwHelpContext << std::endl;
|
/* clang-format off */
|
||||||
oss << " pvReserved: " << excep.pvReserved << std::endl;
|
oss << " dwHelpContext: " << excep.dwHelpContext << "\n"
|
||||||
oss << " pfnDeferredFillIn: "
|
" pvReserved: " << excep.pvReserved << "\n"
|
||||||
<< reinterpret_cast<void*>(excep.pfnDeferredFillIn) << std::endl;
|
" pfnDeferredFillIn: "
|
||||||
oss << " scode: " << excep.scode << std::endl;
|
<< reinterpret_cast<void*>(excep.pfnDeferredFillIn) << "\n"
|
||||||
|
" scode: " << excep.scode << '\n';
|
||||||
|
/* clang-format on */
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string exstr(oss.str());
|
std::string exstr(oss.str());
|
||||||
|
@@ -276,8 +276,7 @@ static bool checkInterfaceDirs(const std::string& prepro,
|
|||||||
<< "\"\nhowever it is also "
|
<< "\"\nhowever it is also "
|
||||||
"a subdirectory of the "
|
"a subdirectory of the "
|
||||||
<< (inBinary ? "build" : "source") << " tree:\n \""
|
<< (inBinary ? "build" : "source") << " tree:\n \""
|
||||||
<< (inBinary ? topBinaryDir : topSourceDir) << "\""
|
<< (inBinary ? topBinaryDir : topSourceDir) << "\"\n";
|
||||||
<< std::endl;
|
|
||||||
target->GetLocalGenerator()->IssueMessage(
|
target->GetLocalGenerator()->IssueMessage(
|
||||||
MessageType::AUTHOR_WARNING, s.str());
|
MessageType::AUTHOR_WARNING, s.str());
|
||||||
CM_FALLTHROUGH;
|
CM_FALLTHROUGH;
|
||||||
|
@@ -1011,7 +1011,7 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand(
|
|||||||
cm::make_unique<cmGeneratedFileStream>(buildFilePath);
|
cm::make_unique<cmGeneratedFileStream>(buildFilePath);
|
||||||
*this->CompileCommandsStream << "[";
|
*this->CompileCommandsStream << "[";
|
||||||
} else {
|
} else {
|
||||||
*this->CompileCommandsStream << "," << std::endl;
|
*this->CompileCommandsStream << ",\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string sourceFileName = sourceFile;
|
std::string sourceFileName = sourceFile;
|
||||||
|
@@ -159,7 +159,7 @@ void cmGlobalUnixMakefileGenerator3::Generate()
|
|||||||
this->WriteMainCMakefile();
|
this->WriteMainCMakefile();
|
||||||
|
|
||||||
if (this->CommandDatabase) {
|
if (this->CommandDatabase) {
|
||||||
*this->CommandDatabase << std::endl << "]";
|
*this->CommandDatabase << "\n]";
|
||||||
this->CommandDatabase.reset();
|
this->CommandDatabase.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,21 +174,20 @@ void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand(
|
|||||||
"/compile_commands.json";
|
"/compile_commands.json";
|
||||||
this->CommandDatabase =
|
this->CommandDatabase =
|
||||||
cm::make_unique<cmGeneratedFileStream>(commandDatabaseName);
|
cm::make_unique<cmGeneratedFileStream>(commandDatabaseName);
|
||||||
*this->CommandDatabase << "[" << std::endl;
|
*this->CommandDatabase << "[\n";
|
||||||
} else {
|
} else {
|
||||||
*this->CommandDatabase << "," << std::endl;
|
*this->CommandDatabase << ",\n";
|
||||||
}
|
}
|
||||||
*this->CommandDatabase << "{" << std::endl
|
*this->CommandDatabase << "{\n"
|
||||||
<< R"( "directory": ")"
|
<< R"( "directory": ")"
|
||||||
<< cmGlobalGenerator::EscapeJSON(workingDirectory)
|
<< cmGlobalGenerator::EscapeJSON(workingDirectory)
|
||||||
<< "\"," << std::endl
|
<< "\",\n"
|
||||||
<< R"( "command": ")"
|
<< R"( "command": ")"
|
||||||
<< cmGlobalGenerator::EscapeJSON(compileCommand)
|
<< cmGlobalGenerator::EscapeJSON(compileCommand)
|
||||||
<< "\"," << std::endl
|
<< "\",\n"
|
||||||
<< R"( "file": ")"
|
<< R"( "file": ")"
|
||||||
<< cmGlobalGenerator::EscapeJSON(sourceFile) << "\""
|
<< cmGlobalGenerator::EscapeJSON(sourceFile)
|
||||||
<< std::endl
|
<< "\"\n}";
|
||||||
<< "}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
|
void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2()
|
||||||
|
@@ -206,9 +206,8 @@ void cmLocalNinjaGenerator::WriteBuildFileTop()
|
|||||||
void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os)
|
void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os)
|
||||||
{
|
{
|
||||||
cmGlobalNinjaGenerator::WriteDivider(os);
|
cmGlobalNinjaGenerator::WriteDivider(os);
|
||||||
os << "# Project: " << this->GetProjectName() << std::endl
|
os << "# Project: " << this->GetProjectName() << '\n'
|
||||||
<< "# Configurations: " << cmJoin(this->GetConfigNames(), ", ")
|
<< "# Configurations: " << cmJoin(this->GetConfigNames(), ", ") << '\n';
|
||||||
<< std::endl;
|
|
||||||
cmGlobalNinjaGenerator::WriteDivider(os);
|
cmGlobalNinjaGenerator::WriteDivider(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,8 +234,7 @@ void cmLocalNinjaGenerator::WriteNinjaRequiredVersion(std::ostream& os)
|
|||||||
|
|
||||||
cmGlobalNinjaGenerator::WriteComment(
|
cmGlobalNinjaGenerator::WriteComment(
|
||||||
os, "Minimal version of Ninja required by this file");
|
os, "Minimal version of Ninja required by this file");
|
||||||
os << "ninja_required_version = " << requiredVersion << std::endl
|
os << "ninja_required_version = " << requiredVersion << "\n\n";
|
||||||
<< std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmLocalNinjaGenerator::WriteNinjaConfigurationVariable(
|
void cmLocalNinjaGenerator::WriteNinjaConfigurationVariable(
|
||||||
@@ -265,9 +263,8 @@ void cmLocalNinjaGenerator::WritePools(std::ostream& os)
|
|||||||
unsigned int jobs;
|
unsigned int jobs;
|
||||||
if (eq != std::string::npos &&
|
if (eq != std::string::npos &&
|
||||||
sscanf(pool.c_str() + eq, "=%u", &jobs) == 1) {
|
sscanf(pool.c_str() + eq, "=%u", &jobs) == 1) {
|
||||||
os << "pool " << pool.substr(0, eq) << std::endl;
|
os << "pool " << pool.substr(0, eq) << "\n depth = " << jobs
|
||||||
os << " depth = " << jobs << std::endl;
|
<< "\n\n";
|
||||||
os << std::endl;
|
|
||||||
} else {
|
} else {
|
||||||
cmSystemTools::Error("Invalid pool defined by property 'JOB_POOLS': " +
|
cmSystemTools::Error("Invalid pool defined by property 'JOB_POOLS': " +
|
||||||
pool);
|
pool);
|
||||||
@@ -279,8 +276,7 @@ void cmLocalNinjaGenerator::WritePools(std::ostream& os)
|
|||||||
void cmLocalNinjaGenerator::WriteNinjaFilesInclusionConfig(std::ostream& os)
|
void cmLocalNinjaGenerator::WriteNinjaFilesInclusionConfig(std::ostream& os)
|
||||||
{
|
{
|
||||||
cmGlobalNinjaGenerator::WriteDivider(os);
|
cmGlobalNinjaGenerator::WriteDivider(os);
|
||||||
os << "# Include auxiliary files.\n"
|
os << "# Include auxiliary files.\n\n";
|
||||||
<< "\n";
|
|
||||||
cmGlobalNinjaGenerator* ng = this->GetGlobalNinjaGenerator();
|
cmGlobalNinjaGenerator* ng = this->GetGlobalNinjaGenerator();
|
||||||
std::string const ninjaCommonFile =
|
std::string const ninjaCommonFile =
|
||||||
ng->NinjaOutputPath(cmGlobalNinjaMultiGenerator::NINJA_COMMON_FILE);
|
ng->NinjaOutputPath(cmGlobalNinjaMultiGenerator::NINJA_COMMON_FILE);
|
||||||
@@ -293,8 +289,7 @@ void cmLocalNinjaGenerator::WriteNinjaFilesInclusionConfig(std::ostream& os)
|
|||||||
void cmLocalNinjaGenerator::WriteNinjaFilesInclusionCommon(std::ostream& os)
|
void cmLocalNinjaGenerator::WriteNinjaFilesInclusionCommon(std::ostream& os)
|
||||||
{
|
{
|
||||||
cmGlobalNinjaGenerator::WriteDivider(os);
|
cmGlobalNinjaGenerator::WriteDivider(os);
|
||||||
os << "# Include auxiliary files.\n"
|
os << "# Include auxiliary files.\n\n";
|
||||||
<< "\n";
|
|
||||||
cmGlobalNinjaGenerator* ng = this->GetGlobalNinjaGenerator();
|
cmGlobalNinjaGenerator* ng = this->GetGlobalNinjaGenerator();
|
||||||
std::string const ninjaRulesFile =
|
std::string const ninjaRulesFile =
|
||||||
ng->NinjaOutputPath(cmGlobalNinjaGenerator::NINJA_RULES_FILE);
|
ng->NinjaOutputPath(cmGlobalNinjaGenerator::NINJA_RULES_FILE);
|
||||||
@@ -307,14 +302,14 @@ void cmLocalNinjaGenerator::WriteNinjaFilesInclusionCommon(std::ostream& os)
|
|||||||
void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
|
void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
|
||||||
{
|
{
|
||||||
cmGlobalNinjaGenerator::WriteDivider(os);
|
cmGlobalNinjaGenerator::WriteDivider(os);
|
||||||
os << "# Write statements declared in CMakeLists.txt:" << std::endl
|
os << "# Write statements declared in CMakeLists.txt:\n"
|
||||||
<< "# " << this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE")
|
<< "# " << this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE")
|
||||||
<< std::endl;
|
<< '\n';
|
||||||
if (this->IsRootMakefile()) {
|
if (this->IsRootMakefile()) {
|
||||||
os << "# Which is the root file." << std::endl;
|
os << "# Which is the root file.\n";
|
||||||
}
|
}
|
||||||
cmGlobalNinjaGenerator::WriteDivider(os);
|
cmGlobalNinjaGenerator::WriteDivider(os);
|
||||||
os << std::endl;
|
os << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmLocalNinjaGenerator::AppendTargetOutputs(cmGeneratorTarget* target,
|
void cmLocalNinjaGenerator::AppendTargetOutputs(cmGeneratorTarget* target,
|
||||||
|
@@ -1328,10 +1328,9 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(
|
|||||||
int result;
|
int result;
|
||||||
if (!ftc->Compare(internalDependFile, tgtInfo, &result) || result < 0) {
|
if (!ftc->Compare(internalDependFile, tgtInfo, &result) || result < 0) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
std::ostringstream msg;
|
cmSystemTools::Stdout(cmStrCat("Dependee \"", tgtInfo,
|
||||||
msg << "Dependee \"" << tgtInfo << "\" is newer than depender \""
|
"\" is newer than depender \"",
|
||||||
<< internalDependFile << "\"." << std::endl;
|
internalDependFile, "\".\n"));
|
||||||
cmSystemTools::Stdout(msg.str());
|
|
||||||
}
|
}
|
||||||
needRescanDependInfo = true;
|
needRescanDependInfo = true;
|
||||||
}
|
}
|
||||||
@@ -1348,10 +1347,9 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(
|
|||||||
if (!ftc->Compare(internalDependFile, dirInfoFile, &result) ||
|
if (!ftc->Compare(internalDependFile, dirInfoFile, &result) ||
|
||||||
result < 0) {
|
result < 0) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
std::ostringstream msg;
|
cmSystemTools::Stdout(cmStrCat("Dependee \"", dirInfoFile,
|
||||||
msg << "Dependee \"" << dirInfoFile << "\" is newer than depender \""
|
"\" is newer than depender \"",
|
||||||
<< internalDependFile << "\"." << std::endl;
|
internalDependFile, "\".\n"));
|
||||||
cmSystemTools::Stdout(msg.str());
|
|
||||||
}
|
}
|
||||||
needRescanDirInfo = true;
|
needRescanDirInfo = true;
|
||||||
}
|
}
|
||||||
@@ -1517,11 +1515,9 @@ void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose)
|
|||||||
if (cmSystemTools::FileExists(dependee) &&
|
if (cmSystemTools::FileExists(dependee) &&
|
||||||
!cmSystemTools::FileExists(depender)) {
|
!cmSystemTools::FileExists(depender)) {
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
std::ostringstream msg;
|
cmSystemTools::Stdout(cmStrCat(
|
||||||
msg << "Deleting primary custom command output \"" << dependee
|
"Deleting primary custom command output \"", dependee,
|
||||||
<< "\" because another output \"" << depender
|
"\" because another output \"", depender, "\" does not exist.\n"));
|
||||||
<< "\" does not exist." << std::endl;
|
|
||||||
cmSystemTools::Stdout(msg.str());
|
|
||||||
}
|
}
|
||||||
cmSystemTools::RemoveFile(dependee);
|
cmSystemTools::RemoveFile(dependee);
|
||||||
}
|
}
|
||||||
@@ -1969,7 +1965,7 @@ std::string cmLocalUnixMakefileGenerator3::GetRecursiveMakeCall(
|
|||||||
void cmLocalUnixMakefileGenerator3::WriteDivider(std::ostream& os)
|
void cmLocalUnixMakefileGenerator3::WriteDivider(std::ostream& os)
|
||||||
{
|
{
|
||||||
os << "#======================================"
|
os << "#======================================"
|
||||||
<< "=======================================\n";
|
"=======================================\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmLocalUnixMakefileGenerator3::WriteCMakeArgument(std::ostream& os,
|
void cmLocalUnixMakefileGenerator3::WriteCMakeArgument(std::ostream& os,
|
||||||
@@ -1977,7 +1973,7 @@ void cmLocalUnixMakefileGenerator3::WriteCMakeArgument(std::ostream& os,
|
|||||||
{
|
{
|
||||||
// Write the given string to the stream with escaping to get it back
|
// Write the given string to the stream with escaping to get it back
|
||||||
// into CMake through the lexical scanner.
|
// into CMake through the lexical scanner.
|
||||||
os << "\"";
|
os << '"';
|
||||||
for (char c : s) {
|
for (char c : s) {
|
||||||
if (c == '\\') {
|
if (c == '\\') {
|
||||||
os << "\\\\";
|
os << "\\\\";
|
||||||
@@ -1987,7 +1983,7 @@ void cmLocalUnixMakefileGenerator3::WriteCMakeArgument(std::ostream& os,
|
|||||||
os << c;
|
os << c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os << "\"";
|
os << '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
|
std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(
|
||||||
|
@@ -300,8 +300,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
|
|||||||
dependFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
|
dependFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
|
||||||
depFileStream << "# Empty dependencies file for "
|
depFileStream << "# Empty dependencies file for "
|
||||||
<< this->GeneratorTarget->GetName() << ".\n"
|
<< this->GeneratorTarget->GetName() << ".\n"
|
||||||
<< "# This may be replaced when dependencies are built."
|
<< "# This may be replaced when dependencies are built.\n";
|
||||||
<< std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the flags file. This should be copy-if-different because the
|
// Open the flags file. This should be copy-if-different because the
|
||||||
|
@@ -72,7 +72,7 @@ bool cmWriteFileCommand(std::vector<std::string> const& args,
|
|||||||
status.SetError(error);
|
status.SetError(error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
file << message << std::endl;
|
file << message << '\n';
|
||||||
file.close();
|
file.close();
|
||||||
if (mode && !writable) {
|
if (mode && !writable) {
|
||||||
cmSystemTools::SetPermissions(fileName.c_str(), mode);
|
cmSystemTools::SetPermissions(fileName.c_str(), mode);
|
||||||
|
Reference in New Issue
Block a user