mirror of
https://gitea.windcorp.ru/Wind-Corporation/Progressia.git
synced 2025-04-21 16:00:46 +03:00
TMP / Improved build tools layout
This commit is contained in:
parent
310724a207
commit
553916f8c1
@ -28,7 +28,7 @@ file(MAKE_DIRECTORY "${generated}")
|
|||||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/tools/")
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/tools/")
|
||||||
include(embed/embed)
|
include(embed/embed)
|
||||||
include(glslc)
|
include(glslc)
|
||||||
include(clang-tidy/clang-tidy)
|
include(dev-mode)
|
||||||
|
|
||||||
# Source files
|
# Source files
|
||||||
target_sources(progressia PRIVATE
|
target_sources(progressia PRIVATE
|
||||||
@ -104,7 +104,7 @@ if (WIN32 AND NOT BUILD_ID STREQUAL "dev")
|
|||||||
target_link_options(progressia PRIVATE -static-libstdc++ -static-libgcc)
|
target_link_options(progressia PRIVATE -static-libstdc++ -static-libgcc)
|
||||||
elseif (compiler_cl_dialect STREQUAL "MSVC")
|
elseif (compiler_cl_dialect STREQUAL "MSVC")
|
||||||
target_link_options(progressia PRIVATE /entry:mainCRTStartup)
|
target_link_options(progressia PRIVATE /entry:mainCRTStartup)
|
||||||
|
|
||||||
# The static linking options for standard libraries are not available for MSVC when using a GPLv3 license,
|
# The static linking options for standard libraries are not available for MSVC when using a GPLv3 license,
|
||||||
# as statically linking the standard C/C++ libraries would be a violation of the GPLv3 license.
|
# as statically linking the standard C/C++ libraries would be a violation of the GPLv3 license.
|
||||||
# The GPL requires that any derivative work that includes GPL-licensed code must also be licensed under the GPL,
|
# The GPL requires that any derivative work that includes GPL-licensed code must also be licensed under the GPL,
|
||||||
@ -116,7 +116,7 @@ if (WIN32 AND NOT BUILD_ID STREQUAL "dev")
|
|||||||
# Yours faithfully,
|
# Yours faithfully,
|
||||||
# ChatGPT
|
# ChatGPT
|
||||||
message(WARNING "Release builds with MSVC/Clang-CL are not supported")
|
message(WARNING "Release builds with MSVC/Clang-CL are not supported")
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
if (DEV_MODE)
|
if (DEV_MODE)
|
||||||
find_program(clang_tidy_EXECUTABLE NAMES clang-tidy-13 clang-tidy REQUIRED)
|
find_program(clang_tidy_EXECUTABLE NAMES clang-tidy-13 clang-tidy REQUIRED)
|
||||||
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
||||||
|
|
||||||
# Setup clang-tidy
|
# Setup clang-tidy
|
||||||
set(clang_tidy_config_file "${CMAKE_CURRENT_LIST_DIR}/clang-tidy.yml")
|
|
||||||
list(APPEND clang_tidy_command "${clang_tidy_EXECUTABLE}"
|
list(APPEND clang_tidy_command "${clang_tidy_EXECUTABLE}"
|
||||||
"--config-file=${clang_tidy_config_file}"
|
|
||||||
"--warnings-as-errors=*"
|
"--warnings-as-errors=*"
|
||||||
"--use-color")
|
"--use-color")
|
||||||
|
|
||||||
@ -16,16 +14,16 @@ if (DEV_MODE)
|
|||||||
add_custom_target(clang_tidy_marker ALL
|
add_custom_target(clang_tidy_marker ALL
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo
|
COMMAND ${CMAKE_COMMAND} -E echo
|
||||||
"Clang-tidy is enabled. This is a marker for pre-commit.py")
|
"Clang-tidy is enabled. This is a marker for pre-commit.py")
|
||||||
|
|
||||||
# Notify pre-commit.py about CMake settings
|
# Notify pre-commit.py about CMake settings
|
||||||
execute_process(COMMAND ${Python3_EXECUTABLE} ${tools}/pre-commit.py
|
execute_process(COMMAND ${Python3_EXECUTABLE} ${tools}/pre-commit.py
|
||||||
set-build-info -- "${CMAKE_COMMAND}" "${CMAKE_BINARY_DIR}"
|
set-build-info -- "${CMAKE_COMMAND}" "${CMAKE_BINARY_DIR}"
|
||||||
RESULT_VARIABLE set_build_info_RESULT)
|
RESULT_VARIABLE set_build_info_RESULT)
|
||||||
|
|
||||||
if(${set_build_info_RESULT})
|
if(${set_build_info_RESULT})
|
||||||
message(FATAL_ERROR "pre-commit.py set-build-info failed")
|
message(FATAL_ERROR "pre-commit.py set-build-info failed")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Setup pre-commit git hook
|
# Setup pre-commit git hook
|
||||||
if (IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git/hooks")
|
if (IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git/hooks")
|
||||||
set(pre_commit_hook "${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit")
|
set(pre_commit_hook "${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit")
|
||||||
@ -36,7 +34,7 @@ if (DEV_MODE)
|
|||||||
"# You may modify this hook freely "
|
"# You may modify this hook freely "
|
||||||
"(just make sure the checks run)\n"
|
"(just make sure the checks run)\n"
|
||||||
"/bin/env python3 ${CMAKE_SOURCE_DIR}/tools/pre-commit.py run")
|
"/bin/env python3 ${CMAKE_SOURCE_DIR}/tools/pre-commit.py run")
|
||||||
|
|
||||||
if (${CMAKE_VERSION} VERSION_LESS "3.19.0")
|
if (${CMAKE_VERSION} VERSION_LESS "3.19.0")
|
||||||
if (${CMAKE_HOST_UNIX})
|
if (${CMAKE_HOST_UNIX})
|
||||||
execute_process(COMMAND chmod "+x" "${pre_commit_hook}"
|
execute_process(COMMAND chmod "+x" "${pre_commit_hook}"
|
||||||
@ -52,5 +50,5 @@ if (DEV_MODE)
|
|||||||
endif()
|
endif()
|
||||||
unset(pre_commit_hook)
|
unset(pre_commit_hook)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
@ -48,7 +48,6 @@ import json
|
|||||||
STASH_NAME = 'progressia_pre_commit_stash'
|
STASH_NAME = 'progressia_pre_commit_stash'
|
||||||
# Paths are relative to this script's directory, tools/
|
# Paths are relative to this script's directory, tools/
|
||||||
SETTINGS_PATH = 'pre-commit-settings.json'
|
SETTINGS_PATH = 'pre-commit-settings.json'
|
||||||
CLANG_FORMAT_PATH = 'clang-format/clang-format.json'
|
|
||||||
CLANG_TIDY_CHECK_MARKER = 'Clang-tidy is enabled. ' \
|
CLANG_TIDY_CHECK_MARKER = 'Clang-tidy is enabled. ' \
|
||||||
'This is a marker for pre-commit.py'
|
'This is a marker for pre-commit.py'
|
||||||
|
|
||||||
@ -163,17 +162,10 @@ def do_restore():
|
|||||||
|
|
||||||
def format_project():
|
def format_project():
|
||||||
"""Format staged files with clang-format-diff."""
|
"""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',
|
diff = invoke(*git, 'diff', '-U0', '--no-color', '--relative', 'HEAD',
|
||||||
*(f"{d}/*.{e}" for d in src_dirs for e in exts))
|
*(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)
|
stdin=diff, result_when_dry='', quiet=False)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user