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
87 lines
2.4 KiB
Bash
Executable File
87 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Reformats a given list of files to match the rocSOLVER style guidelines.
|
|
|
|
display_help() {
|
|
cat <<EOF
|
|
rocSOLVER auto-format script
|
|
|
|
This script changes the given source files to comply with rocSOLVER formatting
|
|
guidelines. It updates the copyright date, ensures files are ASCII-encoded
|
|
fixes minor whitespace issues, and applies clang-format.
|
|
|
|
Usage:
|
|
$0 [--no-clang-format] [--help] [--] files...
|
|
|
|
Options:
|
|
--help Print this help message.
|
|
|
|
--no-clang-format Skip the clang-format step.
|
|
EOF
|
|
}
|
|
|
|
PATH="$(git rev-parse --git-path hooks):/opt/rocm-4.3.1/llvm/bin:/opt/rocm-4.3.0/llvm/bin:$PATH"
|
|
export PATH
|
|
|
|
# Redirect stdout to stderr.
|
|
exec >&2
|
|
|
|
# Set defaults
|
|
apply_clang_format=true
|
|
|
|
# Check getopt version
|
|
getopt -T
|
|
if [[ $? -ne 4 ]]; then
|
|
echo 'getopt version check failed'
|
|
exit 1
|
|
fi
|
|
|
|
# Parse options
|
|
GETOPT_PARSE=$(getopt --name "$0" --longoptions help,no-clang-format --options '' -- "$@")
|
|
if [[ $? -ne 0 ]]; then
|
|
exit 1
|
|
fi
|
|
eval set -- "$GETOPT_PARSE"
|
|
while true; do
|
|
case "$1" in
|
|
--help)
|
|
display_help
|
|
exit ;;
|
|
--no-clang-format)
|
|
apply_clang_format=false
|
|
shift ;;
|
|
--) shift ; break ;;
|
|
esac
|
|
done
|
|
|
|
# Change the copyright date at the top of any text files
|
|
for file in "$@"; do
|
|
perl -pi -e 'INIT { exit 1 if !-f $ARGV[0] || -B $ARGV[0]; $year = (localtime)[5] + 1900 }
|
|
s/^([*\/#[:space:]]*)Copyright\s+(?:\(C\)\s*)?(\d+)(?:\s*-\s*\d+)?/qq($1Copyright (C) $2@{[$year != $2 ? "-$year" : ""]})/ie
|
|
if $. < 10' -- "$file"
|
|
done
|
|
|
|
# Do the formatting
|
|
for file in "$@"; do
|
|
if echo "$file" | grep -Eq '\.c$|\.h$|\.hpp$|\.cpp$|\.cl$|\.in$|\.txt$|\.yaml$|\.sh$|\.py$|\.pl$|\.cmake$|\.md$|\.rst$|\.groovy$|\.m$'; then
|
|
sed -i -e 's/[[:space:]]*$//' -- "$file" # Remove whitespace at end of lines
|
|
sed -i -e '$a\' -- "$file" # Add missing newline to end of file
|
|
|
|
# Convert UTF8 non-ASCII to ASCII
|
|
temp=$(mktemp)
|
|
[[ -w $temp ]] || exit
|
|
iconv -s -f utf-8 -t ascii//TRANSLIT -- "$file" > "$temp" || exit
|
|
chmod --reference="$file" -- "$temp" || exit
|
|
mv -f -- "$temp" "$file" || exit
|
|
fi
|
|
done
|
|
|
|
# Run clang-format on C/C++ files
|
|
if [[ "$apply_clang_format" == true ]]; then
|
|
for file in "$@"; do
|
|
if echo "$file" | grep -Eq '\.c$|\.h$|\.hpp$|\.cpp$|\.cl$|\.h\.in$|\.hpp\.in$|\.cpp\.in$'; then
|
|
clang-format -i -style=file -- "$file"
|
|
fi
|
|
done
|
|
fi
|