Skip to content

Commit

Permalink
[cmake_frontend.py] change parameter optionality; return type
Browse files Browse the repository at this point in the history
of function `get_compilation_arguments`
  • Loading branch information
diivm committed Aug 15, 2021
1 parent 6c335a0 commit 3d1a5d4
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions clang_bind/cmake_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,19 @@ def __init__(self, build_dir):
buildDir=build_dir
)

def get_compilation_arguments(self, filename=None):
"""Returns the compilation commands extracted from the compilation database
def get_compilation_arguments(self, filename):
"""Returns the compilation commands extracted from the compilation database.
:param filename: Get compilation arguments of the file, defaults to None: get for all files
:type filename: str, optional
:return: ilenames and their compiler arguments: {filename: compiler arguments}
:rtype: dict
:param filename: Get compilation arguments of the file.
:type filename: str
:return: Compiler arguments.
:rtype: list
"""

if filename:
# Get compilation commands from the compilation database for the given file
compilation_commands = self.compilation_database.getCompileCommands(
filename=filename
)
else:
# Get all compilation commands from the compilation database
compilation_commands = self.compilation_database.getAllCompileCommands()

return {
command.filename: list(command.arguments)[1:-1]
for command in compilation_commands
}
compilation_arguments = []
for command in self.compilation_database.getCompileCommands(filename=filename):
compilation_arguments += list(command.arguments)[1:-1]
return compilation_arguments


class Target:
Expand Down

0 comments on commit 3d1a5d4

Please sign in to comment.