File: format.sh

package info (click to toggle)
sundials 7.1.1%2Bdfsg1-10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 83,788 kB
  • sloc: ansic: 264,746; f90: 120,987; cpp: 69,481; python: 5,134; sh: 2,483; makefile: 266; perl: 123
file content (33 lines) | stat: -rwxr-xr-x 1,189 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# ---------------------------------------------------------------------------------
# SUNDIALS Copyright Start
# Copyright (c) 2002-2024, Lawrence Livermore National Security
# and Southern Methodist University.
# All rights reserved.
#
# See the top-level LICENSE and NOTICE files for details.
#
# SPDX-License-Identifier: BSD-3-Clause
# SUNDIALS Copyright End
# ---------------------------------------------------------------------------------
# This script will use clang-tidy and clang-format to format C/C++ code and
# fprettify for Fortran code.
#
# Usage:
#    ./format.sh <paths to directories or files to format>
#
# We require clang-format 17.0.4. Other versions may produce different styles!
# ---------------------------------------------------------------------------------

if [ $# -lt 1 ]; then
    echo "ERROR: At least one path to format required"
    exit 1
fi

paths=( "$@" )

find "${paths[@]}" -iname '*.h' -o -iname '*.hpp' -o \
  -iname '*.c' -o -iname '*.cpp' -o \
  -iname '*.cuh' -o -iname '*.cu' | grep -v fmod | xargs clang-format -i

find "${paths[@]}" -iname '*.f90' | grep -v fmod | xargs fprettify --indent 2 --enable-replacements --c-relations