X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=.ycm_extra_conf.py;h=a90610d29d2d1b422c9be335d3f37880e9c0aafd;hp=06a234466121fdde6e34c39807badd94a0bd32ec;hb=2cba2e03524ec0922ddc70f933e8a89b7d23b4ec;hpb=328b5bc96e452b67ae2eb3dee3a09ff3ce03f662 diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py index 06a234466..a90610d29 100644 --- a/.ycm_extra_conf.py +++ b/.ycm_extra_conf.py @@ -1,32 +1,14 @@ +import itertools import os -import ycm_core -from clang_helpers import PrepareClangFlags - -compilation_database_folder = '' - -flags = [ -'-include', -'./config.h', -'-I', -'/usr/include/dbus-1.0', -'-I', -'./src/shared', -'-Wall', -'-Wextra', -'-Werror', -'-Wno-long-long', -'-Wno-variadic-macros', -'-fexceptions', -'-DNDEBUG', -'-DUSE_CLANG_COMPLETER', -'-D_GNU_SOURCE', -'-std=c99', -] - -if compilation_database_folder: - database = ycm_core.CompilationDatabase(compilation_database_folder) -else: - database = None +import subprocess + +def GetFlagsFromMakefile(varname): + return subprocess.check_output([ + "make", "-s", "print-%s" % varname]).decode().split() + + +def Flatten(lists): + return list(itertools.chain.from_iterable(lists)) def DirectoryOfThisScript(): @@ -63,19 +45,22 @@ def MakeRelativePathsInFlagsAbsolute(flags, working_directory): def FlagsForFile(filename): - if database: - compilation_info = database.GetCompilationInfoForFile(filename) - final_flags = PrepareClangFlags( - MakeRelativePathsInFlagsAbsolute( - compilation_info.compiler_flags_, - compilation_info.compiler_working_dir_), - filename) - - else: - relative_to = DirectoryOfThisScript() - final_flags = MakeRelativePathsInFlagsAbsolute(flags, relative_to) + relative_to = DirectoryOfThisScript() return { - 'flags': final_flags, + 'flags': MakeRelativePathsInFlagsAbsolute(flags, relative_to), 'do_cache': True } + +flags = Flatten(map(GetFlagsFromMakefile, [ + 'AM_CPPFLAGS', + 'CPPFLAGS', + 'AM_CFLAGS', + 'CFLAGS', +])) + +# these flags cause crashes in libclang, so remove them +flags.remove('-Wlogical-op') +flags.remove('-Wsuggest-attribute=noreturn') + +# vim: set et ts=2 sw=2: