Skip to content

Commit fb04e7f

Browse files
committed
[cmake_frontend.py] add get_library_targets; add some documentation
1 parent d9a26ff commit fb04e7f

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

clang_bind/cmake_frontend.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55

66
class CompilationDatabase:
7-
"""Class to get information from a CMake compilation database."""
7+
"""Class to get information from a CMake compilation database.
8+
9+
:param build_dir: Build directory path, where compile_commands.json is present.
10+
:type build_dir: str
11+
"""
812

913
def __init__(self, build_dir):
1014
self.compilation_database = clang.CompilationDatabase.fromDirectory(
@@ -36,7 +40,11 @@ def get_compilation_arguments(self, filename=None):
3640

3741

3842
class Target:
39-
"""Class to get information about targets found from the CMake file API."""
43+
"""Class to get information about targets found from the CMake file API.
44+
45+
:param target_file: Target file path.
46+
:type target_file: str
47+
"""
4048

4149
def __init__(self, target_file):
4250
with open(target_file) as f:
@@ -196,7 +204,11 @@ def get_type(self):
196204

197205

198206
class CMakeFileAPI:
199-
"""CMake File API front end."""
207+
"""CMake File API front end.
208+
209+
:param build_dir: Build directory path, where .cmake directory is present.
210+
:type build_dir: str
211+
"""
200212

201213
def __init__(self, build_dir):
202214
self.reply_dir = Path(build_dir, ".cmake", "api", "v1", "reply")
@@ -220,6 +232,17 @@ def _set_targets_from_codemodel(self):
220232
target_obj = Target(Path(self.reply_dir, target_file))
221233
self.targets[target_obj.get_name()] = target_obj
222234

235+
def get_library_targets(self):
236+
"""Get all library targets' names.
237+
238+
:return: Library targets.
239+
:rtype: list
240+
"""
241+
library_targets_objs = filter(
242+
lambda target: target.get_type() == "SHARED_LIBRARY", self.targets.values()
243+
)
244+
return list(map(lambda target: target.get_name(), library_targets_objs))
245+
223246
def get_dependencies(self, target=None):
224247
"""Get dependencies of the target(s).
225248

0 commit comments

Comments
 (0)