Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AFLplusplus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ulf Kargén
AFLplusplus
Commits
aca63d49
Commit
aca63d49
authored
5 years ago
by
Andrea Fioraldi
Browse files
Options
Downloads
Patches
Plain Diff
custom format now search for the best clang-format version
parent
bae398a9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.clang-format
+1
-1
1 addition, 1 deletion
.clang-format
.custom-format.py
+26
-2
26 additions, 2 deletions
.custom-format.py
with
27 additions
and
3 deletions
.clang-format
+
1
−
1
View file @
aca63d49
...
@@ -124,7 +124,7 @@ RawStringFormats:
...
@@ -124,7 +124,7 @@ RawStringFormats:
CanonicalDelimiter: ''
CanonicalDelimiter: ''
BasedOnStyle: google
BasedOnStyle: google
ReflowComments: true
ReflowComments: true
SortIncludes:
tru
e
SortIncludes:
fals
e
SortUsingDeclarations: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceAfterTemplateKeyword: true
...
...
This diff is collapsed.
Click to expand it.
.custom-format.py
+
26
−
2
View file @
aca63d49
...
@@ -2,10 +2,34 @@
...
@@ -2,10 +2,34 @@
import
subprocess
import
subprocess
import
sys
import
sys
import
os
with
open
(
"
.clang-format
"
)
as
f
:
with
open
(
"
.clang-format
"
)
as
f
:
fmt
=
f
.
read
()
fmt
=
f
.
read
()
CLANG_FORMAT_BIN
=
os
.
getenv
(
"
CLANG_FORMAT_BIN
"
)
if
CLANG_FORMAT_BIN
is
None
:
p
=
subprocess
.
Popen
([
"
clang-format
"
,
"
--version
"
],
stdout
=
subprocess
.
PIPE
)
o
,
_
=
p
.
communicate
()
o
=
str
(
o
,
"
utf-8
"
)
o
=
o
[
len
(
"
clang-format version
"
):].
strip
()
o
=
o
[:
o
.
find
(
"
.
"
)]
o
=
int
(
o
)
if
o
<
7
:
if
subprocess
.
call
([
'
which
'
,
'
clang-format-7
'
],
stdout
=
subprocess
.
PIPE
)
==
0
:
CLANG_FORMAT_BIN
=
'
clang-format-7
'
elif
subprocess
.
call
([
'
which
'
,
'
clang-format-8
'
],
stdout
=
subprocess
.
PIPE
)
==
0
:
CLANG_FORMAT_BIN
=
'
clang-format-8
'
elif
subprocess
.
call
([
'
which
'
,
'
clang-format-9
'
],
stdout
=
subprocess
.
PIPE
)
==
0
:
CLANG_FORMAT_BIN
=
'
clang-format-9
'
elif
subprocess
.
call
([
'
which
'
,
'
clang-format-10
'
],
stdout
=
subprocess
.
PIPE
)
==
0
:
CLANG_FORMAT_BIN
=
'
clang-format-10
'
else
:
print
(
"
clang-format 7 or above is needed. Aborted.
"
)
exit
(
1
)
else
:
CLANG_FORMAT_BIN
=
'
clang-format
'
COLUMN_LIMIT
=
80
COLUMN_LIMIT
=
80
for
line
in
fmt
.
split
(
"
\n
"
):
for
line
in
fmt
.
split
(
"
\n
"
):
line
=
line
.
split
(
"
:
"
)
line
=
line
.
split
(
"
:
"
)
...
@@ -13,7 +37,7 @@ for line in fmt.split("\n"):
...
@@ -13,7 +37,7 @@ for line in fmt.split("\n"):
COLUMN_LIMIT
=
int
(
line
[
1
].
strip
())
COLUMN_LIMIT
=
int
(
line
[
1
].
strip
())
def
custom_format
(
filename
):
def
custom_format
(
filename
):
p
=
subprocess
.
Popen
([
'
clang-format-7
'
,
filename
],
stdout
=
subprocess
.
PIPE
)
p
=
subprocess
.
Popen
([
CLANG_FORMAT_BIN
,
filename
],
stdout
=
subprocess
.
PIPE
)
src
,
_
=
p
.
communicate
()
src
,
_
=
p
.
communicate
()
src
=
str
(
src
,
"
utf-8
"
)
src
=
str
(
src
,
"
utf-8
"
)
...
@@ -28,7 +52,7 @@ def custom_format(filename):
...
@@ -28,7 +52,7 @@ def custom_format(filename):
i
-=
1
i
-=
1
elif
line
.
startswith
(
"
#el
"
)
and
macro_indent
>
0
:
elif
line
.
startswith
(
"
#el
"
)
and
macro_indent
>
0
:
i
-=
1
i
-=
1
elif
line
.
startswith
(
"
#if
"
)
and
not
(
line
.
startswith
(
"
#ifndef
"
)
and
line
.
endswith
(
"
_H
"
)):
elif
line
.
startswith
(
"
#if
"
)
and
not
(
line
.
startswith
(
"
#ifndef
"
)
and
(
line
.
endswith
(
"
_H
"
)
or
line
.
endswith
(
"
H_
"
))
):
macro_indent
+=
1
macro_indent
+=
1
r
=
"
#
"
+
(
i
*
"
"
)
+
line
[
1
:]
r
=
"
#
"
+
(
i
*
"
"
)
+
line
[
1
:]
if
i
!=
0
and
line
.
endswith
(
"
\\
"
):
if
i
!=
0
and
line
.
endswith
(
"
\\
"
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment