Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Utils
source-formatters
Commits
77185029
Commit
77185029
authored
Nov 07, 2019
by
Ben Boeckel
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clang-format: add version-variable clang-format script
parent
1557bcef
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
57 additions
and
0 deletions
+57
-0
src/c/CMakeLists.txt
src/c/CMakeLists.txt
+2
-0
src/c/format.clang-format
src/c/format.clang-format
+37
-0
test/clang-format/CMakeLists.txt
test/clang-format/CMakeLists.txt
+3
-0
test/clang-format/format/.clang-format
test/clang-format/format/.clang-format
+3
-0
test/clang-format/format/format.c
test/clang-format/format/format.c
+3
-0
test/clang-format/format/format.c.clean
test/clang-format/format/format.c.clean
+3
-0
test/clang-format/format/format.c.expect
test/clang-format/format/format.c.expect
+1
-0
test/clang-format/no-config-file/format.c
test/clang-format/no-config-file/format.c
+0
-0
test/clang-format/no-config-file/format.c.clean
test/clang-format/no-config-file/format.c.clean
+0
-0
test/clang-format/pass/.clang-format
test/clang-format/pass/.clang-format
+3
-0
test/clang-format/pass/format.c
test/clang-format/pass/format.c
+1
-0
test/clang-format/pass/format.c.clean
test/clang-format/pass/format.c.clean
+1
-0
No files found.
src/c/CMakeLists.txt
View file @
77185029
...
...
@@ -8,6 +8,8 @@ foreach(v
add_formatter
(
clang-format-
${
v
}
reformat clang-format-
${
v
}
)
set_property
(
GLOBAL PROPERTY
"formatter_clang-format-
${
v
}
_exclude_from_all"
"1"
)
endforeach
()
add_formatter
(
clang-format reformat clang-format
)
set_property
(
GLOBAL PROPERTY
"formatter_clang-format_exclude_from_all"
"1"
)
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
)
...
...
src/c/format.clang-format
0 → 100755
View file @
77185029
#!/bin/sh
# This formatter uses the `clang-format` tool to perform
# formatting of files written in C, C++, and other C-like
# languages (CUDA, GLSL, etc.).
#
# It uses the `clang-format` executable in `$PATH` and checks for
# the existence of the `.clang-format` file as its configuration.
set
-e
readonly
path
=
"
$1
"
shift
if
[
"$#"
-ne
0
]
;
then
readonly
version
=
"-
$1
"
shift
else
version
=
""
fi
readonly
value
if
!
[
-f
"
$path
"
]
;
then
echo
>
&2
'error: could not find file to format: '
"
$path
"
exit
4
fi
if
!
which
"clang-format
$version
"
>
/dev/null
;
then
echo
>
&2
'error: could not find the `clang-format'
"
$version
"
'` binary'
exit
3
fi
if
!
[
-f
".clang-format"
]
;
then
echo
>
&2
'error: the `.clang-format` file is missing'
exit
2
fi
exec
"clang-format
$version
"
-i
"
$path
"
test/clang-format/CMakeLists.txt
0 → 100644
View file @
77185029
add_formatter_test
(
clang-format pass format.c pass
)
add_formatter_test
(
clang-format format format.c format
)
add_formatter_test
(
clang-format no-config-file format.c fail
)
test/clang-format/format/.clang-format
0 → 100644
View file @
77185029
---
Language: Cpp
...
test/clang-format/format/format.c
0 → 100644
View file @
77185029
int
main
(
int
argc
,
char
*
argv
[])
{
return
0
;
}
test/clang-format/format/format.c.clean
0 → 100644
View file @
77185029
int main(int argc, char *argv[]) {
return 0;
}
test/clang-format/format/format.c.expect
0 → 100644
View file @
77185029
int main(int argc, char *argv[]) { return 0; }
test/clang-format/no-config-file/format.c
0 → 100644
View file @
77185029
test/clang-format/no-config-file/format.c.clean
0 → 100644
View file @
77185029
test/clang-format/pass/.clang-format
0 → 100644
View file @
77185029
---
Language: Cpp
...
test/clang-format/pass/format.c
0 → 100644
View file @
77185029
int
main
(
int
argc
,
char
*
argv
[])
{
return
0
;
}
test/clang-format/pass/format.c.clean
0 → 100644
View file @
77185029
int main(int argc, char *argv[]) { return 0; }
Brad King
@brad.king
mentioned in commit
58f389b1
·
Nov 08, 2019
mentioned in commit
58f389b1
mentioned in commit 58f389b18cf867647ee5b40cd1fa1ab67c6f4170
Toggle commit list
Write
Preview
Markdown
is supported
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