CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
64 lines
2.6 KiB
CMake
64 lines
2.6 KiB
CMake
# Copyright © Advanced Micro Devices, Inc., or its affiliates.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
set(CLANG_FORMAT_PRUNE -path "./build" -prune -o -path "./install" -prune -o -path "./fin" -prune -o)
|
|
|
|
# Use the pip-installed clang-format (/usr/local/bin/clang-format) so the version matches
|
|
# the mirrors-clang-format rev pinned in .pre-commit-config.yaml (currently 18.1.4).
|
|
# Falls back to clang-format on PATH if the pip binary is not at the expected location.
|
|
if(EXISTS /usr/local/bin/clang-format)
|
|
set(CLANG_FORMAT_BINARY /usr/local/bin/clang-format)
|
|
else()
|
|
find_program(CLANG_FORMAT_BINARY clang-format)
|
|
endif()
|
|
|
|
find_program(PRE_COMMIT_BINARY pre-commit)
|
|
get_filename_component(REPO_ROOT "${CMAKE_SOURCE_DIR}/../.." ABSOLUTE)
|
|
|
|
if(NOT EXISTS "${REPO_ROOT}/.pre-commit-config.yaml")
|
|
message(WARNING "Expected .pre-commit-config.yaml not found at ${REPO_ROOT}; pre-commit checks will be skipped")
|
|
set(PRE_COMMIT_BINARY "")
|
|
endif()
|
|
|
|
add_custom_target(
|
|
check_format
|
|
COMMAND find . ${CLANG_FORMAT_PRUNE} -regex ".*\\.\\(cpp\\|hpp\\|h.in\\|hpp.in\\|cpp.in\\|cl\\)" -exec ${CLANG_FORMAT_BINARY} --dry-run --Werror --verbose {} +
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
COMMENT "clang-format: Checking C/C++ source formatting"
|
|
VERBATIM
|
|
)
|
|
|
|
if(PRE_COMMIT_BINARY)
|
|
# pre-commit exits 1 when it modifies files (expected); only fail on higher codes.
|
|
add_custom_target(
|
|
pre_commit_checks
|
|
COMMAND sh -c "${PRE_COMMIT_BINARY} run --files $(git ls-files projects/miopen); rc=$?; [ $rc -le 1 ] || exit $rc"
|
|
WORKING_DIRECTORY ${REPO_ROOT}
|
|
VERBATIM
|
|
)
|
|
else()
|
|
message(WARNING "pre-commit not found; pre_commit_checks target will not be available and pre-commit checks are skipped in format")
|
|
|
|
add_custom_target(
|
|
pre_commit_checks
|
|
COMMAND ${CMAKE_COMMAND} -E echo "pre-commit not found, skipping pre-commit checks"
|
|
)
|
|
endif()
|
|
|
|
if(PRE_COMMIT_BINARY)
|
|
add_custom_target(
|
|
format
|
|
COMMAND find . ${CLANG_FORMAT_PRUNE} -regex ".*\\.\\(cpp\\|hpp\\|h.in\\|hpp.in\\|cpp.in\\|cl\\)" -exec ${CLANG_FORMAT_BINARY} --verbose -i {} +
|
|
COMMAND sh -c "cd ${REPO_ROOT} && ${PRE_COMMIT_BINARY} run --files $(git ls-files projects/miopen); rc=$?; [ $rc -le 1 ] || exit $rc"
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
VERBATIM
|
|
)
|
|
else()
|
|
add_custom_target(
|
|
format
|
|
COMMAND find . ${CLANG_FORMAT_PRUNE} -regex ".*\\.\\(cpp\\|hpp\\|h.in\\|hpp.in\\|cpp.in\\|cl\\)" -exec ${CLANG_FORMAT_BINARY} --verbose -i {} +
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
VERBATIM
|
|
)
|
|
endif()
|