# HG changeset patch # User Ludovic Chabant # Date 1424471831 28800 # Node ID 1a853b37eddfaf262656aeb465e1293dea213cc1 # Parent 7000d598a2a7d31f2e995445d94ef0da6377f322 Add some mostly-working Cscope module (for Windows). diff -r 7000d598a2a7 -r 1a853b37eddf autoload/gutentags/cscope.vim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/autoload/gutentags/cscope.vim Fri Feb 20 14:37:11 2015 -0800 @@ -0,0 +1,68 @@ +" Cscope module for Gutentags + +if !has('cscope') + throw "Can't enable the cscope module for Gutentags, this Vim has ". + \"no support for cscope files." +endif + +" Global Options {{{ + +if !exists('g:gutentags_cscope_executable') + let g:gutentags_cscope_executable = 'cscope' +endif + +if !exists('g:gutentags_scopefile') + let g:gutentags_scopefile = 'cscope.out' +endif + +if !exists('g:gutentags_auto_add_cscope') + let g:gutentags_auto_add_cscope = 1 +endif + +" }}} + +" Gutentags Module Interface {{{ + +let s:runner_exe = gutentags#get_plat_file('update_scopedb') +let s:added_dbs = [] + +function! gutentags#cscope#init(project_root) abort + let l:dbfile_path = gutentags#get_cachefile( + \a:project_root, g:gutentags_scopefile) + let b:gutentags_files['cscope'] = l:dbfile_path + + if g:gutentags_auto_add_cscope && filereadable(l:dbfile_path) + if index(s:added_dbs, l:dbfile_path) < 0 + call add(s:added_dbs, l:dbfile_path) + execute 'cs add ' . fnameescape(l:dbfile_path) + endif + endif +endfunction + +function! gutentags#cscope#generate(proj_dir, tags_file, write_mode) abort + let l:cmd = gutentags#get_execute_cmd() . s:runner_exe + let l:cmd .= ' -e ' . g:gutentags_cscope_executable + let l:cmd .= ' -p ' . a:proj_dir + let l:cmd .= ' -f ' . a:tags_file + let l:cmd .= ' ' + let l:cmd .= gutentags#get_execute_cmd_suffix() + + call gutentags#trace("Running: " . l:cmd) + call gutentags#trace("In: " . getcwd()) + if !g:gutentags_fake + if !g:gutentags_trace + silent execute l:cmd + else + execute l:cmd + endif + + let l:full_scopedb_file = fnamemodify(a:tags_file, ':p') + call gutentags#add_progress('cscope', l:full_scopedb_file) + else + call gutentags#trace("(fake... not actually running)") + endif + call gutentags#trace("") +endfunction + +" }}} + diff -r 7000d598a2a7 -r 1a853b37eddf plat/win32/update_scopedb.cmd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plat/win32/update_scopedb.cmd Fri Feb 20 14:37:11 2015 -0800 @@ -0,0 +1,74 @@ +@echo off +setlocal EnableExtensions EnableDelayedExpansion + +rem ========================================== +rem PARSE ARGUMENTS +rem ========================================== + +set CSCOPE_EXE=cscope +set DB_FILE=scope.out + +:ParseArgs +if [%1]==[] goto :DoneParseArgs +if [%1]==[-e] ( + set CSCOPE_EXE=%~2 + shift + goto :LoopParseArgs +) +if [%1]==[-f] ( + set DB_FILE=%~2 + shift + goto :LoopParseArgs +) +if [%1]==[-p] ( + set PROJ_ROOT=%~2 + shift + goto :LoopParseArgs +) +echo Invalid Argument: %1 +goto :Usage + +:LoopParseArgs +shift +goto :ParseArgs + +:DoneParseArgs + + +rem ========================================== +rem GENERATE DATABASE +rem ========================================== + +echo Locking db file +echo locked > "%DB_FILE%.lock" + +echo Running cscope +cscope -R -b -k -f "%DB_FILE%" +if ERRORLEVEL 1 ( + echo ERROR: Cscope executable returned non-zero code. +) + +echo Unlocking db file +del /F "%DB_FILE%.lock" +if ERRORLEVEL 1 ( + echo ERROR: Unable to remove file lock. +) + +echo Done. + +goto :EOF + + +rem ========================================== +rem USAGE +rem ========================================== + +:Usage +echo Usage: +echo %~n0 ^ +echo. +echo -e [exe=cscope]: The cscope executable to run +echo -f [file=scope.out]: The path to the database file to create +echo -p [dir=]: The path to the project root +echo. +