Commit a023478b authored by Matthew Woehlke's avatar Matthew Woehlke

uncrustify: add formatter

parent 0a62b768
......@@ -10,3 +10,5 @@ foreach(v
endforeach()
add_formatter(clang-format-kwsys reformat clang-format-3.8)
set_property(GLOBAL PROPERTY "formatter_clang-format-kwsys_exclude_from_all" "1")
add_formatter(uncrustify reformat uncrustify)
set_property(GLOBAL PROPERTY "formatter_uncrustify_exclude_from_all" "1")
#!/bin/sh
# This formatter uses the `uncrustify` tool to perform formatting of files
# written in C, C++, and other C-like languages (CUDA, GLSL, etc.).
#
# It uses the `uncrustify` executable in `$PATH` and checks for the existence
# of the `.uncrustify.cfg` file as its configuration.
set -e
readonly path="$1"
shift
if ! [ -f "$path" ]; then
echo >&2 'error: could not find file to format: '"$path"
exit 4
fi
if ! type "uncrustify" > /dev/null; then
echo >&2 'error: could not find the `uncrustify` binary'
exit 3
fi
if ! [ -f ".uncrustify.cfg" ]; then
echo >&2 'error: the `.uncrustify.cfg` file is missing'
exit 2
fi
exec uncrustify -c .uncrustify.cfg --replace --no-backup "$path"
formatter_uncrustify:
kind: "uncrustify"
script: "@script@"
config_files:
- ".uncrustify.cfg"
add_formatter_test(uncrustify pass format.c pass)
add_formatter_test(uncrustify format format.c format)
add_formatter_test(uncrustify no-config-file format.c fail)
This diff is collapsed.
int main(int argc, char *argv[]) {
return 0;
}
int main(int argc, char *argv[]) {
return 0;
}
int
main( int argc, char* argv[] )
{
return 0;
}
This diff is collapsed.
int
main( int argc, char* argv[] ) { return 0; }
int
main( int argc, char* argv[] ) { return 0; }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment