Skip to content

Instantly share code, notes, and snippets.

@rizzatti
Created March 4, 2013 01:58
Show Gist options
  • Save rizzatti/5079386 to your computer and use it in GitHub Desktop.
Save rizzatti/5079386 to your computer and use it in GitHub Desktop.
Workaround for header files and compilation database
import os
import re
import ycm_core
from clang_helpers import PrepareClangFlags
DATABASE_FOLDER = '/Users/zeh/code/zed/build'
DATABASE = ycm_core.CompilationDatabase(DATABASE_FOLDER)
EXTRA_FLAGS = [
'-isystem',
'/usr/lib/c++/v1',
'-isystem',
'usr/include/c++/4.2.1',
'-isystem',
'/usr/include/c++/4.2.1/ext',
]
def FlagsForFile(filename):
isHeader = filename.endswith('.hpp')
filename = re.sub(r"(_p)?\.hpp$", ".cpp", filename)
info = DATABASE.GetCompilationInfoForFile(filename)
flags = PrepareClangFlags(info.compiler_flags_, filename)
if isHeader:
flags.extend(EXTRA_FLAGS)
return {
'flags': flags,
'do_cache': True
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment