Skip to content

Commit d945452

Browse files
Adapt cpplint header guard check
to deal with non-top-level `src` and `unit` directories
1 parent 85e8451 commit d945452

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scripts/cpplint.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,8 +1971,13 @@ def GetHeaderGuardCPPVariable(filename):
19711971

19721972
fileinfo = FileInfo(filename)
19731973
file_path_from_root = fileinfo.RepositoryName()
1974-
# Remove first path component
1975-
offset=len(file_path_from_root.split(os.path.sep)[0])+1
1974+
# Remove up to including `src` component
1975+
path_components = file_path_from_root.split(os.path.sep)
1976+
offset = 0
1977+
for component in path_components:
1978+
offset += len(component) + 1
1979+
if component == 'src' or component == 'unit':
1980+
break
19761981
file_path_from_root = 'CPROVER_' + file_path_from_root[offset:]
19771982
if _root:
19781983
suffix = os.sep

0 commit comments

Comments
 (0)