Changeset View
Changeset View
Standalone View
Standalone View
contrib/devtools/circular-dependencies.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
import re | import re | ||||
import sys | import sys | ||||
MAPPING = { | MAPPING = { | ||||
'core_read.cpp': 'core_io.cpp', | 'core_read.cpp': 'core_io.cpp', | ||||
'core_write.cpp': 'core_io.cpp', | 'core_write.cpp': 'core_io.cpp', | ||||
} | } | ||||
# Directories with header-based modules, where the assumption that .cpp files | |||||
# define functions and variables declared in corresponding .h files is | |||||
# incorrect. | |||||
HEADER_MODULE_PATHS = [ | |||||
'interfaces/' | |||||
] | |||||
def module_name(path): | def module_name(path): | ||||
if path in MAPPING: | if path in MAPPING: | ||||
path = MAPPING[path] | path = MAPPING[path] | ||||
if any(path.startswith(dirpath) for dirpath in HEADER_MODULE_PATHS): | |||||
return path | |||||
if path.endswith(".h"): | if path.endswith(".h"): | ||||
return path[:-2] | return path[:-2] | ||||
if path.endswith(".c"): | if path.endswith(".c"): | ||||
return path[:-2] | return path[:-2] | ||||
if path.endswith(".cpp"): | if path.endswith(".cpp"): | ||||
return path[:-4] | return path[:-4] | ||||
return None | return None | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |