Author: breser Date: Fri Apr 26 20:06:35 2013 New Revision: 1476374 URL: http://svn.apache.org/r1476374 Log: Add support for YouCompleteMe vim plugin.
Needs the following tools to be useful: YouCompleteMe: https://github.com/Valloric/YouCompleteMe Bear: https://github.com/rizsotto/Bear * .ycm_extra_conf.py: Add config file for YouCompleteMe plugin, which looks for compile flags in compile_commands.json in the srcdir. * Makefile.in: Add new compile-commands target that produces compile_commands.json by using bear. * trunk/ (svn:ignore): Ignore compile_commands.json file. Added: subversion/trunk/.ycm_extra_conf.py Modified: subversion/trunk/ (props changed) subversion/trunk/Makefile.in Propchange: subversion/trunk/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Fri Apr 26 20:06:35 2013 @@ -52,3 +52,4 @@ serf gtest .git .gitignore +compile_commands.json Added: subversion/trunk/.ycm_extra_conf.py URL: http://svn.apache.org/viewvc/subversion/trunk/.ycm_extra_conf.py?rev=1476374&view=auto ============================================================================== --- subversion/trunk/.ycm_extra_conf.py (added) +++ subversion/trunk/.ycm_extra_conf.py Fri Apr 26 20:06:35 2013 @@ -0,0 +1,59 @@ +import os +import ycm_core +from clang_helpers import PrepareClangFlags + +compilation_database_folder = os.path.dirname(os.path.realpath(__file__)) + +if compilation_database_folder: + database = ycm_core.CompilationDatabase( compilation_database_folder ) +else: + database = None + +def MakeRelativePathsInFlagsAbsolute( flags, working_directory ): + if not working_directory: + return flags + new_flags = [] + make_next_absolute = False + path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ] + for flag in flags: + new_flag = flag + + if make_next_absolute: + make_next_absolute = False + if not flag.startswith( '/' ): + new_flag = os.path.join( working_directory, flag ) + + for path_flag in path_flags: + if flag == path_flag: + make_next_absolute = True + break + + if flag.startswith( path_flag ): + path = flag[ len( path_flag ): ] + new_flag = path_flag + os.path.join( working_directory, path ) + break + + if new_flag: + new_flags.append( new_flag ) + return new_flags + + +def FlagsForFile( filename ): + if database: + # Bear in mind that compilation_info.compiler_flags_ does NOT return a + # python list, but a "list-like" StringVec object + compilation_info = database.GetCompilationInfoForFile( filename ) + final_flags = PrepareClangFlags( + MakeRelativePathsInFlagsAbsolute( + compilation_info.compiler_flags_, + compilation_info.compiler_working_dir_ ), + filename ) + do_cache = False + else: + final_flags = [ ] + do_cache = True + + return { + 'flags': final_flags, + 'do_cache': do_cache + } Modified: subversion/trunk/Makefile.in URL: http://svn.apache.org/viewvc/subversion/trunk/Makefile.in?rev=1476374&r1=1476373&r2=1476374&view=diff ============================================================================== --- subversion/trunk/Makefile.in (original) +++ subversion/trunk/Makefile.in Fri Apr 26 20:06:35 2013 @@ -571,6 +571,9 @@ svnsshcheck: bin $(TEST_DEPS) @BDB_TEST_ bdbcheck: bin $(TEST_DEPS) @BDB_TEST_DEPS@ @$(MAKE) check FS_TYPE=bdb +compile-commands: + @bear -o $(abs_srcdir)/compile_commands.json -- $(MAKE) all + # Create an execution coverage report from the data collected during # all execution since the last reset. gcov:
