[systemd-commits] Makefile.am .ycm_extra_conf.py
Dave Reisner
dreisner at kemper.freedesktop.org
Sat Jan 11 10:38:46 PST 2014
.ycm_extra_conf.py | 67 +++++++++++++++++++----------------------------------
Makefile.am | 4 +++
2 files changed, 29 insertions(+), 42 deletions(-)
New commits:
commit 0d8efe3535b3ce9ecbc2c6482007edfc3ac492d0
Author: Dave Reisner <dreisner at archlinux.org>
Date: Sun Nov 24 08:56:56 2013 -0500
ycm: autocompose flags from the Makefile
This should hopefully be self-maintaining.
diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py
index 57b868a..a90610d 100644
--- a/.ycm_extra_conf.py
+++ b/.ycm_extra_conf.py
@@ -1,34 +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',
-'-I',
-'./src/systemd',
-'-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():
@@ -65,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:
diff --git a/Makefile.am b/Makefile.am
index 8b3b81d..65b445e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5081,3 +5081,7 @@ tests += \
cppcheck:
cppcheck --enable=all -q $(top_srcdir)
+
+# Used to extract compile flags for YCM.
+print-%:
+ @echo $($*)
More information about the systemd-commits
mailing list