Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cscope.out.files generation for windows #355

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 99 additions & 99 deletions autoload/gutentags/cscope.vim
Original file line number Diff line number Diff line change
@@ -1,99 +1,99 @@
" 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

if !exists('g:gutentags_cscope_build_inverted_index')
let g:gutentags_cscope_build_inverted_index = 0
endif

" }}}

" Gutentags Module Interface {{{

let s:runner_exe = gutentags#get_plat_file('update_scopedb')
let s:unix_redir = (&shellredir =~# '%s') ? &shellredir : &shellredir . ' %s'
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)
silent! execute 'cs add ' . fnameescape(l:dbfile_path)
endif
endif
endfunction

function! gutentags#cscope#generate(proj_dir, tags_file, gen_opts) abort
let l: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:file_list_cmd =
\ gutentags#get_project_file_list_cmd(a:proj_dir)
if !empty(l:file_list_cmd)
let l:cmd += ['-L', '"' . l:file_list_cmd . '"']
endif
if g:gutentags_cscope_build_inverted_index
let l:cmd += ['-I']
endif
let l:cmd = gutentags#make_args(l:cmd)

call gutentags#trace("Running: " . string(l:cmd))
call gutentags#trace("In: " . getcwd())
if !g:gutentags_fake
let l:job_opts = gutentags#build_default_job_options('cscope')
let l:job = gutentags#start_job(l:cmd, l:job_opts)
call gutentags#add_job('cscope', a:tags_file, l:job)
else
call gutentags#trace("(fake... not actually running)")
endif
endfunction

function! gutentags#cscope#on_job_exit(job, exit_val) abort
let l:job_idx = gutentags#find_job_index_by_data('cscope', a:job)
let l:dbfile_path = gutentags#get_job_tags_file('cscope', l:job_idx)
call gutentags#remove_job('cscope', l:job_idx)

if a:exit_val == 0
if index(s:added_dbs, l:dbfile_path) < 0
call add(s:added_dbs, l:dbfile_path)
silent! execute 'cs add ' . fnameescape(l:dbfile_path)
else
silent! execute 'cs reset'
endif
elseif !g:__gutentags_vim_is_leaving
call gutentags#warning(
\"cscope job failed, returned: ".
\string(a:exit_val))
endif
if has('win32') && g:__gutentags_vim_is_leaving
" The process got interrupted because Vim is quitting.
" Remove the db file on Windows because there's no `trap`
" statement in the update script.
try | call delete(l:dbfile_path) | endtry
endif
endfunction

" }}}

" 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
if !exists('g:gutentags_cscope_build_inverted_index')
let g:gutentags_cscope_build_inverted_index = 0
endif
" }}}
" Gutentags Module Interface {{{
let s:runner_exe = gutentags#get_plat_file('update_scopedb')
let s:unix_redir = (&shellredir =~# '%s') ? &shellredir : &shellredir . ' %s'
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)
silent! execute 'cs add ' . fnameescape(l:dbfile_path)
endif
endif
endfunction
function! gutentags#cscope#generate(proj_dir, tags_file, gen_opts) abort
let l: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:file_list_cmd =
\ gutentags#get_project_file_list_cmd(a:proj_dir)
if !empty(l:file_list_cmd)
let l:cmd += ['-L', '"' . l:file_list_cmd . '"']
endif
if g:gutentags_cscope_build_inverted_index
let l:cmd += ['-I']
endif
let l:cmd = gutentags#make_args(l:cmd)
call gutentags#trace("Running: " . string(l:cmd))
call gutentags#trace("In: " . getcwd())
if !g:gutentags_fake
let l:job_opts = gutentags#build_default_job_options('cscope')
let l:job = gutentags#start_job(l:cmd, l:job_opts)
call gutentags#add_job('cscope', a:tags_file, l:job)
else
call gutentags#trace("(fake... not actually running)")
endif
endfunction
function! gutentags#cscope#on_job_exit(job, exit_val) abort
let l:job_idx = gutentags#find_job_index_by_data('cscope', a:job)
let l:dbfile_path = gutentags#get_job_tags_file('cscope', l:job_idx)
call gutentags#remove_job('cscope', l:job_idx)
if a:exit_val == 0
if index(s:added_dbs, l:dbfile_path) < 0
call add(s:added_dbs, l:dbfile_path)
silent! execute 'cs add ' . fnameescape(l:dbfile_path)
else
silent! execute 'cs reset'
endif
elseif !g:__gutentags_vim_is_leaving
" call gutentags#warning(
" \"cscope job failed, returned: ".
" \string(a:exit_val))
endif
if has('win32') && g:__gutentags_vim_is_leaving
" The process got interrupted because Vim is quitting.
" Remove the db file on Windows because there's no `trap`
" statement in the update script.
try | call delete(l:dbfile_path) | endtry
endif
endfunction
" }}}
160 changes: 80 additions & 80 deletions autoload/gutentags/cscope_maps.vim
Original file line number Diff line number Diff line change
@@ -1,80 +1,80 @@
" cscope_maps module for Gutentags

if !has('nvim') || !exists(":Cscope")
throw "Can't enable the cscope_maps module for Gutentags, this Vim has ".
\"no support for cscope_maps files."
endif

" Global Options {{{

if !exists('g:gutentags_cscope_executable_maps')
let g:gutentags_cscope_executable_maps = 'cscope'
endif

if !exists('g:gutentags_scopefile_maps')
let g:gutentags_scopefile_maps = 'cscope.out'
endif

if !exists('g:gutentags_cscope_build_inverted_index_maps')
let g:gutentags_cscope_build_inverted_index_maps = 0
endif

" }}}

" Gutentags Module Interface {{{

let s:runner_exe = gutentags#get_plat_file('update_scopedb')
let s:unix_redir = (&shellredir =~# '%s') ? &shellredir : &shellredir . ' %s'
let s:added_dbs = []

function! gutentags#cscope_maps#init(project_root) abort
let l:dbfile_path = gutentags#get_cachefile(
\a:project_root, g:gutentags_scopefile_maps)
let b:gutentags_files['cscope_maps'] = l:dbfile_path
endfunction

function! gutentags#cscope_maps#generate(proj_dir, tags_file, gen_opts) abort
let l:cmd = [s:runner_exe]
let l:cmd += ['-e', g:gutentags_cscope_executable_maps]
let l:cmd += ['-p', a:proj_dir]
let l:cmd += ['-f', a:tags_file]
let l:file_list_cmd =
\ gutentags#get_project_file_list_cmd(a:proj_dir)
if !empty(l:file_list_cmd)
let l:cmd += ['-L', '"' . l:file_list_cmd . '"']
endif
if g:gutentags_cscope_build_inverted_index_maps
let l:cmd += ['-I']
endif
let l:cmd = gutentags#make_args(l:cmd)

call gutentags#trace("Running: " . string(l:cmd))
call gutentags#trace("In: " . getcwd())
if !g:gutentags_fake
let l:job_opts = gutentags#build_default_job_options('cscope_maps')
let l:job = gutentags#start_job(l:cmd, l:job_opts)
" Change cscope_maps db_file to gutentags' tags_file
" Useful for when g:gutentags_cache_dir is used.
let g:cscope_maps_db_file = a:tags_file
call gutentags#add_job('cscope_maps', a:tags_file, l:job)
else
call gutentags#trace("(fake... not actually running)")
endif
endfunction

function! gutentags#cscope_maps#on_job_exit(job, exit_val) abort
let l:job_idx = gutentags#find_job_index_by_data('cscope_maps', a:job)
let l:dbfile_path = gutentags#get_job_tags_file('cscope_maps', l:job_idx)
call gutentags#remove_job('cscope_maps', l:job_idx)

if a:exit_val == 0
call gutentags#trace("NOOP! cscope_maps does not need add or reset command")
elseif !g:__gutentags_vim_is_leaving
call gutentags#warning(
\"cscope job failed, returned: ".
\string(a:exit_val))
endif
endfunction

" }}}

" cscope_maps module for Gutentags
if !has('nvim') || !exists(":Cscope")
throw "Can't enable the cscope_maps module for Gutentags, this Vim has ".
\"no support for cscope_maps files."
endif
" Global Options {{{
if !exists('g:gutentags_cscope_executable_maps')
let g:gutentags_cscope_executable_maps = 'cscope'
endif
if !exists('g:gutentags_scopefile_maps')
let g:gutentags_scopefile_maps = 'cscope.out'
endif
if !exists('g:gutentags_cscope_build_inverted_index_maps')
let g:gutentags_cscope_build_inverted_index_maps = 0
endif
" }}}
" Gutentags Module Interface {{{
let s:runner_exe = gutentags#get_plat_file('update_scopedb')
let s:unix_redir = (&shellredir =~# '%s') ? &shellredir : &shellredir . ' %s'
let s:added_dbs = []
function! gutentags#cscope_maps#init(project_root) abort
let l:dbfile_path = gutentags#get_cachefile(
\a:project_root, g:gutentags_scopefile_maps)
let b:gutentags_files['cscope_maps'] = l:dbfile_path
endfunction
function! gutentags#cscope_maps#generate(proj_dir, tags_file, gen_opts) abort
let l:cmd = [s:runner_exe]
let l:cmd += ['-e', g:gutentags_cscope_executable_maps]
let l:cmd += ['-p', a:proj_dir]
let l:cmd += ['-f', a:tags_file]
let l:file_list_cmd =
\ gutentags#get_project_file_list_cmd(a:proj_dir)
if !empty(l:file_list_cmd)
let l:cmd += ['-L', '"' . l:file_list_cmd . '"']
endif
if g:gutentags_cscope_build_inverted_index_maps
let l:cmd += ['-I']
endif
let l:cmd = gutentags#make_args(l:cmd)
call gutentags#trace("Running: " . string(l:cmd))
call gutentags#trace("In: " . getcwd())
if !g:gutentags_fake
let l:job_opts = gutentags#build_default_job_options('cscope_maps')
let l:job = gutentags#start_job(l:cmd, l:job_opts)
" Change cscope_maps db_file to gutentags' tags_file
" Useful for when g:gutentags_cache_dir is used.
let g:cscope_maps_db_file = a:tags_file
call gutentags#add_job('cscope_maps', a:tags_file, l:job)
else
call gutentags#trace("(fake... not actually running)")
endif
endfunction
function! gutentags#cscope_maps#on_job_exit(job, exit_val) abort
let l:job_idx = gutentags#find_job_index_by_data('cscope_maps', a:job)
let l:dbfile_path = gutentags#get_job_tags_file('cscope_maps', l:job_idx)
call gutentags#remove_job('cscope_maps', l:job_idx)
" if a:exit_val == 0
" call gutentags#trace("NOOP! cscope_maps does not need add or reset command")
" elseif !g:__gutentags_vim_is_leaving
" call gutentags#warning(
" \"cscope job failed, returned: ".
" \string(a:exit_val))
" endif
endfunction
" }}}
8 changes: 4 additions & 4 deletions plat/win32/update_scopedb.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ echo locked > "%DB_FILE%.lock"

echo Running cscope >> %LOG_FILE%
if NOT ["%FILE_LIST_CMD%"]==[""] (
if ["%PROJECT_ROOT%"]==["."] (
for /F "usebackq delims=" %%F in (`%FILE_LIST_CMD%`) do @echo "%%F">%DB_FILE%.files
if ["%PROJECT_ROOT%"]==[""] (
for /F "usebackq delims=" %%F in (`%FILE_LIST_CMD%`) do @echo ".\%%F">>%DB_FILE%.files
) else (
rem Potentially useful:
rem http://stackoverflow.com/questions/9749071/cmd-iterate-stdin-piped-from-another-command
for /F "usebackq delims=" %%F in (`%FILE_LIST_CMD%`) do @echo "%PROJECT_ROOT%\%%F">%DB_FILE%.files
for /F "usebackq delims=" %%F in (`%FILE_LIST_CMD%`) do @echo "%PROJECT_ROOT%\%%F">>%DB_FILE%.files
)
) ELSE (
for /F "usebackq delims=" %%F in (`dir /S /B /A-D .`) do @echo "%%F">%DB_FILE%.files
for /F "usebackq delims=" %%F in (`dir /S /B /A-D .`) do @echo "%%F">>%DB_FILE%.files
)

set FILESIZE=0
Expand Down