Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,5 @@ SpacesBeforeTrailingComments: 1
# SpacesInParentheses: false
# SpacesInSquareBrackets: false
TabWidth: 4
UseCRLF: true
UseCRLF: false
UseTab: Always
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ root = true

[*]
charset = utf-8
end_of_line = crlf
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v6.0.2
- name: Run clang-format style check for C/C++.
uses: jidicula/clang-format-action@v4.9.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-hub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ jobs:

- name: Upload digest
if: (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) && github.event_name != 'pull_request'
uses: actions/upload-artifact@v6.0.0
uses: actions/upload-artifact@v7.0.0
with:
name: digests-${{ env.PLATFORM_SAFE }}
path: .bake/digests/*
Expand Down
24 changes: 22 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,29 @@ install(FILES README.md DESTINATION ${INSTALL_ROOT} COMPONENT runtime)
#

if(OPTION_GIT_HOOKS)
message(STATUS "Installing git hooks at ${CMAKE_CURRENT_SOURCE_DIR}")
# macOS shares the POSIX hook scripts with Linux/BSD; there is no
# separate githooks/macos/ directory.
if(PROJECT_OS_FAMILY STREQUAL "macos")
set(_hooks_family "unix")
else()
set(_hooks_family "${PROJECT_OS_FAMILY}")
endif()

message(STATUS "Installing git hooks at ${CMAKE_CURRENT_SOURCE_DIR}/githooks/${_hooks_family}")

execute_process(
COMMAND git config --local core.hooksPath githooks/${PROJECT_OS_FAMILY}
COMMAND git config --local core.hooksPath githooks/${_hooks_family}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE _git_hooks_result
)

if(NOT _git_hooks_result EQUAL 0)
message(WARNING
"Failed to install git hooks (is git available and is this a git repository?). "
"Run manually: git config --local core.hooksPath githooks/${_hooks_family}"
)
endif()

unset(_hooks_family)
unset(_git_hooks_result)
endif()
33 changes: 32 additions & 1 deletion cmake/ClangDevTools.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# See FindClangFormat.cmake
# Variables of interest on this file: ${ClangFormat_VERSION} and ${ClangFormat_EXECUTABLE}
# Variables of interest on this file: ${ClangFormat_VERSION}, ${ClangFormat_EXECUTABLE}, ${ClangFormat_USE_DOCKER}

# Get only C/C++ files for now
file(GLOB_RECURSE
Expand All @@ -16,6 +16,36 @@ file(GLOB_RECURSE
${CMAKE_SOURCE_DIR}/source/**/*.inl
)

if(ClangFormat_USE_DOCKER)
message(STATUS
"clang-format target will run via Docker (ghcr.io/jidicula/clang-format:12). "
"Pulling image now to avoid latency at build time..."
)

# Pull the image at configure time so `cmake --build . --target clang-format`
# does not stall on the first run waiting for the pull.
execute_process(
COMMAND docker pull ghcr.io/jidicula/clang-format:12
RESULT_VARIABLE _docker_pull_result
OUTPUT_QUIET
ERROR_QUIET
)

if(NOT _docker_pull_result EQUAL 0)
message(WARNING
"Failed to pull ghcr.io/jidicula/clang-format:12 at configure time. "
"The image will be pulled on the first `clang-format` build target invocation, "
"or the pull may fail if there is no network access / Docker daemon is not running."
)
else()
message(STATUS "Docker image ghcr.io/jidicula/clang-format:12 is ready.")
endif()

unset(_docker_pull_result)
else()
message(STATUS "clang-format target will use native binary: ${ClangFormat_EXECUTABLE} (version ${ClangFormat_VERSION})")
endif()

# clang-tidy not implemented yet
#add_custom_target(
# clang-tidy
Expand All @@ -34,4 +64,5 @@ add_custom_target(
-style=file
-i
${ALL_SOURCE_FILES}
COMMENT "Running clang-format 12 on all source files..."
)
20 changes: 20 additions & 0 deletions cmake/CompileOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,26 @@ else()
set(TESTS_MEMCHECK_ENVIRONMENT_VARIABLES)
endif()

# Warn loudly when a sanitizer is requested with a build type that will not
# activate it. Silent no-ops here cost hours of debugging as happened in node_ci.
foreach(_san_opt
OPTION_BUILD_THREAD_SANITIZER
OPTION_BUILD_MEMORY_SANITIZER
OPTION_BUILD_ADDRESS_SANITIZER
)
if(${_san_opt} AND
NOT CMAKE_BUILD_TYPE STREQUAL "Debug" AND
NOT CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
message(WARNING
"${_san_opt} is ON but CMAKE_BUILD_TYPE is '${CMAKE_BUILD_TYPE}'. "
"Sanitizers only activate for Debug and RelWithDebInfo builds - "
"the sanitizer will have NO EFFECT. "
"Reconfigure with -DCMAKE_BUILD_TYPE=Debug to enable it."
)
endif()
endforeach()
unset(_san_opt)

# ThreadSanitizer is incompatible with AddressSanitizer and LeakSanitizer
if(OPTION_BUILD_THREAD_SANITIZER AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
set(SANITIZER_LIBRARIES -ltsan)
Expand Down
Loading