-
Notifications
You must be signed in to change notification settings - Fork 228
/
Copy pathrun_clang_format.sh
41 lines (35 loc) · 1.37 KB
/
run_clang_format.sh
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
34
35
36
37
38
39
40
41
#!/bin/bash
# ============================================================================ #
# Copyright (c) 2022 - 2025 NVIDIA Corporation & Affiliates. #
# All rights reserved. #
# #
# This source code and the accompanying materials are made available under #
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #
# Usage:
# bash scripts/run_clang_format.sh
# -or-
# bash scripts/run_clang_format.sh -p /path/to/clang-format
#
# By default, this script will use the clang-format executable
# in your PATH, but you can modify that with the -p command line option.
# Process command line arguments
__optind__=$OPTIND
OPTIND=1
while getopts ":p:" opt; do
case $opt in
p) clang_format_executable="$OPTARG"
;;
\?) echo "Invalid command line option -$OPTARG" >&2
exit 1
;;
esac
done
OPTIND=$__optind__
clang_format_executable=${clang_format_executable:-clang-format}
# Run the script from the top-level of the repo
cd $(git rev-parse --show-toplevel)
# Run Clang Format
git ls-files -- '*.cpp' '*.h' ':!:tpls/*' ':!:test' ':!:targettests' | xargs $clang_format_executable -i
# Take us back to where we were
cd -