Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cef
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Web
cef
Commits
f6eb19f8
Commit
f6eb19f8
authored
May 19, 2017
by
Marshall Greenblatt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix discovery of the .clang-format file (issue #2171)
parent
24e20aec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
4 deletions
+14
-4
tools/clang_util.py
tools/clang_util.py
+12
-2
tools/fix_style.py
tools/fix_style.py
+1
-1
tools/translator.py
tools/translator.py
+1
-1
No files found.
tools/clang_util.py
View file @
f6eb19f8
...
...
@@ -3,16 +3,26 @@
# can be found in the LICENSE file
from
exec_util
import
exec_cmd
import
os
import
sys
# Script directory.
script_dir
=
os
.
path
.
dirname
(
__file__
)
root_dir
=
os
.
path
.
join
(
script_dir
,
os
.
pardir
)
if
sys
.
platform
==
'win32'
:
# Force use of the clang-format version bundled with depot_tools.
clang_format_exe
=
'clang-format.bat'
else
:
clang_format_exe
=
'clang-format'
def
clang_format
(
file_contents
):
result
=
exec_cmd
(
clang_format_exe
,
"."
,
file_contents
)
def
clang_format
(
file_name
,
file_contents
):
# -assume-filename is necessary to find the .clang-format file and determine
# the language when specifying contents via stdin.
result
=
exec_cmd
(
"%s -assume-filename=%s"
%
(
clang_format_exe
,
file_name
),
\
root_dir
,
file_contents
)
if
result
[
'err'
]
!=
''
:
print
"clang-format error: %s"
%
result
[
'err'
]
if
result
[
'out'
]
!=
''
:
output
=
result
[
'out'
]
if
sys
.
platform
==
'win32'
:
...
...
tools/fix_style.py
View file @
f6eb19f8
...
...
@@ -34,7 +34,7 @@ def update_file(filename):
msg
(
filename
,
"empty"
)
return
;
newcontents
=
clang_format
(
oldcontents
)
newcontents
=
clang_format
(
filename
,
oldcontents
)
if
newcontents
is
None
:
raise
Exception
(
"Failed to process %s"
%
filename
)
...
...
tools/translator.py
View file @
f6eb19f8
...
...
@@ -124,7 +124,7 @@ def update_file(file, newcontents):
# Apply clang-format for C/C++ files.
if
os
.
path
.
splitext
(
file
)[
1
][
1
:]
in
(
'cc'
,
'cpp'
,
'h'
):
result
=
clang_format
(
newcontents
)
result
=
clang_format
(
file
,
newcontents
)
if
result
!=
None
:
newcontents
=
result
else
:
...
...
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