Angleichen bmsk - bmsx: Bmsk benutzt GetVars, ...

git-svn-id: https://vimsuite.svn.sourceforge.net/svnroot/vimsuite/trunk@134 eb2d0018-73a3-4aeb-bfe9-1def61c9ec69
This commit is contained in:
qx13468 2007-04-13 09:08:13 +00:00
parent 28d94f21ed
commit 0c7dbfc4be
4 changed files with 43 additions and 75 deletions

View File

@ -14,9 +14,6 @@ let b:forceRedoTexCompiler = 'yes'
let g:Tex_ShowallLines = 1
"execute 'source ' . expand(g:vimfiles . '/compiler/tex.vim')
let g:makeprg = simplify(GetBmskDir() . '/make_fsw.bat')
let &makeprg = g:makeprg . ' $*'
if exists('g:make_log')
let &shellpipe = '| ' . g:tee . PathNormpath(make_log) . ' | ' . g:tee
else
@ -133,22 +130,6 @@ if (g:SW_Stand != '')
let g:makeopts = g:makeopts . ' Stand=' . g:SW_Stand
endif
" user commands
command! -nargs=* Make execute(':make! <args> ' . g:makeopts)
command! -nargs=0 Clean call Clean()
command! -nargs=0 CleanAll call CleanAll()
command! Compile call Compile_File()
command! PreCompile call PreCompile_File()
" Clean function
function! Clean()
Make clean
endfunction
function! CleanAll()
cscope kill -1
Make cleanall
endfunction
" reformat i-file
command! ReformatIFile call Reformat_IFile()
function! Reformat_IFile() abort
@ -168,38 +149,3 @@ function! Reformat_IFile() abort
endwhile
endfunction
function! GetMakeVar(varName)
let var = GetMakeVars([a:varName])
if has_key(var, a:varName)
let varValue = var[a:varName]
else
let varValue = ''
endif
return varValue
endfunction
function! GetMakeVars(varNameList)
let varlist = {}
try
let vars = join(a:varNameList, ' ')
let command = g:makeprg . g:makeopts . ' getvar name="' . vars . '"'
let output = system(command)
let lines = split(output, "\n")
if len(lines) == 1
" make < make-43 (Antwort nur VALUE)
let RE = '\(.*\)'
let SU = "let varlist['" . vars . "']='\\1'"
else
" make >= make-43 (Antwort: NAME=VALUE
let RE = '^\(\w\+\)=\(.*\)\s*'
let SU = "let varlist['\\1']='\\2'"
endif
for line in lines
if match(line, RE) >= 0
execute substitute(line, RE, SU, '')
endif
endfor
endtry
return varlist
endfunction

View File

@ -10,7 +10,9 @@ setlocal softtabstop=4
setlocal formatoptions=croq
" vimfiles sollen immer im unix-Format gespeichert werden
setlocal fileformat=unix
if filereadable('%')
setlocal fileformat=unix
endif
" commenting
let b:commentstring = '"'

View File

