diff options
author | Brad King <brad.king@kitware.com> | 2016-05-17 13:33:02 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-05-17 13:33:02 (GMT) |
commit | 7d2a0aa76c25d92f1e2a03778f5666bdd7e56b92 (patch) | |
tree | 2bdcf15abfef8e197173b5a135fe6b8391e43316 /Utilities | |
parent | 930ac45cbafca79eec9ae68e07c547b5c81b8c2c (diff) | |
parent | d9fd2f5402eeaa345691313658e02b51038f570b (diff) | |
download | CMake-7d2a0aa76c25d92f1e2a03778f5666bdd7e56b92.zip CMake-7d2a0aa76c25d92f1e2a03778f5666bdd7e56b92.tar.gz CMake-7d2a0aa76c25d92f1e2a03778f5666bdd7e56b92.tar.bz2 |
Merge topic 'clang-format-source'
d9fd2f54 Revise C++ coding style using clang-format
82df6dea Empty commit at end of history preceding clang-format style transition
6a13f43f CONTRIBUTING: Add a section on coding style
bf451d9f Add a script to run clang-format on the entire source tree
1e90d78f Configure clang-format for CMake source tree
da60adc3 Tell Git to use a distinct conflict marker size in `.rst` files
Diffstat (limited to 'Utilities')
-rw-r--r-- | Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp | 17 | ||||
-rwxr-xr-x | Utilities/Scripts/clang-format.bash | 91 | ||||
-rw-r--r-- | Utilities/cm_bzlib.h | 4 | ||||
-rw-r--r-- | Utilities/cm_curl.h | 4 | ||||
-rw-r--r-- | Utilities/cm_expat.h | 4 | ||||
-rw-r--r-- | Utilities/cm_jsoncpp_reader.h | 4 | ||||
-rw-r--r-- | Utilities/cm_jsoncpp_value.h | 4 | ||||
-rw-r--r-- | Utilities/cm_jsoncpp_writer.h | 4 | ||||
-rw-r--r-- | Utilities/cm_kwiml.h | 8 | ||||
-rw-r--r-- | Utilities/cm_libarchive.h | 8 | ||||
-rw-r--r-- | Utilities/cm_lzma.h | 4 | ||||
-rw-r--r-- | Utilities/cm_xmlrpc.h | 4 | ||||
-rw-r--r-- | Utilities/cm_zlib.h | 4 |
13 files changed, 124 insertions, 36 deletions
diff --git a/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp b/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp index d4f628c..4b17875 100644 --- a/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp +++ b/Utilities/Release/WiX/CustomAction/detect_nsis_overwrite.cpp @@ -12,20 +12,17 @@ std::wstring get_property(MSIHANDLE msi_handle, std::wstring const& name) UINT status = MsiGetPropertyW(msi_handle, name.c_str(), L"", &size); - if(status == ERROR_MORE_DATA) - { + if (status == ERROR_MORE_DATA) { std::vector<wchar_t> buffer(size + 1); MsiGetPropertyW(msi_handle, name.c_str(), &buffer[0], &size); return std::wstring(&buffer[0]); - } - else - { + } else { return std::wstring(); - } + } } -void set_property(MSIHANDLE msi_handle, - std::wstring const& name, std::wstring const& value) +void set_property(MSIHANDLE msi_handle, std::wstring const& name, + std::wstring const& value) { MsiSetPropertyW(msi_handle, name.c_str(), value.c_str()); } @@ -37,10 +34,10 @@ extern "C" UINT __stdcall DetectNsisOverwrite(MSIHANDLE msi_handle) std::wstring uninstall_exe = install_root + L"\\uninstall.exe"; bool uninstall_exe_exists = - GetFileAttributesW(uninstall_exe.c_str()) != INVALID_FILE_ATTRIBUTES; + GetFileAttributesW(uninstall_exe.c_str()) != INVALID_FILE_ATTRIBUTES; set_property(msi_handle, L"CMAKE_NSIS_OVERWRITE_DETECTED", - uninstall_exe_exists ? L"1" : L"0"); + uninstall_exe_exists ? L"1" : L"0"); return ERROR_SUCCESS; } diff --git a/Utilities/Scripts/clang-format.bash b/Utilities/Scripts/clang-format.bash new file mode 100755 index 0000000..2090a1a --- /dev/null +++ b/Utilities/Scripts/clang-format.bash @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +#============================================================================= +# Copyright 2015-2016 Kitware, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= + +usage='usage: clang-format.bash [<options>] [--] + + --clang-format <tool> Use given clang-format tool. +' + +die() { + echo "$@" 1>&2; exit 1 +} + +#----------------------------------------------------------------------------- + +# Parse command-line arguments. +clang_format='' +while test "$#" != 0; do + case "$1" in + --clang-format) shift; clang_format="$1" ;; + --) shift ; break ;; + -*) die "$usage" ;; + *) break ;; + esac + shift +done +test "$#" = 0 || die "$usage" + +# Find a default tool. +tools=' + clang-format + clang-format-3.8 +' +if test "x$clang_format" = "x"; then + for tool in $tools; do + if type -p "$tool" >/dev/null; then + clang_format="$tool" + break + fi + done +fi + +# Verify that we have a tool. +if ! type -p "$clang_format" >/dev/null; then + echo "Unable to locate '$clang_format'" + exit 1 +fi + +# Filter sources to which our style should apply. +git ls-files -z -- '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' | + + # Exclude lexer/parser generator input and output. + egrep -z -v '^Source/cmCommandArgumentLexer\.' | + egrep -z -v '^Source/cmCommandArgumentParser(\.y|\.cxx|Tokens\.h)' | + egrep -z -v '^Source/cmDependsJavaLexer\.' | + egrep -z -v '^Source/cmDependsJavaParser(\.y|\.cxx|Tokens\.h)' | + egrep -z -v '^Source/cmExprLexer\.' | + egrep -z -v '^Source/cmExprParser(\.y|\.cxx|Tokens\.h)' | + egrep -z -v '^Source/cmFortranLexer\.' | + egrep -z -v '^Source/cmFortranParser(\.y|\.cxx|Tokens\.h)' | + egrep -z -v '^Source/cmListFileLexer(\.in\.l|\.c)' | + + # Exclude third-party sources. + egrep -z -v '^Source/(cm_sha2|bindexplib)' | + egrep -z -v '^Source/(kwsys|CursesDialog/form)/' | + egrep -z -v '^Utilities/(KW|cm).*/' | + + # Exclude reference content. + egrep -z -v '^Tests/Module/GenerateExportHeader/reference/' | + + # Exclude manually-formatted sources (e.g. with long lines). + egrep -z -v '^Tests/PositionIndependentTargets/pic_test.h' | + + # Exclude sources with encoding not suported by clang-format. + egrep -z -v '^Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h' | + + # Update sources in-place. + xargs -0 "$clang_format" -i diff --git a/Utilities/cm_bzlib.h b/Utilities/cm_bzlib.h index 5678025..0eb7bd8 100644 --- a/Utilities/cm_bzlib.h +++ b/Utilities/cm_bzlib.h @@ -15,9 +15,9 @@ /* Use the bzip2 library configured for CMake. */ #include "cmThirdParty.h" #ifdef CMAKE_USE_SYSTEM_BZIP2 -# include <bzlib.h> +#include <bzlib.h> #else -# include <cmbzip2/bzlib.h> +#include <cmbzip2/bzlib.h> #endif #endif diff --git a/Utilities/cm_curl.h b/Utilities/cm_curl.h index c9835e7..bf4c63c 100644 --- a/Utilities/cm_curl.h +++ b/Utilities/cm_curl.h @@ -15,9 +15,9 @@ /* Use the curl library configured for CMake. */ #include "cmThirdParty.h" #ifdef CMAKE_USE_SYSTEM_CURL -# include <curl/curl.h> +#include <curl/curl.h> #else -# include <cmcurl/include/curl/curl.h> +#include <cmcurl/include/curl/curl.h> #endif #endif diff --git a/Utilities/cm_expat.h b/Utilities/cm_expat.h index d35e106..c6c6683 100644 --- a/Utilities/cm_expat.h +++ b/Utilities/cm_expat.h @@ -15,9 +15,9 @@ /* Use the expat library configured for CMake. */ #include "cmThirdParty.h" #ifdef CMAKE_USE_SYSTEM_EXPAT -# include <expat.h> +#include <expat.h> #else -# include <cmexpat/lib/expat.h> +#include <cmexpat/lib/expat.h> #endif #endif diff --git a/Utilities/cm_jsoncpp_reader.h b/Utilities/cm_jsoncpp_reader.h index 22f2d81..019044e 100644 --- a/Utilities/cm_jsoncpp_reader.h +++ b/Utilities/cm_jsoncpp_reader.h @@ -15,9 +15,9 @@ /* Use the jsoncpp library configured for CMake. */ #include "cmThirdParty.h" #ifdef CMAKE_USE_SYSTEM_JSONCPP -# include <json/reader.h> +#include <json/reader.h> #else -# include <cmjsoncpp/include/json/reader.h> +#include <cmjsoncpp/include/json/reader.h> #endif #endif diff --git a/Utilities/cm_jsoncpp_value.h b/Utilities/cm_jsoncpp_value.h index b4cf620..81c9ae0 100644 --- a/Utilities/cm_jsoncpp_value.h +++ b/Utilities/cm_jsoncpp_value.h @@ -15,9 +15,9 @@ /* Use the jsoncpp library configured for CMake. */ #include "cmThirdParty.h" #ifdef CMAKE_USE_SYSTEM_JSONCPP -# include <json/value.h> +#include <json/value.h> #else -# include <cmjsoncpp/include/json/value.h> +#include <cmjsoncpp/include/json/value.h> #endif #endif diff --git a/Utilities/cm_jsoncpp_writer.h b/Utilities/cm_jsoncpp_writer.h index c99a0d0..597539d 100644 --- a/Utilities/cm_jsoncpp_writer.h +++ b/Utilities/cm_jsoncpp_writer.h @@ -15,9 +15,9 @@ /* Use the jsoncpp library configured for CMake. */ #include "cmThirdParty.h" #ifdef CMAKE_USE_SYSTEM_JSONCPP -# include <json/writer.h> +#include <json/writer.h> #else -# include <cmjsoncpp/include/json/writer.h> +#include <cmjsoncpp/include/json/writer.h> #endif #endif diff --git a/Utilities/cm_kwiml.h b/Utilities/cm_kwiml.h index ab2b80b..fce8881 100644 --- a/Utilities/cm_kwiml.h +++ b/Utilities/cm_kwiml.h @@ -15,11 +15,11 @@ /* Use the KWIML library configured for CMake. */ #include "cmThirdParty.h" #ifdef CMAKE_USE_SYSTEM_KWIML -# include <kwiml/abi.h> -# include <kwiml/int.h> +#include <kwiml/abi.h> +#include <kwiml/int.h> #else -# include "KWIML/include/kwiml/abi.h" -# include "KWIML/include/kwiml/int.h" +#include "KWIML/include/kwiml/abi.h" +#include "KWIML/include/kwiml/int.h" #endif #endif diff --git a/Utilities/cm_libarchive.h b/Utilities/cm_libarchive.h index 0f18c91..c6a8a82 100644 --- a/Utilities/cm_libarchive.h +++ b/Utilities/cm_libarchive.h @@ -15,11 +15,11 @@ /* Use the libarchive configured for CMake. */ #include "cmThirdParty.h" #ifdef CMAKE_USE_SYSTEM_LIBARCHIVE -# include <archive.h> -# include <archive_entry.h> +#include <archive.h> +#include <archive_entry.h> #else -# include <cmlibarchive/libarchive/archive.h> -# include <cmlibarchive/libarchive/archive_entry.h> +#include <cmlibarchive/libarchive/archive.h> +#include <cmlibarchive/libarchive/archive_entry.h> #endif #endif diff --git a/Utilities/cm_lzma.h b/Utilities/cm_lzma.h index 02d7e4f..20cf1d7 100644 --- a/Utilities/cm_lzma.h +++ b/Utilities/cm_lzma.h @@ -15,9 +15,9 @@ /* Use the liblzma configured for CMake. */ #include "cmThirdParty.h" #ifdef CMAKE_USE_SYSTEM_LIBLZMA -# include <lzma.h> +#include <lzma.h> #else -# include <cmliblzma/liblzma/api/lzma.h> +#include <cmliblzma/liblzma/api/lzma.h> #endif #endif diff --git a/Utilities/cm_xmlrpc.h b/Utilities/cm_xmlrpc.h index ac461f9..0bc93f4 100644 --- a/Utilities/cm_xmlrpc.h +++ b/Utilities/cm_xmlrpc.h @@ -15,8 +15,8 @@ /* Use the xmlrpc library configured for CMake. */ #include "cmThirdParty.h" #ifdef CTEST_USE_XMLRPC -# include <xmlrpc.h> -# include <xmlrpc_client.h> +#include <xmlrpc.h> +#include <xmlrpc_client.h> #endif #endif diff --git a/Utilities/cm_zlib.h b/Utilities/cm_zlib.h index 1b5c06e..6ff8e6c 100644 --- a/Utilities/cm_zlib.h +++ b/Utilities/cm_zlib.h @@ -15,9 +15,9 @@ /* Use the zlib library configured for CMake. */ #include "cmThirdParty.h" #ifdef CMAKE_USE_SYSTEM_ZLIB -# include <zlib.h> +#include <zlib.h> #else -# include <cmzlib/zlib.h> +#include <cmzlib/zlib.h> #endif #endif |