Skip to content

Commit 318f41f

Browse files
committed
circular-dependencies: Avoid treating some .h/.cpp files as a unit
This avoids a bogus circular dependency error in the next commit: interfaces/chain -> interfaces/wallet -> wallet/wallet -> interfaces/chain Which is incorrect, because interfaces/chain.cpp depends only on the interfaces/wallet.h file, not the interfaces/wallet.cpp file, and it is wrong to treat these as a unit. Inside the interfaces directory, .h files contain abstract class definitions and .cpp files contain implementations of those classes, so you don't need to link against .cpp files if you're only using the abstract class definition in the .h file. An alternative fix might be to rename all the cpp files in the interfaces directory like: chain.cpp->chain_impl.cpp, node.cpp->node_impl.cpp. But just getting the linter to treat these files as independent dependencies seemed like it would allow keeping code organization straightforward and avoiding the need to rename things.
1 parent d02b34c commit 318f41f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

contrib/devtools/circular-dependencies.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,18 @@
88
'core_write.cpp': 'core_io.cpp',
99
}
1010

11+
# Directories with header-based modules, where the assumption that .cpp files
12+
# define functions and variables declared in corresponding .h files is
13+
# incorrect.
14+
HEADER_MODULE_PATHS = [
15+
'interfaces/'
16+
]
17+
1118
def module_name(path):
1219
if path in MAPPING:
1320
path = MAPPING[path]
21+
if any(path.startswith(dirpath) for dirpath in HEADER_MODULE_PATHS):
22+
return path
1423
if path.endswith(".h"):
1524
return path[:-2]
1625
if path.endswith(".c"):

0 commit comments

Comments
 (0)