@ -45,6 +45,8 @@ function s:SetBmskProject(basedir)
let basedir = fnamemodify(makefile, ':p:h')
let makefile = fnamemodify(makefile, ':t')
if ((makefile == 'make_fsw.bat') || (makefile == 'makefile.mak') || (makefile == 'makefile'))
let g:makeCommand = makefile
let &makeprg = g:makeCommand . ' $*'
call s:SetBmskDirs(basedir)
else
echo 'No makefile:' makefile
@ -59,6 +61,8 @@ function s:SetBmskProject(basedir)
let basedir = fnamemodify(makefile, ':p:h')
endif
if (filereadable(makefile))
let g:makeCommand = makefile
let &makeprg = g:makeCommand . ' $*'
call s:SetBmskDirs(basedir)
else
echo 'No makefile' makefile
@ -755,7 +759,8 @@ command -nargs=? GrepBmsk call GrepFull(GetBmskSwDir(), '*.c *.h *.kgs', '<args>
" ----------------
" Make and compile
" ----------------
command -complete=custom,GetAllBmskTargets -nargs=* Bmsk call s:Bmsk('<args>')
"command -complete=custom,GetAllBmskTargets -nargs=* Make call s:Make('<args>')
command -complete=custom,GetAllBmskTargets -nargs=* Bmsk call s:Make('<args>')
command -complete=custom,GetAllBmskTargets -nargs=* BmskDoku call s:BmskDoku('<args>')
command -nargs=* Clean compiler bmsk | Clean <args>
command -nargs=* CleanAll compiler bmsk | CleanAll <args>
@ -764,11 +769,11 @@ command -nargs=* Lint Bmsk <args> %:t:r.lint
command -complete=customlist,GetAllBmskSWStand -nargs=1 BmskAll call s:BmskAll('<args>')
" Programmstand compilieren
function s:Bmsk(args)
function s:Make(args)
echo a:args
cscope kill -1
compiler bmsk
execute 'Make ' . a:args
execute 'make!' a:args g:makeopts
CscopeConnect
clist
endfunction

View File

@ -25,7 +25,7 @@ let g:projectFile = fnamemodify($VIMRUNTIME . '/../projects.txt', ':p')
" SetProject
" ----------
if (v:version > 602)
command -complete=customlist,GetAllMakefiles -nargs=? SetProject call s:SetProject('<args>')
command -complete=customlist,GetAllMakefiles -nargs=? SetProject call SetProject('<args>')
else
command -nargs=1 SetProject call SetProject('<args>')
endif
@ -84,7 +84,7 @@ endfunction
" Find makefile and set some options
" ----------------------------------
function s:SetProject(makefile)
function SetProject(makefile)
if ((a:makefile == '') && has('browse'))
" Browse for makefile
if exists('g:WA')
@ -106,13 +106,16 @@ function s:SetProject(makefile)
" split file name and path
let g:basedir = fnamemodify(makefilePath, ':p:h')
let g:makefileName = fnamemodify(makefilePath, ':t')
let makefileName = fnamemodify(makefilePath, ':t')
" test if makefile is a batch-script
let ext = fnamemodify(g:makefileName, ':e')
let ext = fnamemodify(makefileName, ':e')
if ext == 'bat'
let &makeprg = makefilePath . ' $*'
let g:makeCommand = makefilePath
else
let g:makeCommand = 'make -f ' . makefilePath
endif
let &makeprg = g:makeCommand . ' $*'
" set directories
execute 'cd ' . g:basedir
@ -138,7 +141,7 @@ function s:SetProjectVariables()
\ 'VIM_CSCOPEFILE',
\ 'GOALS',
\]
let s:Variables = s:GetMakeVars(varnames)
let s:Variables = GetMakeVars(varnames)
echo 'Reading variables from makefile'
echo '-------------------------------'
@ -154,7 +157,7 @@ function s:SetProjectVariables()
try
execute 'set path=' . s:Variables['VIM_PATH']
catch
echoerr 'cant set path to ' . s:Variables['VIM_PATH']
echoerr 'cant set path to "' . s:Variables['VIM_PATH'] . '"'
echoerr 'check the make variable VIM_PATH'
endtry
else
@ -166,7 +169,7 @@ function s:SetProjectVariables()
try
execute 'set tags=' . s:Variables['VIM_TAGS']
catch
echoerr 'cant set tags to ' . s:Variables['VIM_TAGS']
echoerr 'cant set tags to "' . s:Variables['VIM_TAGS'] . '"'
echoerr 'check the make variable VIM_TAGS'
endtry
else
@ -178,7 +181,7 @@ function s:SetProjectVariables()
try
execute 'set cscopeprg=' . s:Variables['VIM_CSCOPEPRG']
catch
echoerr 'cant set cscopeprg to ' . s:Variables['VIM_CSCOPEPRG']
echoerr 'cant set cscopeprg to "' . s:Variables['VIM_CSCOPEPRG'] . '"'
echoerr 'check the make variable VIM_CSCOPEPRG'
endtry
else
@ -189,7 +192,7 @@ function s:SetProjectVariables()
cscope kill -1
execute 'cscope add ' . s:Variables['VIM_CSCOPEFILE']
catch
echomsg 'cant add cscope-file ' . s:Variables['VIM_CSCOPEFILE']
echomsg 'cant add cscope-file "' . s:Variables['VIM_CSCOPEFILE'] . '"'
echomsg 'check the make variable VIM_CSCOPEFILE and if file exists'
endtry
else
@ -201,7 +204,7 @@ function s:SetProjectVariables()
try
execute 'compiler ' . s:Variables['VIM_COMPILER']
catch
echoerr 'cant set compiler to ' . s:Variables['VIM_COMPILER']
echoerr 'cant set compiler to "' . s:Variables['VIM_COMPILER'] . '"'
echoerr 'check the make variable VIM_COMPILER'
endtry
else
@ -209,29 +212,30 @@ function s:SetProjectVariables()
endif
catch
echoerr 'Could not read variables from makefile (vim-script-error)'
echoerr 'Error while reading make-variables: ' . v:exception
endtry
endfunction
" Get values for a list of variables as dictionary
function! s:GetMakeVars(varNameList)
function GetMakeVars(varNameList)
let varlist = {}
try
let vars = join(a:varNameList, ' ')
let command = g:makefileName . ' getvar name="' . vars . '"'
let command = g:makeCommand . ' getvar name="' . vars . '"'
"echomsg command
let output = system(command)
let lines = split(output, "\n")
let RE = '^\(\w\+\)=\(.*\)\s*'
let SU = "let varlist['\\1']='\\2'"
"echo 'getvars:'
"echomsg 'getvars:'
for line in lines
" echo line
"echomsg line
if match(line, RE) >= 0
execute substitute(line, RE, SU, '')
endif
endfor
"echo ''
"echomsg ''
catch
echoerr 'Could not read make variables'
endtry
@ -248,6 +252,17 @@ function! s:GetMakeVars(varNameList)
return varlist
endfunction
function GetMakeVar(varName)
let var = GetMakeVars([a:varName])
try
varValue = var[a:varName]
catch
varValue = ''
echoerr 'Could not read make-variable "' . varName . '"'
endtry
return varValue
endfunction
" ------------------------------------------
" special make-command for target-completion
" ------------------------------------------