mirror of
https://github.com/Kitware/CMake.git
synced 2026-07-13 19:11:23 +00:00
Sort include directives within each block (separated by a blank line) in
lexicographic order (except to prioritize `sys/types.h` first). First
run `clang-format` with the config file:
---
SortIncludes: false
...
Commit the result temporarily. Then run `clang-format` again with:
---
SortIncludes: true
IncludeCategories:
- Regex: 'sys/types.h'
Priority: -1
...
Commit the result temporarily. Start a new branch and cherry-pick the
second commit. Manually resolve conflicts to preserve indentation of
re-ordered includes. This cleans up the include ordering without
changing any other style.
Use the following command to run `clang-format`:
$ git ls-files -z -- \
'*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' |
egrep -z -v '(Lexer|Parser|ParserHelper)\.' |
egrep -z -v '^Source/cm_sha2' |
egrep -z -v '^Source/(kwsys|CursesDialog/form)/' |
egrep -z -v '^Utilities/(KW|cm).*/' |
egrep -z -v '^Tests/Module/GenerateExportHeader' |
egrep -z -v '^Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h' |
xargs -0 clang-format -i
This selects source files that do not come from a third-party.
Inspired-by: Daniel Pfeifer <daniel@pfeifer-mail.de>
199 lines
4.0 KiB
C
199 lines
4.0 KiB
C
#include <preprocess.h>
|
|
|
|
#include FILE_PATH
|
|
#include TARGET_PATH
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
int check_defines_C(void)
|
|
{
|
|
int result = 1;
|
|
if(strcmp(FILE_STRING, STRING_VALUE) != 0)
|
|
{
|
|
fprintf(stderr,
|
|
"FILE_STRING has wrong value in C [%s]\n", FILE_STRING);
|
|
result = 0;
|
|
}
|
|
if(strcmp(TARGET_STRING, STRING_VALUE) != 0)
|
|
{
|
|
fprintf(stderr,
|
|
"TARGET_STRING has wrong value in C [%s]\n", TARGET_STRING);
|
|
result = 0;
|
|
}
|
|
{
|
|
int x = 2;
|
|
int y = 3;
|
|
if((FILE_EXPR) != (EXPR))
|
|
{
|
|
fprintf(stderr, "FILE_EXPR did not work in C [%s]\n",
|
|
TO_STRING(FILE_EXPR));
|
|
result = 0;
|
|
}
|
|
if((TARGET_EXPR) != (EXPR))
|
|
{
|
|
fprintf(stderr, "TARGET_EXPR did not work in C [%s]\n",
|
|
TO_STRING(FILE_EXPR));
|
|
result = 0;
|
|
}
|
|
}
|
|
#ifdef NDEBUG
|
|
# ifdef FILE_DEF_DEBUG
|
|
{
|
|
fprintf(stderr, "FILE_DEF_DEBUG should not be defined in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
# ifdef TARGET_DEF_DEBUG
|
|
{
|
|
fprintf(stderr, "TARGET_DEF_DEBUG should not be defined in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
# ifdef DIRECTORY_DEF_DEBUG
|
|
{
|
|
fprintf(stderr, "DIRECTORY_DEF_DEBUG should not be defined in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
# ifndef FILE_DEF_RELEASE
|
|
# ifndef PREPROCESS_XCODE
|
|
{
|
|
fprintf(stderr, "FILE_DEF_RELEASE should be defined in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
# endif
|
|
# ifndef TARGET_DEF_RELEASE
|
|
{
|
|
fprintf(stderr, "TARGET_DEF_RELEASE should be defined in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
# ifndef DIRECTORY_DEF_RELEASE
|
|
{
|
|
fprintf(stderr, "DIRECTORY_DEF_RELEASE should be defined in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
#endif
|
|
#ifdef PREPROCESS_DEBUG
|
|
# ifndef FILE_DEF_DEBUG
|
|
# ifndef PREPROCESS_XCODE
|
|
{
|
|
fprintf(stderr, "FILE_DEF_DEBUG should be defined in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
# endif
|
|
# ifndef TARGET_DEF_DEBUG
|
|
{
|
|
fprintf(stderr, "TARGET_DEF_DEBUG should be defined in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
# ifndef DIRECTORY_DEF_DEBUG
|
|
{
|
|
fprintf(stderr, "DIRECTORY_DEF_DEBUG should be defined in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
# ifdef FILE_DEF_RELEASE
|
|
{
|
|
fprintf(stderr, "FILE_DEF_RELEASE should not be defined in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
# ifdef TARGET_DEF_RELEASE
|
|
{
|
|
fprintf(stderr, "TARGET_DEF_RELEASE should not be defined in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
# ifdef DIRECTORY_DEF_RELEASE
|
|
{
|
|
fprintf(stderr, "DIRECTORY_DEF_RELEASE should not be defined in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
#endif
|
|
#if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
|
|
# if !defined(FILE_DEF_DEBUG) || !defined(TARGET_DEF_DEBUG)
|
|
# ifndef PREPROCESS_XCODE
|
|
{
|
|
fprintf(stderr,
|
|
"FILE_DEF_DEBUG and TARGET_DEF_DEBUG inconsistent in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
# endif
|
|
# if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
|
|
{
|
|
fprintf(stderr, "DEBUG and RELEASE definitions inconsistent in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
#endif
|
|
#if defined(FILE_DEF_RELEASE) || defined(TARGET_DEF_RELEASE)
|
|
# if !defined(FILE_DEF_RELEASE) || !defined(TARGET_DEF_RELEASE)
|
|
# ifndef PREPROCESS_XCODE
|
|
{
|
|
fprintf(stderr,
|
|
"FILE_DEF_RELEASE and TARGET_DEF_RELEASE inconsistent in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
# endif
|
|
# if defined(FILE_DEF_DEBUG) || defined(TARGET_DEF_DEBUG)
|
|
{
|
|
fprintf(stderr, "RELEASE and DEBUG definitions inconsistent in C\n");
|
|
result = 0;
|
|
}
|
|
# endif
|
|
#endif
|
|
#ifndef FILE_PATH_DEF
|
|
{
|
|
fprintf(stderr, "FILE_PATH_DEF not defined in C\n");
|
|
result = 0;
|
|
}
|
|
#endif
|
|
#ifndef TARGET_PATH_DEF
|
|
{
|
|
fprintf(stderr, "TARGET_PATH_DEF not defined in C\n");
|
|
result = 0;
|
|
}
|
|
#endif
|
|
#ifndef FILE_DEF
|
|
{
|
|
fprintf(stderr, "FILE_DEF not defined in C\n");
|
|
result = 0;
|
|
}
|
|
#endif
|
|
#ifndef TARGET_DEF
|
|
{
|
|
fprintf(stderr, "TARGET_DEF not defined in C\n");
|
|
result = 0;
|
|
}
|
|
#endif
|
|
#ifndef DIRECTORY_DEF
|
|
{
|
|
fprintf(stderr, "DIRECTORY_DEF not defined in C\n");
|
|
result = 0;
|
|
}
|
|
#endif
|
|
#ifndef OLD_DEF
|
|
{
|
|
fprintf(stderr, "OLD_DEF not defined in C\n");
|
|
result = 0;
|
|
}
|
|
#endif
|
|
#if !defined(OLD_EXPR) || OLD_EXPR != 2
|
|
{
|
|
fprintf(stderr, "OLD_EXPR id not work in C [%s]\n",
|
|
TO_STRING(OLD_EXPR));
|
|
result = 0;
|
|
}
|
|
#endif
|
|
return result;
|
|
}
|