Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
performance
Megadep
Commits
047f4c2e
Commit
047f4c2e
authored
Jul 01, 2019
by
Pádraig Ó Conbhuí
Browse files
Cleaned format.sh. Added lint.sh and .clang-tidy.
parent
33256905
Changes
3
Hide whitespace changes
Inline
Side-by-side
.clang-tidy
0 → 100644
View file @
047f4c2e
---
Checks: '*,-llvm-header-guard'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
User: poconbhui
CheckOptions:
...
tools/format.sh
View file @
047f4c2e
...
...
@@ -12,17 +12,22 @@ suffixes=( .cpp .hpp )
CLANG_FORMAT_EXECUTABLE
=
$(
which clang-format
)
VERBOSE
=
# Options array to store all popped options
declare
-a
options
# Loop over arguments
while
:
do
case
"
$1
"
in
--clang-format
=
*
)
CLANG_FORMAT_EXECUTABLE
=
"
$(
echo
"
$1
"
|
sed
's/--clang-format=//'
)
"
options
=(
"
${
options
[@]
}
"
"
$1
"
)
shift
;;
--verbose
)
VERBOSE
=
"--verbose"
options
=(
"
${
options
[@]
}
"
"
$1
"
)
shift
;;
...
...
@@ -114,4 +119,4 @@ fi
# On some / no file arguments, run the formatter over all the files.
"
${
script_dir
}
"
/list_files.sh
"
${
suffixes
[@]
}
"
"
$@
"
\
| xargs
-n
1
"
$0
"
--clang-format
=
"
${
CLANG_FORMAT_EXECUTABLE
}
"
${
VERBOSE
}
| xargs
-n
1
"
$0
"
"
${
options
[@]
}
"
tools/lint.sh
0 → 100755
View file @
047f4c2e
#!/usr/bin/env bash
# List the suffixes that will be formatted in subdirectory recursion.
suffixes
=(
.cpp .hpp
)
#
# Parse optional arguments
#
# Set defaults for the optional arguments
CLANG_TIDY_EXECUTABLE
=
$(
which clang-tidy
)
VERBOSE
=
declare
-a
options
declare
-a
clang_tidy_options
# Loop over arguments
while
:
do
case
"
$1
"
in
--clang-tidy
=
*
)
CLANG_TIDY_EXECUTABLE
=
"
$(
echo
"
$1
"
|
sed
's/--clang-tidy=//'
)
"
options
=(
"
${
options
[@]
}
"
"
$1
"
)
shift
;;
--verbose
)
VERBOSE
=
"--verbose"
options
=(
"
${
options
[@]
}
"
"
$1
"
)
shift
;;
--help
)
echo
echo
"Usage: lint.sh [OPTIONS] [CLANG_TIDY_OPTIONS] [FILE|DIRECTORY ...]"
echo
echo
"Options:"
echo
" --clang-tidy=CLANG_TIDY_EXECUTABLE"
echo
" Set the clang-tidy executable to use."
echo
echo
" --verbose"
echo
" Enable verbose output"
echo
echo
"Clang Tidy Options:"
echo
" -p=BUILD_DIRECTORY"
echo
echo
"Examples:"
echo
" tidy.sh"
echo
" tidy.sh /path/to/file.cpp"
echo
" tidy.sh --clang-tidy=my-clang-tidy file.cpp"
echo
" tidy.sh -p=/path/to/build /path/to/src"
echo
" tidy.sh file_1.cpp file_2.cpp src/"
echo
echo
"Arguments to be passed to clang-tidy must be of the form"
echo
"
\"
--option
\"
or
\"
--option=value
\"
. This script doesn't"
echo
"check for 2-part arguments."
echo
exit
0
;;
-
*
)
clang_tidy_options
=(
"
${
clang_tidy_options
[@]
}
"
"
$1
"
)
options
=(
"
${
options
[@]
}
"
"
$1
"
)
shift
;;
*
)
break
;;
esac
done
if
[[
-z
"
${
CLANG_TIDY_EXECUTABLE
}
"
]]
then
echo
>
&2
"Error: No clang-tidy executable found!"
exit
1
fi
echo_verbose
()
{
if
[[
-n
"
${
VERBOSE
}
"
]]
then
echo
>
&2
"
$@
"
fi
}
script_dir
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
>
/dev/null 2>&1
&&
pwd
)
"
#
# If given exactly one file argument, parse it.
#
if
[[
$#
-eq
1
]]
&&
[[
-f
"
$1
"
]]
then
target_file
=
$1
# Only lint files with the correct suffix
if
[[
-z
"
$(
"
${
script_dir
}
"
/list_files.sh
"
${
suffixes
[@]
}
"
"
${
target_file
}
"
)
"
]]
then
echo
>
&2
"Error: File suffix not one of:
\"
${
suffixes
[@]
}
\"
"
echo
>
&2
" File:
${
target_file
}
"
exit
1
fi
echo_verbose
"Linting:
${
target_file
}
"
# Run clang-tidy!
"
${
CLANG_TIDY_EXECUTABLE
}
"
"
${
clang_tidy_options
[@]
}
"
"
${
target_file
}
"
exit
0
fi
# On some / no file arguments, run the formatter over all the files.
"
${
script_dir
}
"
/list_files.sh
"
${
suffixes
[@]
}
"
"
$@
"
\
| xargs
-n
1
"
$0
"
"
${
options
[@]
}
"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment