mdbx-make: don't use clang-format < 10 to avoid misformating.

Change-Id: I58d3b5071011a106b1801a1bd966f5c2d8354fcb
This commit is contained in:
Leonid Yuriev 2020-05-05 18:52:32 +03:00
parent bc9c5bad5d
commit c99f258a47
2 changed files with 18 additions and 12 deletions

View File

@ -253,17 +253,23 @@ else()
add_custom_target(ctags DEPENDS tags) add_custom_target(ctags DEPENDS tags)
endif(CTAGS) endif(CTAGS)
# Enable 'make reformat' target. if(UNIX)
find_program(CLANG_FORMAT find_program(CLANG_FORMAT
NAMES clang-format-11.0 clang-format-10.0 clang-format-9.0 clang-format-8.0 clang-format) NAMES clang-format-12 clang-format-11 clang-format-10 clang-format)
if(CLANG_FORMAT AND UNIX) if(CLANG_FORMAT)
add_custom_target(reformat execute_process(COMMAND ${CLANG_FORMAT} "--version" OUTPUT_VARIABLE clang_format_version_info)
VERBATIM string(REGEX MATCH "version ([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)?" clang_format_version_info CLANG_FORMAT_VERSION)
COMMAND if(clang_format_version_info AND NOT CLANG_FORMAT_VERSION VERSION_LESS 10.0)
git ls-files | # Enable 'make reformat' target.
grep -E \\.\(c|cxx|cc|cpp|h|hxx|hpp\)\(\\.in\)?\$ | add_custom_target(reformat
xargs ${CLANG_FORMAT} -i --style=file VERBATIM
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) COMMAND
git ls-files |
grep -E \\.\(c|cxx|cc|cpp|h|hxx|hpp\)\(\\.in\)?\$ |
xargs ${CLANG_FORMAT} -i --style=file
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif()
endif()
endif() endif()
if(NOT "${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}") if(NOT "${PROJECT_BINARY_DIR}" STREQUAL "${PROJECT_SOURCE_DIR}")

View File

@ -128,7 +128,7 @@ CXX ?= g++
CXXSTD ?= $(shell $(CXX) -std=c++27 -c test/test.cc -o /dev/null 2>/dev/null && echo -std=c++17 || echo -std=c++11) CXXSTD ?= $(shell $(CXX) -std=c++27 -c test/test.cc -o /dev/null 2>/dev/null && echo -std=c++17 || echo -std=c++11)
CXXFLAGS := $(CXXSTD) $(filter-out -std=gnu11,$(CFLAGS)) CXXFLAGS := $(CXXSTD) $(filter-out -std=gnu11,$(CFLAGS))
TAR ?= $(shell which gnu-tar || echo tar) TAR ?= $(shell which gnu-tar || echo tar)
CLANG_FORMAT ?= $(shell (which clang-format || which clang-format-8 || which clang-format-9 || which clang-format-10 || which clang-format-11 || which clang-format-12) 2>/dev/null) CLANG_FORMAT ?= $(shell (which clang-format-12 || which clang-format-11 || which clang-format-10 || which clang-format) 2>/dev/null)
reformat: reformat:
@if [ -n "$(CLANG_FORMAT)" ]; then \ @if [ -n "$(CLANG_FORMAT)" ]; then \