[ycm] Fix YouCompleteMe config
The .ycm_extra_conf.py is out of date with the current build settings and ycm versions. In particular, ycm expects a `Settings` function, a couple of more flags need to be passed and some includes are marked -isystem now. Also, we can use the C++ standard from the ninja files instead of hard-coding it. Change-Id: Ibaed29eb341346a86b6b736f95c97b41957f62de Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3980257 Reviewed-by: Clemens Backes <clemensb@chromium.org> Reviewed-by: Michael Achenbach <machenbach@chromium.org> Auto-Submit: Olivier Flückiger <olivf@chromium.org> Commit-Queue: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/main@{#84013}
This commit is contained in:
parent
cecd01ac18
commit
5a2eb4a2aa
@ -42,7 +42,6 @@ import sys
|
|||||||
# Flags from YCM's default config.
|
# Flags from YCM's default config.
|
||||||
flags = [
|
flags = [
|
||||||
'-DUSE_CLANG_COMPLETER',
|
'-DUSE_CLANG_COMPLETER',
|
||||||
'-std=gnu++14',
|
|
||||||
'-x',
|
'-x',
|
||||||
'c++',
|
'c++',
|
||||||
]
|
]
|
||||||
@ -143,23 +142,25 @@ def GetClangCommandFromNinjaForFilename(v8_root, filename):
|
|||||||
# Parse flags that are important for YCM's purposes.
|
# Parse flags that are important for YCM's purposes.
|
||||||
for flag in clang_line.split(' '):
|
for flag in clang_line.split(' '):
|
||||||
if flag.startswith('-I'):
|
if flag.startswith('-I'):
|
||||||
|
v8_flags.append(MakeIncludePathAbsolute(flag, "-I", out_dir))
|
||||||
|
elif flag.startswith('-isystem'):
|
||||||
|
v8_flags.append(MakeIncludePathAbsolute(flag, "-isystem", out_dir))
|
||||||
|
elif flag.startswith('-std') or flag.startswith(
|
||||||
|
'-pthread') or flag.startswith('-no'):
|
||||||
|
v8_flags.append(flag)
|
||||||
|
elif flag.startswith('-') and flag[1] in 'DWFfmgOX':
|
||||||
|
v8_flags.append(flag)
|
||||||
|
return v8_flags
|
||||||
|
|
||||||
|
|
||||||
|
def MakeIncludePathAbsolute(flag, prefix, out_dir):
|
||||||
# Relative paths need to be resolved, because they're relative to the
|
# Relative paths need to be resolved, because they're relative to the
|
||||||
# output dir, not the source.
|
# output dir, not the source.
|
||||||
if flag[2] == '/':
|
if flag[len(prefix)] == '/':
|
||||||
v8_flags.append(flag)
|
return flag
|
||||||
else:
|
else:
|
||||||
abs_path = os.path.normpath(os.path.join(out_dir, flag[2:]))
|
abs_path = os.path.normpath(os.path.join(out_dir, flag[len(prefix):]))
|
||||||
v8_flags.append('-I' + abs_path)
|
return prefix + abs_path
|
||||||
elif flag.startswith('-std'):
|
|
||||||
v8_flags.append(flag)
|
|
||||||
elif flag.startswith('-') and flag[1] in 'DWFfmO':
|
|
||||||
if flag == '-Wno-deprecated-register' or flag == '-Wno-header-guard':
|
|
||||||
# These flags causes libclang (3.3) to crash. Remove it until things
|
|
||||||
# are fixed.
|
|
||||||
continue
|
|
||||||
v8_flags.append(flag)
|
|
||||||
|
|
||||||
return v8_flags
|
|
||||||
|
|
||||||
|
|
||||||
def FlagsForFile(filename):
|
def FlagsForFile(filename):
|
||||||
@ -180,3 +181,9 @@ def FlagsForFile(filename):
|
|||||||
'flags': final_flags,
|
'flags': final_flags,
|
||||||
'do_cache': True
|
'do_cache': True
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def Settings(**kwargs):
|
||||||
|
if kwargs['language'] == 'cfamily':
|
||||||
|
return FlagsForFile(kwargs['filename'])
|
||||||
|
return {}
|
||||||
|
Loading…
Reference in New Issue
Block a user