Skip to content

Commit

Permalink
Add the workaround from cpradog/.ycm_extra_conf.py@aad88d
Browse files Browse the repository at this point in the history
In the FAQ of Valloric/YouCompleteMe, there was an issue of C++ standard
library headers not found (ycm-core/YouCompleteMe#303) that has been
resolved with a workaround, and @cpradog has kindly implemented it.

However, this workaround has not yet been incorporated into template.py
in rdnetto/YCM-Generator, so adding this becomes the main purpose of
this fork.
  • Loading branch information
leofang committed Oct 23, 2016
1 parent 4d92151 commit 062f14b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion template.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,28 @@

import os
import ycm_core
import re
import subprocess


flags = [
# INSERT FLAGS HERE
]


def LoadSystemIncludes():
regex = re.compile(ur'(?:\#include \<...\> search starts here\:)(?P<list>.*?)(?:End of search list)', re.DOTALL);
process = subprocess.Popen(['clang', '-v', '-E', '-x', 'c++', '-'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE);
process_out, process_err = process.communicate('');
output = process_out + process_err;
includes = [];
for p in re.search(regex, output).group('list').split('\n'):
p = p.strip();
if len(p) > 0 and p.find('(framework directory)') < 0:
includes.append('-isystem');
includes.append(p);
return includes;

# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
Expand All @@ -54,6 +70,8 @@
database = None

SOURCE_EXTENSIONS = [ '.C', '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
systemIncludes = LoadSystemIncludes();
flags = flags + systemIncludes;

def DirectoryOfThisScript():
return os.path.dirname( os.path.abspath( __file__ ) )
Expand Down Expand Up @@ -121,7 +139,7 @@ def FlagsForFile( filename, **kwargs ):

final_flags = MakeRelativePathsInFlagsAbsolute(
compilation_info.compiler_flags_,
compilation_info.compiler_working_dir_ )
compilation_info.compiler_working_dir_ ) + systemIncludes

else:
relative_to = DirectoryOfThisScript()
Expand Down

0 comments on commit 062f14b

Please sign in to comment.