diff options
author | Brad King <brad.king@kitware.com> | 2016-05-06 18:19:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-06 18:25:55 (GMT) |
commit | 64b5520346c75ec479042a114390a0bf71909723 (patch) | |
tree | bea1373e84594ba036fe50eea3eab86375d63aa6 /Source/cmLocalUnixMakefileGenerator3.cxx | |
parent | 73601ff831faa80a188e5997ee048b6986b00a5c (diff) | |
download | CMake-64b5520346c75ec479042a114390a0bf71909723.zip CMake-64b5520346c75ec479042a114390a0bf71909723.tar.gz CMake-64b5520346c75ec479042a114390a0bf71909723.tar.bz2 |
Isolate formatted streaming blocks with clang-format off/on
The clang-format tool can do a good job formatting most code, but
well-organized streaming blocks are best left manually formatted.
Find blocks of the form
os <<
"...\n"
"...\n"
;
using the command
$ git ls-files -z -- Source |
egrep -v -z '^Source/kwsys/' |
xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
'<<[^\n]*\n(^ *("[^\n]*("|<<|;)$|;)\n){2,}'
Find blocks of the form
os << "...\n"
<< "...\n"
<< "...\n";
using the command
$ git ls-files -z -- Source |
egrep -v -z '^Source/kwsys/' |
xargs -0 pcregrep -M --color=always -B 1 -A 1 -n \
'<<[^\n]*\n(^ *<<[^\n]*(\\n"|<<|;)$\n){2,}'
Surround such blocks with the pair
/* clang-format off */
...
/* clang-format on */
in order to protect them from update by clang-format. Use the C-style
`/*...*/` comments instead of C++-style `//...` comments in order to
prevent them from ever being swallowed by re-formatting of surrounding
comments.
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator3.cxx')
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 2a0e07d..7a404af 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -519,6 +519,7 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() this->WriteDisclaimer(infoFileStream); // Setup relative path conversion tops. + /* clang-format off */ infoFileStream << "# Relative path conversion top directories.\n" << "set(CMAKE_RELATIVE_PATH_TOP_SOURCE \"" @@ -528,14 +529,17 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() << this->StateSnapshot.GetDirectory().GetRelativePathTopBinary() << "\")\n" << "\n"; + /* clang-format on */ // Tell the dependency scanner to use unix paths if necessary. if(cmSystemTools::GetForceUnixPaths()) { + /* clang-format off */ infoFileStream << "# Force unix paths in dependencies.\n" << "set(CMAKE_FORCE_UNIX_PATHS 1)\n" << "\n"; + /* clang-format on */ } // Store the include regular expressions for this directory. @@ -718,13 +722,16 @@ cmLocalUnixMakefileGenerator3 else { #if !defined(__VMS) + /* clang-format off */ makefileStream << "# The shell in which to execute make rules.\n" << "SHELL = /bin/sh\n" << "\n"; + /* clang-format on */ #endif } + /* clang-format off */ makefileStream << "# The CMake executable.\n" << "CMAKE_COMMAND = " @@ -753,6 +760,7 @@ cmLocalUnixMakefileGenerator3 << this->Convert(this->GetBinaryDirectory(), FULL, SHELL) << "\n" << "\n"; + /* clang-format on */ } //---------------------------------------------------------------------------- @@ -793,27 +801,33 @@ cmLocalUnixMakefileGenerator3 // Switch on WMake feature, if an error or interrupt occurs during // makefile processing, the current target being made may be deleted // without prompting (the same as command line -e option). + /* clang-format off */ makefileStream << "\n" ".ERASE\n" "\n" ; + /* clang-format on */ } if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")) { + /* clang-format off */ makefileStream << "# Produce verbose output by default.\n" << "VERBOSE = 1\n" << "\n"; + /* clang-format on */ } if(this->IsWatcomWMake()) { + /* clang-format off */ makefileStream << "!ifndef VERBOSE\n" ".SILENT\n" "!endif\n" "\n" ; + /* clang-format on */ } else { @@ -1252,12 +1266,14 @@ cmLocalUnixMakefileGenerator3 std::set<std::string> languages; target->GetLanguages(languages, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")); + /* clang-format off */ fout << "\n" << "# Per-language clean rules from dependency scanning.\n" << "foreach(lang " << cmJoin(languages, " ") << ")\n" << " include(" << this->GetTargetDirectory(target) << "/cmake_clean_${lang}.cmake OPTIONAL)\n" << "endforeach()\n"; + /* clang-format on */ } } @@ -2083,10 +2099,12 @@ void cmLocalUnixMakefileGenerator3 this->ConfigName, l->first); if(!defines.empty()) { + /* clang-format off */ cmakefileStream << "\n" << "# Preprocessor definitions for this target.\n" << "set(CMAKE_TARGET_DEFINITIONS_" << l->first << "\n"; + /* clang-format on */ for(std::set<std::string>::const_iterator di = defines.begin(); di != defines.end(); ++di) { |