Skip to content
This repository has been archived by the owner on Aug 30, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
…83ecfc6

In the FAQ of https://github.com/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 https://github.com/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 6f044a6
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

1 comment on commit 6f044a6

@TotalKrill
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks stuff for me.
I get SyntaxError: invalid syntax (.ycm_extra_conf.py, line 114) when i run :YcmGenerateConfig and then use it

Please sign in to comment.