mirror of https://gitlab.com/ita1024/waf.git
Fix relative path comparisons in clang_compilation_database
This commit is contained in:
parent
38b6f24d73
commit
16dbeb73e8
|
@ -46,7 +46,7 @@ class ClangDbContext(Build.BuildContext):
|
||||||
'''generates compile_commands.json by request'''
|
'''generates compile_commands.json by request'''
|
||||||
cmd = 'clangdb'
|
cmd = 'clangdb'
|
||||||
clang_compilation_database_tasks = []
|
clang_compilation_database_tasks = []
|
||||||
|
|
||||||
def write_compilation_database(self):
|
def write_compilation_database(self):
|
||||||
"""
|
"""
|
||||||
Write the clang compilation database as JSON
|
Write the clang compilation database as JSON
|
||||||
|
@ -63,9 +63,8 @@ class ClangDbContext(Build.BuildContext):
|
||||||
cmd = task.last_cmd
|
cmd = task.last_cmd
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
continue
|
continue
|
||||||
directory = getattr(task, 'cwd', self.variant_dir)
|
|
||||||
f_node = task.inputs[0]
|
f_node = task.inputs[0]
|
||||||
filename = os.path.relpath(f_node.abspath(), directory)
|
filename = f_node.path_from(task.getcwd())
|
||||||
entry = {
|
entry = {
|
||||||
"directory": directory,
|
"directory": directory,
|
||||||
"arguments": cmd,
|
"arguments": cmd,
|
||||||
|
@ -91,7 +90,7 @@ class ClangDbContext(Build.BuildContext):
|
||||||
# exec_command temporarily
|
# exec_command temporarily
|
||||||
def exec_command(self, *k, **kw):
|
def exec_command(self, *k, **kw):
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
for g in self.groups:
|
for g in self.groups:
|
||||||
for tg in g:
|
for tg in g:
|
||||||
try:
|
try:
|
||||||
|
@ -100,7 +99,7 @@ class ClangDbContext(Build.BuildContext):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
f()
|
f()
|
||||||
|
|
||||||
if isinstance(tg, Task.Task):
|
if isinstance(tg, Task.Task):
|
||||||
lst = [tg]
|
lst = [tg]
|
||||||
else: lst = tg.tasks
|
else: lst = tg.tasks
|
||||||
|
@ -117,7 +116,7 @@ class ClangDbContext(Build.BuildContext):
|
||||||
EXECUTE_PATCHED = False
|
EXECUTE_PATCHED = False
|
||||||
def patch_execute():
|
def patch_execute():
|
||||||
global EXECUTE_PATCHED
|
global EXECUTE_PATCHED
|
||||||
|
|
||||||
if EXECUTE_PATCHED:
|
if EXECUTE_PATCHED:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -127,11 +126,11 @@ def patch_execute():
|
||||||
"""
|
"""
|
||||||
if type(self) == Build.BuildContext:
|
if type(self) == Build.BuildContext:
|
||||||
Scripting.run_command('clangdb')
|
Scripting.run_command('clangdb')
|
||||||
|
|
||||||
old_execute_build(self)
|
old_execute_build(self)
|
||||||
|
|
||||||
old_execute_build = getattr(Build.BuildContext, 'execute_build', None)
|
old_execute_build = getattr(Build.BuildContext, 'execute_build', None)
|
||||||
setattr(Build.BuildContext, 'execute_build', new_execute_build)
|
setattr(Build.BuildContext, 'execute_build', new_execute_build)
|
||||||
EXECUTE_PATCHED = True
|
EXECUTE_PATCHED = True
|
||||||
|
|
||||||
patch_execute()
|
patch_execute()
|
||||||
|
|
Loading…
Reference in New Issue