mirror of
https://gitea.windcorp.ru/Wind-Corporation/Progressia.git
synced 2025-08-28 14:46:51 +03:00
TMP / Improved build tools layout
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"BasedOnStyle": "LLVM",
|
||||
"IndentWidth": 4,
|
||||
"CommentPragmas": "NOLINT",
|
||||
}
|
@@ -1,78 +0,0 @@
|
||||
Checks: "-*,\
|
||||
clang-analyzer-*,\
|
||||
cppcoreguidelines-*,\
|
||||
modernize-*,\
|
||||
performance-*,\
|
||||
readability-*,\
|
||||
clang-diagnostic-*,\
|
||||
-modernize-use-trailing-return-type,\
|
||||
-readability-implicit-bool-conversion,\
|
||||
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,\
|
||||
-cppcoreguidelines-pro-type-reinterpret-cast,\
|
||||
-cppcoreguidelines-pro-bounds-constant-array-index,\
|
||||
-*-avoid-c-arrays,\
|
||||
-readability-else-after-return,\
|
||||
-readability-named-parameter,\
|
||||
-readability-use-anyofallof,\
|
||||
-cppcoreguidelines-pro-bounds-pointer-arithmetic,\
|
||||
-performance-trivially-destructible,\
|
||||
-modernize-make-unique,\
|
||||
-cppcoreguidelines-prefer-member-initializer,\
|
||||
-*-magic-numbers,\
|
||||
-readability-suspicious-call-argument,\
|
||||
-cppcoreguidelines-pro-type-union-access"
|
||||
|
||||
# modernize-use-trailing-return-type
|
||||
# ignore reason: reduces readability
|
||||
|
||||
# readability-implicit-bool-conversion
|
||||
# ignore reason: expected use by C libraries (GLFW, Vulkan API)
|
||||
|
||||
# cppcoreguidelines-pro-bounds-array-to-pointer-decay
|
||||
# ignore reason: expected use by C libraries
|
||||
|
||||
# cppcoreguidelines-pro-type-reinterpret-cast
|
||||
# ignore reason: expected use by C libraries
|
||||
|
||||
# cppcoreguidelines-pro-bounds-constant-array-index
|
||||
# ignore reason: infeasible to avoid without GSL
|
||||
|
||||
# *-avoid-c-arrays
|
||||
# ignore reason: often makes code significantly more verbose
|
||||
|
||||
# readability-else-after-return
|
||||
# ignore reason: personal preference of OLEGSHA (using 'else' helps highlight
|
||||
# branches in code)
|
||||
|
||||
# readability-named-parameter
|
||||
# ignore reason: using GCC convention is clear enough
|
||||
|
||||
# readability-use-anyofallof
|
||||
# ignore reason: these relatively obscure functions reduce readability by
|
||||
# increasing code complexity and verbosity
|
||||
|
||||
# cppcoreguidelines-pro-bounds-pointer-arithmetic
|
||||
# ignore reason: infeasible to avoid in C++17
|
||||
|
||||
# performance-trivially-destructible
|
||||
# ignore reason: breaks incapsulation too often
|
||||
|
||||
# modernize-make-unique
|
||||
# ignore reason: impossible with brace-init lists:
|
||||
# struct S { int a; int b; };
|
||||
# std::unique_ptr<S>(new S { 1, 2 }) // works
|
||||
# std::make_unique<S>(1, 2) // error
|
||||
# std::make_unique<S>({1, 2}) // error
|
||||
|
||||
# cppcoreguidelines-prefer-member-initializer
|
||||
# ignore reason: rule fails to notice execution order dependencies
|
||||
|
||||
# *-magic-numbers
|
||||
# ignore reason: triggers in many trivial cases (e.g. 6 sides of a cube);
|
||||
# infeasible to avoid while writing placeholder code
|
||||
|
||||
# readability-suspicious-call-argument
|
||||
# ignore reason: trips up on geometry code (y no NOLINTBEGIN, Debian?)
|
||||
|
||||
# cppcoreguidelines-pro-type-union-access
|
||||
# ignore reason: triggers on GLM code
|
@@ -1,11 +1,9 @@
|
||||
if (DEV_MODE)
|
||||
find_program(clang_tidy_EXECUTABLE NAMES clang-tidy-13 clang-tidy REQUIRED)
|
||||
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
||||
|
||||
|
||||
# Setup clang-tidy
|
||||
set(clang_tidy_config_file "${CMAKE_CURRENT_LIST_DIR}/clang-tidy.yml")
|
||||
list(APPEND clang_tidy_command "${clang_tidy_EXECUTABLE}"
|
||||
"--config-file=${clang_tidy_config_file}"
|
||||
"--warnings-as-errors=*"
|
||||
"--use-color")
|
||||
|
||||
@@ -16,16 +14,16 @@ if (DEV_MODE)
|
||||
add_custom_target(clang_tidy_marker ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E echo
|
||||
"Clang-tidy is enabled. This is a marker for pre-commit.py")
|
||||
|
||||
|
||||
# Notify pre-commit.py about CMake settings
|
||||
execute_process(COMMAND ${Python3_EXECUTABLE} ${tools}/pre-commit.py
|
||||
set-build-info -- "${CMAKE_COMMAND}" "${CMAKE_BINARY_DIR}"
|
||||
RESULT_VARIABLE set_build_info_RESULT)
|
||||
|
||||
|
||||
if(${set_build_info_RESULT})
|
||||
message(FATAL_ERROR "pre-commit.py set-build-info failed")
|
||||
endif()
|
||||
|
||||
|
||||
# Setup pre-commit git hook
|
||||
if (IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git/hooks")
|
||||
set(pre_commit_hook "${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit")
|
||||
@@ -36,7 +34,7 @@ if (DEV_MODE)
|
||||
"# You may modify this hook freely "
|
||||
"(just make sure the checks run)\n"
|
||||
"/bin/env python3 ${CMAKE_SOURCE_DIR}/tools/pre-commit.py run")
|
||||
|
||||
|
||||
if (${CMAKE_VERSION} VERSION_LESS "3.19.0")
|
||||
if (${CMAKE_HOST_UNIX})
|
||||
execute_process(COMMAND chmod "+x" "${pre_commit_hook}"
|
||||
@@ -52,5 +50,5 @@ if (DEV_MODE)
|
||||
endif()
|
||||
unset(pre_commit_hook)
|
||||
endif()
|
||||
|
||||
|
||||
endif()
|
@@ -48,7 +48,6 @@ import json
|
||||
STASH_NAME = 'progressia_pre_commit_stash'
|
||||
# Paths are relative to this script's directory, tools/
|
||||
SETTINGS_PATH = 'pre-commit-settings.json'
|
||||
CLANG_FORMAT_PATH = 'clang-format/clang-format.json'
|
||||
CLANG_TIDY_CHECK_MARKER = 'Clang-tidy is enabled. ' \
|
||||
'This is a marker for pre-commit.py'
|
||||
|
||||
@@ -163,17 +162,10 @@ def do_restore():
|
||||
|
||||
def format_project():
|
||||
"""Format staged files with clang-format-diff."""
|
||||
print('Formatting code')
|
||||
format_file = os.path.join(os.path.dirname(__file__),
|
||||
CLANG_FORMAT_PATH)
|
||||
|
||||
with open(format_file, encoding='utf-8') as f:
|
||||
style = f.read()
|
||||
|
||||
diff = invoke(*git, 'diff', '-U0', '--no-color', '--relative', 'HEAD',
|
||||
*(f"{d}/*.{e}" for d in src_dirs for e in exts))
|
||||
|
||||
invoke(*clang_format_diff, '-p1', '-i', '--verbose', '-style=' + style,
|
||||
invoke(*clang_format_diff, '-p1', '-i', '--verbose',
|
||||
stdin=diff, result_when_dry='', quiet=False)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user